[vlc-commits] Qt: plugins: activate buttons contextually

Francois Cartegnie git at videolan.org
Mon Feb 20 18:10:31 CET 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Feb 20 18:09:31 2012 +0100| [3b5bfc6e3c723c9988deae1acfd1b27ab43411f3] | committer: Francois Cartegnie

Qt: plugins: activate buttons contextually

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b5bfc6e3c723c9988deae1acfd1b27ab43411f3
---

 modules/gui/qt4/dialogs/plugins.cpp |   24 +++++++++++++-----------
 modules/gui/qt4/dialogs/plugins.hpp |    1 +
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt4/dialogs/plugins.cpp b/modules/gui/qt4/dialogs/plugins.cpp
index d84878e..bd37b61 100644
--- a/modules/gui/qt4/dialogs/plugins.cpp
+++ b/modules/gui/qt4/dialogs/plugins.cpp
@@ -227,8 +227,7 @@ ExtensionTab::ExtensionTab( intf_thread_t *p_intf )
     butMoreInfo = new QPushButton( QIcon( ":/menu/info" ),
                                    qtr( "More information..." ),
                                    this );
-    CONNECT( butMoreInfo, clicked(),
-             this, moreInformation() );
+    CONNECT( butMoreInfo, clicked(), this, moreInformation() );
     hbox->addWidget( butMoreInfo );
 
     // Reload button
@@ -236,18 +235,28 @@ ExtensionTab::ExtensionTab( intf_thread_t *p_intf )
     QPushButton *reload = new QPushButton( QIcon( ":/update" ),
                                            qtr( "Reload extensions" ),
                                            this );
-    CONNECT( reload, clicked(),
-             EM, reloadExtensions() );
+    CONNECT( reload, clicked(), EM, reloadExtensions() );
+    CONNECT( reload, clicked(), this, updateButtons() );
+    CONNECT( extList->selectionModel(),
+             selectionChanged( const QItemSelection &, const QItemSelection & ),
+             this,
+             updateButtons() );
     hbox->addWidget( reload );
 
     // Add buttons hbox
     layout->addItem( hbox );
+    updateButtons();
 }
 
 ExtensionTab::~ExtensionTab()
 {
 }
 
+void ExtensionTab::updateButtons()
+{
+    butMoreInfo->setEnabled( extList->selectionModel()->hasSelection() );
+}
+
 // Do not close on ESC or ENTER
 void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent )
 {
@@ -261,13 +270,6 @@ void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent )
 // Show more information
 void ExtensionTab::moreInformation()
 {
-    if( !extList->selectionModel() ||
-        extList->selectionModel()->selectedIndexes().isEmpty() )
-
-    {
-        return;
-    }
-
     QModelIndex index = extList->selectionModel()->selectedIndexes().first();
     ExtensionCopy *ext = (ExtensionCopy*) index.internalPointer();
     if( !ext )
diff --git a/modules/gui/qt4/dialogs/plugins.hpp b/modules/gui/qt4/dialogs/plugins.hpp
index 20ba740..5494b44 100644
--- a/modules/gui/qt4/dialogs/plugins.hpp
+++ b/modules/gui/qt4/dialogs/plugins.hpp
@@ -100,6 +100,7 @@ private:
 
 private slots:
     void moreInformation();
+    void updateButtons();
 
 private:
     QListView *extList;



More information about the vlc-commits mailing list