Close popup menus when ScanPopup window closes

This commit is contained in:
Abs62 2012-09-12 18:18:16 +04:00
parent 831d46a6d3
commit e00415e4d2
4 changed files with 17 additions and 1 deletions

View file

@ -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

View file

@ -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 );

View file

@ -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();

View file

@ -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: