From 20b435053f9d2829518cdc5f0294a471e4a50494 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Sat, 19 Nov 2022 11:35:25 -0500 Subject: [PATCH] X11: Add two Preferences to optional tracking clipboard or selection tracking --- config.cc | 14 ++++++++++++++ config.hh | 2 ++ preferences.cc | 8 +++++++- preferences.ui | 23 +++++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/config.cc b/config.cc index 9a3d3689..fb4fc1b6 100644 --- a/config.cc +++ b/config.cc @@ -237,6 +237,10 @@ Preferences::Preferences(): ignoreDiacritics( false ), ignorePunctuation( false ), #ifdef HAVE_X11 + // Enable both Clipboard and Selection by default so that X users can enjoy full + // power and disable optionally. + trackClipboardScan ( true ), + trackSelectionScan ( true ), showScanFlag( false ), #endif pronounceOnLoadMain( false ), @@ -895,6 +899,8 @@ Class load() if( !preferences.namedItem( "ignorePunctuation" ).isNull() ) c.preferences.ignorePunctuation = ( preferences.namedItem( "ignorePunctuation" ).toElement().text() == "1" ); #ifdef HAVE_X11 + c.preferences.trackClipboardScan= ( preferences.namedItem( "trackClipboardScan" ).toElement().text() == "1" ); + c.preferences.trackSelectionScan= ( preferences.namedItem( "trackSelectionScan" ).toElement().text() == "1" ); c.preferences.showScanFlag= ( preferences.namedItem( "showScanFlag" ).toElement().text() == "1" ); #endif @@ -1775,6 +1781,14 @@ void save( Class const & c ) preferences.appendChild( opt ); #ifdef HAVE_X11 + opt = dd.createElement( "trackClipboardScan" ); + opt.appendChild( dd.createTextNode( c.preferences.trackClipboardScan ? "1":"0" ) ); + preferences.appendChild( opt ); + + opt = dd.createElement( "trackSelectionScan" ); + opt.appendChild( dd.createTextNode( c.preferences.trackSelectionScan ? "1":"0" ) ); + preferences.appendChild( opt ); + opt = dd.createElement( "showScanFlag" ); opt.appendChild( dd.createTextNode( c.preferences.showScanFlag? "1":"0" ) ); preferences.appendChild( opt ); diff --git a/config.hh b/config.hh index 2d7554d1..2a1d0b3d 100644 --- a/config.hh +++ b/config.hh @@ -329,6 +329,8 @@ struct Preferences bool ignoreDiacritics; bool ignorePunctuation; #ifdef HAVE_X11 + bool trackClipboardScan; + bool trackSelectionScan; bool showScanFlag; #endif diff --git a/preferences.cc b/preferences.cc index fc4d7552..625785f6 100644 --- a/preferences.cc +++ b/preferences.cc @@ -251,8 +251,12 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): //Platform-specific options #ifdef HAVE_X11 - ui.showScanFlag->setChecked( p.showScanFlag); + ui.enableX11SelectionTrack->setChecked(p.trackSelectionScan); + ui.enableClipboardTrack ->setChecked(p.trackClipboardScan); + ui.showScanFlag->setChecked(p.showScanFlag); #else + ui.enableX11SelectionTrack->hide(); + ui.enableClipboardTrack->hide(); ui.showScanFlag->hide(); ui.ignoreOwnClipboardChanges->hide(); #endif @@ -422,6 +426,8 @@ Config::Preferences Preferences::getPreferences() p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked(); p.scanToMainWindow = ui.scanToMainWindow->isChecked(); #ifdef HAVE_X11 + p.trackSelectionScan = ui.enableX11SelectionTrack ->isChecked(); + p.trackClipboardScan = ui.enableClipboardTrack ->isChecked(); p.showScanFlag= ui.showScanFlag->isChecked(); #endif diff --git a/preferences.ui b/preferences.ui index e5e54f09..771da91b 100644 --- a/preferences.ui +++ b/preferences.ui @@ -711,6 +711,29 @@ seconds, which is specified here. + + + + Track Selection change + + + true + + + false + + + + + + + Track clipboard changes when Scanning is enabled. Noice! You should always enable this unless you are on Linux. + + + Track Clipboard change + + +