From 6edfd15962cc788992f1f8109d591f14af857e59 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Fri, 1 Nov 2024 14:25:41 +0800 Subject: [PATCH] opt: add option about open website in seperate tab --- src/config.cc | 8 ++++++++ src/config.hh | 1 + src/ui/preferences.cc | 2 ++ src/ui/preferences.ui | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/src/config.cc b/src/config.cc index 96b3d842..98c5ebfa 100644 --- a/src/config.cc +++ b/src/config.cc @@ -1082,6 +1082,10 @@ Class load() ( preferences.namedItem( "removeInvalidIndexOnExit" ).toElement().text() == "1" ); } + if ( !preferences.namedItem( "openWebsiteInNewTab" ).isNull() ) { + c.preferences.openWebsiteInNewTab = ( preferences.namedItem( "openWebsiteInNewTab" ).toElement().text() == "1" ); + } + if ( !preferences.namedItem( "maxStringsInHistory" ).isNull() ) { c.preferences.maxStringsInHistory = preferences.namedItem( "maxStringsInHistory" ).toElement().text().toUInt(); } @@ -2111,6 +2115,10 @@ void save( Class const & c ) opt.appendChild( dd.createTextNode( c.preferences.removeInvalidIndexOnExit ? "1" : "0" ) ); preferences.appendChild( opt ); + opt = dd.createElement( "openWebsiteInNewTab" ); + opt.appendChild( dd.createTextNode( c.preferences.openWebsiteInNewTab ? "1" : "0" ) ); + preferences.appendChild( opt ); + opt = dd.createElement( "maxStringsInHistory" ); opt.appendChild( dd.createTextNode( QString::number( c.preferences.maxStringsInHistory ) ) ); preferences.appendChild( opt ); diff --git a/src/config.hh b/src/config.hh index 1a5feaac..32d4c32e 100644 --- a/src/config.hh +++ b/src/config.hh @@ -382,6 +382,7 @@ struct Preferences int maxNetworkCacheSize; bool clearNetworkCacheOnExit; bool removeInvalidIndexOnExit = false; + bool openWebsiteInNewTab = false; qreal zoomFactor; qreal helpZoomFactor; diff --git a/src/ui/preferences.cc b/src/ui/preferences.cc index 9b97c9ef..5a4537cf 100644 --- a/src/ui/preferences.cc +++ b/src/ui/preferences.cc @@ -336,6 +336,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): //Misc ui.removeInvalidIndexOnExit->setChecked( p.removeInvalidIndexOnExit ); + ui.openWebsiteInNewTab->setChecked( p.openWebsiteInNewTab ); // Add-on styles ui.addonStylesLabel->setVisible( ui.addonStyles->count() > 1 ); @@ -494,6 +495,7 @@ Config::Preferences Preferences::getPreferences() p.clearNetworkCacheOnExit = ui.clearNetworkCacheOnExit->isChecked(); p.removeInvalidIndexOnExit = ui.removeInvalidIndexOnExit->isChecked(); + p.openWebsiteInNewTab = ui.openWebsiteInNewTab->isChecked(); p.addonStyle = ui.addonStyles->getCurrentStyle(); diff --git a/src/ui/preferences.ui b/src/ui/preferences.ui index d616e44c..1ad3018a 100644 --- a/src/ui/preferences.ui +++ b/src/ui/preferences.ui @@ -1916,6 +1916,13 @@ from Stardict, Babylon and GLS dictionaries + + + + Open website dictionary in seperate tab + + +