mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Let the user disable main window stealing focus when searching. (#387)
* add a checkbox that allows the user to disable main window being raised when search is triggered * run clang-format on the edited lines * partially revert clang-format
This commit is contained in:
parent
76fa9a806a
commit
fb6d4f9ccd
12
config.cc
12
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 );
|
||||
|
|
|
@ -382,6 +382,7 @@ struct Preferences
|
|||
|
||||
bool synonymSearchEnabled;
|
||||
bool stripClipboard;
|
||||
bool raiseWindowOnSearch;
|
||||
|
||||
QString addonStyle;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -1768,6 +1768,13 @@ from Stardict, Babylon and GLS dictionaries</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="raiseWindowOnSearch">
|
||||
<property name="text">
|
||||
<string>On a new search, focus the main or popup window even if it's visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_17">
|
||||
<property name="orientation">
|
||||
|
|
14
scanpopup.cc
14
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();
|
||||
|
|
Loading…
Reference in a new issue