mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
parent
df91a5b7bd
commit
ea21eba386
121
preferences.cc
121
preferences.cc
|
@ -19,9 +19,32 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
|||
connect( ui.enableScanPopup, SIGNAL( toggled( bool ) ),
|
||||
this, SLOT( enableScanPopupToggled( bool ) ) );
|
||||
|
||||
connect( ui.enableScanPopupModifiers, SIGNAL( toggled( bool ) ),
|
||||
this, SLOT( enableScanPopupModifiersToggled( bool ) ) );
|
||||
|
||||
connect( ui.showScanFlag, SIGNAL( toggled( bool ) ),
|
||||
this, SLOT( showScanFlagToggled( bool ) ) );
|
||||
|
||||
connect( ui.altKey, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( wholeAltClicked( bool ) ) );
|
||||
connect( ui.ctrlKey, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( wholeCtrlClicked( bool ) ) );
|
||||
connect( ui.shiftKey, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( wholeShiftClicked( bool ) ) );
|
||||
|
||||
connect( ui.leftAlt, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( sideAltClicked( bool ) ) );
|
||||
connect( ui.rightAlt, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( sideAltClicked( bool ) ) );
|
||||
connect( ui.leftCtrl, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( sideCtrlClicked( bool ) ) );
|
||||
connect( ui.rightCtrl, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( sideCtrlClicked( bool ) ) );
|
||||
connect( ui.leftShift, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( sideShiftClicked( bool ) ) );
|
||||
connect( ui.rightShift, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( sideShiftClicked( bool ) ) );
|
||||
|
||||
connect( ui.buttonBox, SIGNAL( helpRequested() ),
|
||||
this, SLOT( helpRequested() ) );
|
||||
|
||||
|
@ -169,7 +192,21 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
|||
|
||||
ui.enableScanPopup->setChecked( p.enableScanPopup );
|
||||
ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn );
|
||||
ui.enableScanPopupModifiers->setChecked( p.enableScanPopupModifiers );
|
||||
|
||||
ui.altKey->setChecked( p.scanPopupModifiers & KeyboardState::Alt );
|
||||
ui.ctrlKey->setChecked( p.scanPopupModifiers & KeyboardState::Ctrl );
|
||||
ui.shiftKey->setChecked( p.scanPopupModifiers & KeyboardState::Shift );
|
||||
ui.winKey->setChecked( p.scanPopupModifiers & KeyboardState::Win );
|
||||
ui.leftAlt->setChecked( p.scanPopupModifiers & KeyboardState::LeftAlt );
|
||||
ui.rightAlt->setChecked( p.scanPopupModifiers & KeyboardState::RightAlt );
|
||||
ui.leftCtrl->setChecked( p.scanPopupModifiers & KeyboardState::LeftCtrl );
|
||||
ui.rightCtrl->setChecked( p.scanPopupModifiers & KeyboardState::RightCtrl );
|
||||
ui.leftShift->setChecked( p.scanPopupModifiers & KeyboardState::LeftShift );
|
||||
ui.rightShift->setChecked( p.scanPopupModifiers & KeyboardState::RightShift );
|
||||
|
||||
ui.scanPopupAltMode->setChecked( p.scanPopupAltMode );
|
||||
ui.scanPopupAltModeSecs->setValue( p.scanPopupAltModeSecs );
|
||||
ui.ignoreOwnClipboardChanges->setChecked( p.ignoreOwnClipboardChanges );
|
||||
ui.scanToMainWindow->setChecked( p.scanToMainWindow );
|
||||
|
||||
|
@ -199,6 +236,22 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
|||
|
||||
// Different platforms have different keys available
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
ui.winKey->hide();
|
||||
#else
|
||||
ui.leftAlt->hide();
|
||||
ui.rightAlt->hide();
|
||||
ui.leftCtrl->hide();
|
||||
ui.rightCtrl->hide();
|
||||
ui.leftShift->hide();
|
||||
ui.rightShift->hide();
|
||||
#ifdef Q_OS_MAC
|
||||
ui.altKey->setText( "Opt" );
|
||||
ui.winKey->setText( "Ctrl" );
|
||||
ui.ctrlKey->setText( "Cmd" );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Platform-specific options
|
||||
|
||||
#ifdef HAVE_X11
|
||||
|
@ -356,7 +409,21 @@ Config::Preferences Preferences::getPreferences()
|
|||
|
||||
p.enableScanPopup = ui.enableScanPopup->isChecked();
|
||||
p.startWithScanPopupOn = ui.startWithScanPopupOn->isChecked();
|
||||
p.enableScanPopupModifiers = ui.enableScanPopupModifiers->isChecked();
|
||||
|
||||
p.scanPopupModifiers += ui.altKey->isChecked() ? KeyboardState::Alt : 0;
|
||||
p.scanPopupModifiers += ui.ctrlKey->isChecked() ? KeyboardState::Ctrl: 0;
|
||||
p.scanPopupModifiers += ui.shiftKey->isChecked() ? KeyboardState::Shift: 0;
|
||||
p.scanPopupModifiers += ui.winKey->isChecked() ? KeyboardState::Win: 0;
|
||||
p.scanPopupModifiers += ui.leftAlt->isChecked() ? KeyboardState::LeftAlt: 0;
|
||||
p.scanPopupModifiers += ui.rightAlt->isChecked() ? KeyboardState::RightAlt: 0;
|
||||
p.scanPopupModifiers += ui.leftCtrl->isChecked() ? KeyboardState::LeftCtrl: 0;
|
||||
p.scanPopupModifiers += ui.rightCtrl->isChecked() ? KeyboardState::RightCtrl: 0;
|
||||
p.scanPopupModifiers += ui.leftShift->isChecked() ? KeyboardState::LeftShift: 0;
|
||||
p.scanPopupModifiers += ui.rightShift->isChecked() ? KeyboardState::RightShift: 0;
|
||||
|
||||
p.scanPopupAltMode = ui.scanPopupAltMode->isChecked();
|
||||
p.scanPopupAltModeSecs = ui.scanPopupAltModeSecs->value();
|
||||
p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked();
|
||||
p.scanToMainWindow = ui.scanToMainWindow->isChecked();
|
||||
#ifdef HAVE_X11
|
||||
|
@ -507,7 +574,7 @@ Config::Preferences Preferences::getPreferences()
|
|||
|
||||
void Preferences::enableScanPopupToggled( bool b )
|
||||
{
|
||||
ui.scanPopupModifiers->setEnabled( b );
|
||||
ui.scanPopupModifiers->setEnabled( b && ui.enableScanPopupModifiers->isChecked() );
|
||||
}
|
||||
|
||||
void Preferences::enableScanPopupModifiersToggled( bool b )
|
||||
|
@ -517,6 +584,58 @@ void Preferences::enableScanPopupModifiersToggled( bool b )
|
|||
ui.showScanFlag->setChecked( false );
|
||||
}
|
||||
|
||||
void Preferences::showScanFlagToggled( bool b )
|
||||
{
|
||||
if( b )
|
||||
ui.enableScanPopupModifiers->setChecked( false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Preferences::wholeAltClicked( bool b )
|
||||
{
|
||||
if ( b )
|
||||
{
|
||||
ui.leftAlt->setChecked( false );
|
||||
ui.rightAlt->setChecked( false );
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::wholeCtrlClicked( bool b )
|
||||
{
|
||||
if ( b )
|
||||
{
|
||||
ui.leftCtrl->setChecked( false );
|
||||
ui.rightCtrl->setChecked( false );
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::wholeShiftClicked( bool b )
|
||||
{
|
||||
if ( b )
|
||||
{
|
||||
ui.leftShift->setChecked( false );
|
||||
ui.rightShift->setChecked( false );
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::sideAltClicked( bool )
|
||||
{
|
||||
if ( ui.leftAlt->isChecked() || ui.rightAlt->isChecked() )
|
||||
ui.altKey->setChecked( false );
|
||||
}
|
||||
|
||||
void Preferences::sideCtrlClicked( bool )
|
||||
{
|
||||
if ( ui.leftCtrl->isChecked() || ui.rightCtrl->isChecked() )
|
||||
ui.ctrlKey->setChecked( false );
|
||||
}
|
||||
|
||||
void Preferences::sideShiftClicked( bool )
|
||||
{
|
||||
if ( ui.leftShift->isChecked() || ui.rightShift->isChecked() )
|
||||
ui.shiftKey->setChecked( false );
|
||||
}
|
||||
void Preferences::on_enableMainWindowHotkey_toggled( bool checked )
|
||||
{
|
||||
ui.mainWindowHotkey->setEnabled( checked );
|
||||
|
|
|
@ -35,6 +35,15 @@ private slots:
|
|||
|
||||
void enableScanPopupToggled( bool );
|
||||
void enableScanPopupModifiersToggled( bool );
|
||||
void showScanFlagToggled( bool b );
|
||||
|
||||
void wholeAltClicked( bool );
|
||||
void wholeCtrlClicked( bool );
|
||||
void wholeShiftClicked( bool );
|
||||
|
||||
void sideAltClicked( bool );
|
||||
void sideCtrlClicked( bool );
|
||||
void sideShiftClicked( bool );
|
||||
|
||||
void on_enableMainWindowHotkey_toggled( bool checked );
|
||||
void on_enableClipboardHotkey_toggled( bool checked );
|
||||
|
|
233
preferences.ui
233
preferences.ui
|
@ -452,6 +452,17 @@ the program would always start with the scan popup active.</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enableScanPopupModifiers">
|
||||
<property name="toolTip">
|
||||
<string>With this enabled, the popup would only show up if all chosen keys are
|
||||
in the pressed state when the word selection changes.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Only show popup when all selected keys are kept pressed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="scanPopupModifiers">
|
||||
<property name="frameShape">
|
||||
|
@ -476,9 +487,218 @@ the program would always start with the scan popup active.</string>
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="leftCtrl">
|
||||
<property name="toolTip">
|
||||
<string>Left Ctrl only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Left Ctrl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="rightShift">
|
||||
<property name="toolTip">
|
||||
<string>Right Shift only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Right Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="altKey">
|
||||
<property name="toolTip">
|
||||
<string>Alt key</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="ctrlKey">
|
||||
<property name="toolTip">
|
||||
<string>Ctrl key</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ctrl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="leftAlt">
|
||||
<property name="toolTip">
|
||||
<string>Left Alt only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Left Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="shiftKey">
|
||||
<property name="toolTip">
|
||||
<string>Shift key</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="rightAlt">
|
||||
<property name="toolTip">
|
||||
<string>Right Alt only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Right Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="rightCtrl">
|
||||
<property name="toolTip">
|
||||
<string>Right Ctrl only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Right Ctrl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="leftShift">
|
||||
<property name="toolTip">
|
||||
<string>Left Shift only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Left Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QCheckBox" name="winKey">
|
||||
<property name="toolTip">
|
||||
<string>Windows key or Meta key</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Win/Meta</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="scanPopupAltMode">
|
||||
<property name="toolTip">
|
||||
<string>Normally, in order to activate a popup you have to
|
||||
maintain the chosen keys pressed while you select
|
||||
a word. With this enabled, the chosen keys may also
|
||||
be pressed shortly after the selection is done.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Keys may also be pressed afterwards, within</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="scanPopupAltModeSecs">
|
||||
<property name="toolTip">
|
||||
<string>To avoid false positives, the keys are only monitored
|
||||
after the selection's done for a limited amount of
|
||||
seconds, which is specified here.</string>
|
||||
</property>
|
||||
<property name="wrapping">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>99</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>secs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<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>
|
||||
<widget class="QCheckBox" name="showScanFlag">
|
||||
<property name="toolTip">
|
||||
|
@ -1625,6 +1845,19 @@ from Stardict, Babylon and GLS dictionaries</string>
|
|||
<tabstop>cbAutostart</tabstop>
|
||||
<tabstop>interfaceLanguage</tabstop>
|
||||
<tabstop>startWithScanPopupOn</tabstop>
|
||||
<tabstop>enableScanPopupModifiers</tabstop>
|
||||
<tabstop>leftCtrl</tabstop>
|
||||
<tabstop>rightShift</tabstop>
|
||||
<tabstop>altKey</tabstop>
|
||||
<tabstop>ctrlKey</tabstop>
|
||||
<tabstop>leftAlt</tabstop>
|
||||
<tabstop>shiftKey</tabstop>
|
||||
<tabstop>rightAlt</tabstop>
|
||||
<tabstop>rightCtrl</tabstop>
|
||||
<tabstop>leftShift</tabstop>
|
||||
<tabstop>winKey</tabstop>
|
||||
<tabstop>scanPopupAltMode</tabstop>
|
||||
<tabstop>scanPopupAltModeSecs</tabstop>
|
||||
<tabstop>useProxyServer</tabstop>
|
||||
<tabstop>proxyType</tabstop>
|
||||
<tabstop>proxyHost</tabstop>
|
||||
|
|
Loading…
Reference in a new issue