]> git.sesse.net Git - vlc/commitdiff
Qt: plugins: activate buttons contextually
authorFrancois Cartegnie <fcvlcdev@free.fr>
Mon, 20 Feb 2012 17:09:31 +0000 (18:09 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Mon, 20 Feb 2012 17:09:54 +0000 (18:09 +0100)
modules/gui/qt4/dialogs/plugins.cpp
modules/gui/qt4/dialogs/plugins.hpp

index d84878e61e8af741bf665175f2212a074d7796e3..bd37b610d4f35303a8c800fbf138f09c94ccd9fa 100644 (file)
@@ -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 )
index 20ba74081a5540009f4d86cab559f5d03dfa07ae..5494b44b9b7e8a623a812734e6de4c13fb3fcb72 100644 (file)
@@ -100,6 +100,7 @@ private:
 
 private slots:
     void moreInformation();
+    void updateButtons();
 
 private:
     QListView *extList;