mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-17 23:04:06 +00:00
Merge pull request #818 from shenlebantongying/expose_timer
feat: expose linux's selection clipboard delay timer to user
This commit is contained in:
commit
e0dba5ac3b
|
@ -245,6 +245,7 @@ Preferences::Preferences():
|
||||||
trackClipboardScan ( true ),
|
trackClipboardScan ( true ),
|
||||||
trackSelectionScan ( true ),
|
trackSelectionScan ( true ),
|
||||||
showScanFlag( false ),
|
showScanFlag( false ),
|
||||||
|
selectionChangeDelayTimer( 500 ),
|
||||||
#endif
|
#endif
|
||||||
pronounceOnLoadMain( false ),
|
pronounceOnLoadMain( false ),
|
||||||
pronounceOnLoadPopup( false ),
|
pronounceOnLoadPopup( false ),
|
||||||
|
@ -931,6 +932,8 @@ Class load()
|
||||||
c.preferences.trackClipboardScan= ( preferences.namedItem( "trackClipboardScan" ).toElement().text() == "1" );
|
c.preferences.trackClipboardScan= ( preferences.namedItem( "trackClipboardScan" ).toElement().text() == "1" );
|
||||||
c.preferences.trackSelectionScan= ( preferences.namedItem( "trackSelectionScan" ).toElement().text() == "1" );
|
c.preferences.trackSelectionScan= ( preferences.namedItem( "trackSelectionScan" ).toElement().text() == "1" );
|
||||||
c.preferences.showScanFlag= ( preferences.namedItem( "showScanFlag" ).toElement().text() == "1" );
|
c.preferences.showScanFlag= ( preferences.namedItem( "showScanFlag" ).toElement().text() == "1" );
|
||||||
|
c.preferences.selectionChangeDelayTimer =
|
||||||
|
preferences.namedItem( "selectionChangeDelayTimer" ).toElement().text().toInt();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
c.preferences.pronounceOnLoadMain = ( preferences.namedItem( "pronounceOnLoadMain" ).toElement().text() == "1" );
|
c.preferences.pronounceOnLoadMain = ( preferences.namedItem( "pronounceOnLoadMain" ).toElement().text() == "1" );
|
||||||
|
@ -1842,6 +1845,11 @@ void save( Class const & c )
|
||||||
opt = dd.createElement( "showScanFlag" );
|
opt = dd.createElement( "showScanFlag" );
|
||||||
opt.appendChild( dd.createTextNode( c.preferences.showScanFlag? "1":"0" ) );
|
opt.appendChild( dd.createTextNode( c.preferences.showScanFlag? "1":"0" ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "selectionChangeDelayTimer" );
|
||||||
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.selectionChangeDelayTimer ) ) );
|
||||||
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
opt = dd.createElement( "pronounceOnLoadMain" );
|
opt = dd.createElement( "pronounceOnLoadMain" );
|
||||||
|
|
|
@ -296,6 +296,7 @@ struct Preferences
|
||||||
bool trackClipboardScan;
|
bool trackClipboardScan;
|
||||||
bool trackSelectionScan;
|
bool trackSelectionScan;
|
||||||
bool showScanFlag;
|
bool showScanFlag;
|
||||||
|
int selectionChangeDelayTimer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Whether the word should be pronounced on page load, in main window/popup
|
// Whether the word should be pronounced on page load, in main window/popup
|
||||||
|
|
|
@ -228,11 +228,13 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
||||||
ui.enableX11SelectionTrack->setChecked(p.trackSelectionScan);
|
ui.enableX11SelectionTrack->setChecked(p.trackSelectionScan);
|
||||||
ui.enableClipboardTrack ->setChecked(p.trackClipboardScan);
|
ui.enableClipboardTrack ->setChecked(p.trackClipboardScan);
|
||||||
ui.showScanFlag->setChecked(p.showScanFlag);
|
ui.showScanFlag->setChecked(p.showScanFlag);
|
||||||
|
ui.delayTimer->setValue( p.selectionChangeDelayTimer );
|
||||||
#else
|
#else
|
||||||
ui.enableX11SelectionTrack->hide();
|
ui.enableX11SelectionTrack->hide();
|
||||||
ui.enableClipboardTrack->hide();
|
ui.enableClipboardTrack->hide();
|
||||||
ui.showScanFlag->hide();
|
ui.showScanFlag->hide();
|
||||||
ui.ignoreOwnClipboardChanges->hide();
|
ui.ignoreOwnClipboardChanges->hide();
|
||||||
|
ui.delayTimer->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
|
@ -409,6 +411,7 @@ Config::Preferences Preferences::getPreferences()
|
||||||
p.trackSelectionScan = ui.enableX11SelectionTrack ->isChecked();
|
p.trackSelectionScan = ui.enableX11SelectionTrack ->isChecked();
|
||||||
p.trackClipboardScan = ui.enableClipboardTrack ->isChecked();
|
p.trackClipboardScan = ui.enableClipboardTrack ->isChecked();
|
||||||
p.showScanFlag= ui.showScanFlag->isChecked();
|
p.showScanFlag= ui.showScanFlag->isChecked();
|
||||||
|
p.selectionChangeDelayTimer = ui.delayTimer->value();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p.storeHistory = ui.storeHistory->isChecked();
|
p.storeHistory = ui.storeHistory->isChecked();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>787</width>
|
<width>787</width>
|
||||||
<height>629</height>
|
<height>730</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -620,6 +620,35 @@ in the pressed state when the word selection changes.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="delayTimerLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Delay time</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="delayTimer">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> ms</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>10000</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -273,9 +273,10 @@ ScanPopup::ScanPopup( QWidget * parent,
|
||||||
translateWordFromSelection();
|
translateWordFromSelection();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Use delay show to prevent multiple popups while selection in progress
|
// Use delay show to prevent popup from showing up while selection is still in progress
|
||||||
|
// Only certain software has this problem (e.g. Chrome)
|
||||||
selectionDelayTimer.setSingleShot( true );
|
selectionDelayTimer.setSingleShot( true );
|
||||||
selectionDelayTimer.setInterval( 800 );
|
selectionDelayTimer.setInterval( cfg.preferences.selectionChangeDelayTimer );
|
||||||
|
|
||||||
connect( &selectionDelayTimer, &QTimer::timeout, this, &ScanPopup::translateWordFromSelection );
|
connect( &selectionDelayTimer, &QTimer::timeout, this, &ScanPopup::translateWordFromSelection );
|
||||||
#endif
|
#endif
|
||||||
|
@ -307,6 +308,9 @@ void ScanPopup::refresh() {
|
||||||
|
|
||||||
connect( ui.groupList, &GroupComboBox::currentIndexChanged,
|
connect( ui.groupList, &GroupComboBox::currentIndexChanged,
|
||||||
this, &ScanPopup::currentGroupChanged );
|
this, &ScanPopup::currentGroupChanged );
|
||||||
|
#ifdef HAVE_X11
|
||||||
|
selectionDelayTimer.setInterval( cfg.preferences.selectionChangeDelayTimer );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue