Merge branch 'vedgy-add-avoid-auto-scrolling-out-of-top-dictionary-option' into staged

This commit is contained in:
yifang 2022-02-12 13:12:21 +08:00
commit 0b10c5c2c5
5 changed files with 153 additions and 190 deletions

View file

@ -543,6 +543,7 @@ void ArticleView::loadFinished( bool result )
} }
} }
else else
if( cfg.preferences.autoScrollToTargetArticle )
{ {
QString const scrollTo = Utils::Url::queryItemValue( url, "scrollto" ); QString const scrollTo = Utils::Url::queryItemValue( url, "scrollto" );
if( isScrollTo( scrollTo ) ) if( isScrollTo( scrollTo ) )

View file

@ -217,6 +217,7 @@ Preferences::Preferences():
autoStart( false ), autoStart( false ),
doubleClickTranslates( true ), doubleClickTranslates( true ),
selectWordBySingleClick( false ), selectWordBySingleClick( false ),
autoScrollToTargetArticle( true ),
escKeyHidesMainWindow( false ), escKeyHidesMainWindow( false ),
alwaysOnTop ( false ), alwaysOnTop ( false ),
searchInDock ( false ), searchInDock ( false ),
@ -862,6 +863,9 @@ Class load()
if ( !preferences.namedItem( "selectWordBySingleClick" ).isNull() ) if ( !preferences.namedItem( "selectWordBySingleClick" ).isNull() )
c.preferences.selectWordBySingleClick = ( preferences.namedItem( "selectWordBySingleClick" ).toElement().text() == "1" ); c.preferences.selectWordBySingleClick = ( preferences.namedItem( "selectWordBySingleClick" ).toElement().text() == "1" );
if ( !preferences.namedItem( "autoScrollToTargetArticle" ).isNull() )
c.preferences.autoScrollToTargetArticle = ( preferences.namedItem( "autoScrollToTargetArticle" ).toElement().text() == "1" );
if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() ) if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() )
c.preferences.escKeyHidesMainWindow = ( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" ); c.preferences.escKeyHidesMainWindow = ( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" );
@ -1725,6 +1729,10 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( c.preferences.selectWordBySingleClick ? "1":"0" ) ); opt.appendChild( dd.createTextNode( c.preferences.selectWordBySingleClick ? "1":"0" ) );
preferences.appendChild( opt ); preferences.appendChild( opt );
opt = dd.createElement( "autoScrollToTargetArticle" );
opt.appendChild( dd.createTextNode( c.preferences.autoScrollToTargetArticle ? "1":"0" ) );
preferences.appendChild( opt );
opt = dd.createElement( "escKeyHidesMainWindow" ); opt = dd.createElement( "escKeyHidesMainWindow" );
opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1":"0" ) ); opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1":"0" ) );
preferences.appendChild( opt ); preferences.appendChild( opt );

View file

@ -293,6 +293,7 @@ struct Preferences
bool autoStart; bool autoStart;
bool doubleClickTranslates; bool doubleClickTranslates;
bool selectWordBySingleClick; bool selectWordBySingleClick;
bool autoScrollToTargetArticle;
bool escKeyHidesMainWindow; bool escKeyHidesMainWindow;
bool alwaysOnTop; bool alwaysOnTop;

View file

