diff --git a/articleview.cc b/articleview.cc index 07eb016d..d1501b54 100644 --- a/articleview.cc +++ b/articleview.cc @@ -941,7 +941,6 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) QMenu menu( this ); - QAction * followLink = 0; QAction * followLinkExternal = 0; QAction * followLinkNewTab = 0; @@ -1086,6 +1085,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) if ( !menu.isEmpty() ) { + connect( this, SIGNAL( closePopupMenu() ), &menu, SLOT( close() ) ); QAction * result = menu.exec( ui.definition->mapToGlobal( pos ) ); if ( !result ) @@ -1397,6 +1397,11 @@ void ArticleView::onJsActiveArticleChanged(QString const & id) emit activeArticleChanged( id.mid( 7 ) ); } +void ArticleView::closeMenu() +{ + emit closePopupMenu(); +} + void ArticleView::doubleClicked() { // We might want to initiate translation of the selected word diff --git a/articleview.hh b/articleview.hh index ecb40e17..07a04853 100644 --- a/articleview.hh +++ b/articleview.hh @@ -192,12 +192,18 @@ signals: /// Signal to add word to history even if history is disabled void forceAddWordToHistory( const QString & word); + /// Signal to close popup menu + void closePopupMenu(); + public slots: void on_searchPrevious_clicked(); void on_searchNext_clicked(); void onJsActiveArticleChanged(QString const & id); + /// Receive signal from ScanPopup to close context menu + void closeMenu(); + private slots: void loadFinished( bool ok ); diff --git a/scanpopup.cc b/scanpopup.cc index 0f3bac26..257b2be9 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -636,6 +636,8 @@ void ScanPopup::on_wordListButton_clicked() menu.addAction( results[ x ].first ); } + connect( this, SIGNAL( closeMenu() ), &menu, SLOT( close() ) ); + QAction * result = menu.exec( mapToGlobal( ui.wordListButton->pos() ) + QPoint( 0, ui.wordListButton->height() ) ); @@ -731,6 +733,7 @@ void ScanPopup::hideWindow() { uninterceptMouse(); + emit closeMenu(); hideTimer.stop(); unsetCursor(); hide(); diff --git a/scanpopup.hh b/scanpopup.hh index 001234fd..49663bdf 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -51,6 +51,8 @@ signals: void editGroupRequested( unsigned id ); /// Send word to main window void sendWordToMainWindow( QString const & word ); + /// Close opened menus when window hide + void closeMenu(); public slots: