X11: Add two Preferences to optional tracking clipboard or selection tracking

This commit is contained in:
shenleban tongying 2022-11-19 11:35:25 -05:00
parent 9d9ad3ecc9
commit 20b435053f
4 changed files with 46 additions and 1 deletions

View file

@ -237,6 +237,10 @@ Preferences::Preferences():
ignoreDiacritics( false ), ignoreDiacritics( false ),
ignorePunctuation( false ), ignorePunctuation( false ),
#ifdef HAVE_X11 #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 ), showScanFlag( false ),
#endif #endif
pronounceOnLoadMain( false ), pronounceOnLoadMain( false ),
@ -895,6 +899,8 @@ Class load()
if( !preferences.namedItem( "ignorePunctuation" ).isNull() ) if( !preferences.namedItem( "ignorePunctuation" ).isNull() )
c.preferences.ignorePunctuation = ( preferences.namedItem( "ignorePunctuation" ).toElement().text() == "1" ); c.preferences.ignorePunctuation = ( preferences.namedItem( "ignorePunctuation" ).toElement().text() == "1" );
#ifdef HAVE_X11 #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" ); c.preferences.showScanFlag= ( preferences.namedItem( "showScanFlag" ).toElement().text() == "1" );
#endif #endif
@ -1775,6 +1781,14 @@ void save( Class const & c )
preferences.appendChild( opt ); preferences.appendChild( opt );
#ifdef HAVE_X11 #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 = 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 );

View file

@ -329,6 +329,8 @@ struct Preferences
bool ignoreDiacritics; bool ignoreDiacritics;
bool ignorePunctuation; bool ignorePunctuation;
#ifdef HAVE_X11 #ifdef HAVE_X11
bool trackClipboardScan;
bool trackSelectionScan;
bool showScanFlag; bool showScanFlag;
#endif #endif

View file

@ -251,8 +251,12 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
//Platform-specific options //Platform-specific options
#ifdef HAVE_X11 #ifdef HAVE_X11
ui.showScanFlag->setChecked( p.showScanFlag); ui.enableX11SelectionTrack->setChecked(p.trackSelectionScan);
ui.enableClipboardTrack ->setChecked(p.trackClipboardScan);
ui.showScanFlag->setChecked(p.showScanFlag);
#else #else
ui.enableX11SelectionTrack->hide();
ui.enableClipboardTrack->hide();
ui.showScanFlag->hide(); ui.showScanFlag->hide();
ui.ignoreOwnClipboardChanges->hide(); ui.ignoreOwnClipboardChanges->hide();
#endif #endif
@ -422,6 +426,8 @@ Config::Preferences Preferences::getPreferences()
p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked(); p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked();
p.scanToMainWindow = ui.scanToMainWindow->isChecked(); p.scanToMainWindow = ui.scanToMainWindow->isChecked();
#ifdef HAVE_X11 #ifdef HAVE_X11
p.trackSelectionScan = ui.enableX11SelectionTrack ->isChecked();
p.trackClipboardScan = ui.enableClipboardTrack ->isChecked();
p.showScanFlag= ui.showScanFlag->isChecked(); p.showScanFlag= ui.showScanFlag->isChecked();
#endif #endif

View file

@ -711,6 +711,29 @@ seconds, which is specified here.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="enableX11SelectionTrack">
<property name="title">
<string>Track Selection change</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableClipboardTrack">
<property name="toolTip">
<string>Track clipboard changes when Scanning is enabled. Noice! You should always enable this unless you are on Linux.</string>
</property>
<property name="text">
<string>Track Clipboard change</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_6"> <spacer name="verticalSpacer_6">
<property name="orientation"> <property name="orientation">