diff --git a/config.cc b/config.cc index 12bfab00b..fc4b0db90 100644 --- a/config.cc +++ b/config.cc @@ -283,8 +283,9 @@ Preferences::Preferences(): , limitInputPhraseLength( false ) , inputPhraseLengthLimit( 1000 ) , maxDictionaryRefsInContextMenu ( 20 ) -, synonymSearchEnabled( true ) - , stripClipboard( false ) +, synonymSearchEnabled( true ), + stripClipboard( false ), + raiseWindowOnSearch(true) { } @@ -1041,6 +1042,9 @@ Class load() if ( !preferences.namedItem( "stripClipboard" ).isNull() ) c.preferences.stripClipboard = ( preferences.namedItem( "stripClipboard" ).toElement().text() == "1" ); + if( !preferences.namedItem( "raiseWindowOnSearch" ).isNull() ) + c.preferences.raiseWindowOnSearch = ( preferences.namedItem( "raiseWindowOnSearch" ).toElement().text() == "1" ); + QDomNode fts = preferences.namedItem( "fullTextSearch" ); if ( !fts.isNull() ) @@ -2032,6 +2036,10 @@ void save( Class const & c ) opt.appendChild( dd.createTextNode( c.preferences.stripClipboard ? "1" : "0" ) ); preferences.appendChild( opt ); + opt = dd.createElement( "raiseWindowOnSearch" ); + opt.appendChild( dd.createTextNode( c.preferences.raiseWindowOnSearch ? "1" : "0" ) ); + preferences.appendChild( opt ); + { QDomNode hd = dd.createElement( "fullTextSearch" ); preferences.appendChild( hd ); diff --git a/config.hh b/config.hh index 0fbfd665e..5b7151f66 100644 --- a/config.hh +++ b/config.hh @@ -382,6 +382,7 @@ struct Preferences bool synonymSearchEnabled; bool stripClipboard; + bool raiseWindowOnSearch; QString addonStyle; diff --git a/mainwindow.cc b/mainwindow.cc index 80d17dc4c..2bf2b1c9a 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -2934,12 +2934,12 @@ void MainWindow::toggleMainWindow( bool onlyShow ) raise(); shown = true; } - else - if ( !isActiveWindow() ) - { + else if( !isActiveWindow() ) { qApp->setActiveWindow( this ); - raise(); - activateWindow(); + if( cfg.preferences.raiseWindowOnSearch ) { + raise(); + activateWindow(); + } shown = true; } else diff --git a/preferences.cc b/preferences.cc index 3e38a9094..63f8e14ab 100644 --- a/preferences.cc +++ b/preferences.cc @@ -223,6 +223,8 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): ui.stripClipboard->setChecked( p.stripClipboard ); + ui.raiseWindowOnSearch->setChecked( p.raiseWindowOnSearch ); + ui.maxDictsInContextMenu->setValue( p.maxDictionaryRefsInContextMenu ); // Different platforms have different keys available @@ -443,6 +445,7 @@ Config::Preferences Preferences::getPreferences() p.ignoreDiacritics = ui.ignoreDiacritics->isChecked(); p.ignorePunctuation = ui.ignorePunctuation->isChecked(); p.stripClipboard = ui.stripClipboard->isChecked(); + p.raiseWindowOnSearch = ui.raiseWindowOnSearch->isChecked(); p.synonymSearchEnabled = ui.synonymSearchEnabled->isChecked(); diff --git a/preferences.ui b/preferences.ui index 94a1b6d8a..5804d467b 100644 --- a/preferences.ui +++ b/preferences.ui @@ -1768,6 +1768,13 @@ from Stardict, Babylon and GLS dictionaries + + + + On a new search, focus the main or popup window even if it's visible + + + diff --git a/scanpopup.cc b/scanpopup.cc index 67ddf99db..8f337f959 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -580,18 +580,16 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus ) // This produced some funky mouse grip-related bugs so we commented it out //QApplication::processEvents(); // Make window appear immediately no matter what } - else - if ( ui.pinButton->isChecked() ) - { + else if( ui.pinButton->isChecked() ) { // Pinned-down window isn't always on top, so we need to raise it show(); - activateWindow(); - raise(); + if( cfg.preferences.raiseWindowOnSearch ) { + activateWindow(); + raise(); + } } #if defined( HAVE_X11 ) - else - if ( ( windowFlags() & Qt::Tool ) == Qt::Tool ) - { + else if( ( windowFlags() & Qt::Tool ) == Qt::Tool && cfg.preferences.raiseWindowOnSearch ) { // Ensure that the window with Qt::Tool flag always has focus on X11. activateWindow(); raise();