@ -169,6 +169,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.cbAutostart->setChecked( p.autoStart ); ui.cbAutostart->setChecked( p.autoStart );
ui.doubleClickTranslates->setChecked( p.doubleClickTranslates ); ui.doubleClickTranslates->setChecked( p.doubleClickTranslates );
ui.selectBySingleClick->setChecked( p.selectWordBySingleClick); ui.selectBySingleClick->setChecked( p.selectWordBySingleClick);
ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle );
ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow ); ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow );
ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey ); ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey );
@ -379,6 +380,7 @@ Config::Preferences Preferences::getPreferences()
p.autoStart = ui.cbAutostart->isChecked(); p.autoStart = ui.cbAutostart->isChecked();
p.doubleClickTranslates = ui.doubleClickTranslates->isChecked(); p.doubleClickTranslates = ui.doubleClickTranslates->isChecked();
p.selectWordBySingleClick = ui.selectBySingleClick->isChecked(); p.selectWordBySingleClick = ui.selectBySingleClick->isChecked();
p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked();
p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked(); p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked();
p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked(); p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked();

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>636</width> <width>721</width>
<height>447</height> <height>506</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -24,7 +24,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>6</number> <number>0</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -47,129 +47,8 @@
<string>&amp;Interface</string> <string>&amp;Interface</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1"> <item row="9" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2"> <spacer name="verticalSpacer">
<property name="title">
<string>Startup</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="cbAutostart">
<property name="toolTip">
<string>Automatically starts GoldenDict after operation system bootup.</string>
</property>
<property name="text">
<string>Start with system</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="addonStylesLabel">
<property name="text">
<string>Add-on style:</string>
</property>
</widget>
</item>
<item>
<widget class="StylesComboBox" name="addonStyles"/>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="enableTrayIcon">
<property name="toolTip">
<string>When enabled, an icon appears in the system tray area which can be used
to open main window and perform other tasks.</string>
</property>
<property name="title">
<string>Enable system tray icon</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="startToTray">
<property name="toolTip">
<string>With this on, the application starts directly to system tray without showing
its main window.</string>
</property>
<property name="text">
<string>Start to system tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeToTray">
<property name="toolTip">
<string>With this on, an attempt to close main window would hide it instead of closing
the application.</string>
</property>
<property name="text">
<string>Close to system tray</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="doubleClickTranslates">
<property name="text">
<string>Double-click translates the word clicked</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="escKeyHidesMainWindow">
<property name="toolTip">
<string>Normally, pressing ESC key moves focus to the translation line.
With this on however, it will hide the main window.</string>
</property>
<property name="text">
<string>ESC key hides main window</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="selectBySingleClick">
<property name="toolTip">
<string>Turn this option on if you want to select words by single mouse click</string>
</property>
<property name="text">
<string>Select word by single click</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<spacer name="verticalSpacer_8">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -181,7 +60,14 @@ With this on however, it will hide the main window.</string>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="2" column="0">
<widget class="QCheckBox" name="doubleClickTranslates">
<property name="text">
<string>Double-click translates the word clicked</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Tabbed browsing</string> <string>Tabbed browsing</string>
@ -231,7 +117,17 @@ be the last ones.</string>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="3" column="0">
<widget class="QCheckBox" name="selectBySingleClick">
<property name="toolTip">
<string>Turn this option on if you want to select words by single mouse click</string>
</property>
<property name="text">
<string>Select word by single click</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
@ -307,20 +203,127 @@ be the last ones.</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="10" column="0" colspan="2"> <item row="1" column="0">
<spacer name="verticalSpacer"> <widget class="QGroupBox" name="enableTrayIcon">
<property name="toolTip">
<string>When enabled, an icon appears in the system tray area which can be used
to open main window and perform other tasks.</string>
</property>
<property name="title">
<string>Enable system tray icon</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="startToTray">
<property name="toolTip">
<string>With this on, the application starts directly to system tray without showing
its main window.</string>
</property>
<property name="text">
<string>Start to system tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeToTray">
<property name="toolTip">
<string>With this on, an attempt to close main window would hide it instead of closing
the application.</string>
</property>
<property name="text">
<string>Close to system tray</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="addonStylesLabel">
<property name="text">
<string>Add-on style:</string>
</property>
</widget>
</item>
<item>
<widget class="StylesComboBox" name="addonStyles"/>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>40</width>
<height>40</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QCheckBox" name="autoScrollToTargetArticle">
<property name="toolTip">
<string>Normally, clicking on a link, double-clicking on a word or looking up
selection in an article loads the translation and almost immediately
scrolls to the article from the same dictionary. With this option off,
however, the article from the topmost dictionary is shown.</string>
</property>
<property name="text">
<string>Automatically scroll to target article</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Startup</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="cbAutostart">
<property name="toolTip">
<string>Automatically starts GoldenDict after operation system bootup.</string>
</property>
<property name="text">
<string>Start with system</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="escKeyHidesMainWindow">
<property name="toolTip">
<string>Normally, pressing ESC key moves focus to the translation line.
With this on however, it will hide the main window.</string>
</property>
<property name="text">
<string>ESC key hides main window</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_13"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<item> <item>
<widget class="QLabel" name="maxDictsInContextMenuLabel"> <widget class="QLabel" name="maxDictsInContextMenuLabel">
@ -380,19 +383,6 @@ be the last ones.</string>
<string>&amp;Scan Popup</string> <string>&amp;Scan Popup</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<spacer name="verticalSpacer_16">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QGroupBox" name="enableScanPopup"> <widget class="QGroupBox" name="enableScanPopup">
<property name="toolTip"> <property name="toolTip">
@ -726,19 +716,6 @@ seconds, which is specified here.</string>
<string>Hotkeys</string> <string>Hotkeys</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_12"> <layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<spacer name="verticalSpacer_11">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>19</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QCheckBox" name="enableMainWindowHotkey"> <widget class="QCheckBox" name="enableMainWindowHotkey">
<property name="text"> <property name="text">
@ -871,19 +848,6 @@ p, li { white-space: pre-wrap; }
<string>&amp;Audio</string> <string>&amp;Audio</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
@ -1259,19 +1223,6 @@ download page.</string>
<string>Full-text search</string> <string>Full-text search</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_19"> <layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QGroupBox" name="ftsGroupBox"> <widget class="QGroupBox" name="ftsGroupBox">
<property name="title"> <property name="title">