Commit 3b5bfc6e authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: plugins: activate buttons contextually

parent 02affbfe
...@@ -227,8 +227,7 @@ ExtensionTab::ExtensionTab( intf_thread_t *p_intf ) ...@@ -227,8 +227,7 @@ ExtensionTab::ExtensionTab( intf_thread_t *p_intf )
butMoreInfo = new QPushButton( QIcon( ":/menu/info" ), butMoreInfo = new QPushButton( QIcon( ":/menu/info" ),
qtr( "More information..." ), qtr( "More information..." ),
this ); this );
CONNECT( butMoreInfo, clicked(), CONNECT( butMoreInfo, clicked(), this, moreInformation() );
this, moreInformation() );
hbox->addWidget( butMoreInfo ); hbox->addWidget( butMoreInfo );
// Reload button // Reload button
...@@ -236,18 +235,28 @@ ExtensionTab::ExtensionTab( intf_thread_t *p_intf ) ...@@ -236,18 +235,28 @@ ExtensionTab::ExtensionTab( intf_thread_t *p_intf )
QPushButton *reload = new QPushButton( QIcon( ":/update" ), QPushButton *reload = new QPushButton( QIcon( ":/update" ),
qtr( "Reload extensions" ), qtr( "Reload extensions" ),
this ); this );
CONNECT( reload, clicked(), CONNECT( reload, clicked(), EM, reloadExtensions() );
EM, reloadExtensions() ); CONNECT( reload, clicked(), this, updateButtons() );
CONNECT( extList->selectionModel(),
selectionChanged( const QItemSelection &, const QItemSelection & ),
this,
updateButtons() );
hbox->addWidget( reload ); hbox->addWidget( reload );
// Add buttons hbox // Add buttons hbox
layout->addItem( hbox ); layout->addItem( hbox );
updateButtons();
} }
ExtensionTab::~ExtensionTab() ExtensionTab::~ExtensionTab()
{ {
} }
void ExtensionTab::updateButtons()
{
butMoreInfo->setEnabled( extList->selectionModel()->hasSelection() );
}
// Do not close on ESC or ENTER // Do not close on ESC or ENTER
void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent ) void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent )
{ {
...@@ -261,13 +270,6 @@ void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent ) ...@@ -261,13 +270,6 @@ void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent )
// Show more information // Show more information
void ExtensionTab::moreInformation() void ExtensionTab::moreInformation()
{ {
if( !extList->selectionModel() ||
extList->selectionModel()->selectedIndexes().isEmpty() )
{
return;
}
QModelIndex index = extList->selectionModel()->selectedIndexes().first(); QModelIndex index = extList->selectionModel()->selectedIndexes().first();
ExtensionCopy *ext = (ExtensionCopy*) index.internalPointer(); ExtensionCopy *ext = (ExtensionCopy*) index.internalPointer();
if( !ext ) if( !ext )
......
...@@ -100,6 +100,7 @@ private: ...@@ -100,6 +100,7 @@ private:
private slots: private slots:
void moreInformation(); void moreInformation();
void updateButtons();
private: private:
QListView *extList; QListView *extList;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment