Unify trackClipboardChanges and enableScanPopupAction

* There is no difference between those two on Windows and MacOS which only support clipboard (Ctrl+C) scanning

* Q_WS_X11 was defined on Qt4, and it causes the super weird trackClipboardChanges to occur on Windows
This commit is contained in:
shenleban tongying 2022-11-19 10:30:31 -05:00
parent aa3778bb64
commit b3b740854a
5 changed files with 7 additions and 41 deletions

View file

@ -263,9 +263,6 @@ Preferences::Preferences():
, limitInputPhraseLength( false ) , limitInputPhraseLength( false )
, inputPhraseLengthLimit( 1000 ) , inputPhraseLengthLimit( 1000 )
, maxDictionaryRefsInContextMenu ( 20 ) , maxDictionaryRefsInContextMenu ( 20 )
#ifndef Q_WS_X11
, trackClipboardChanges( false )
#endif
, synonymSearchEnabled( true ) , synonymSearchEnabled( true )
{ {
} }
@ -1000,11 +997,6 @@ Class load()
if ( !preferences.namedItem( "maxDictionaryRefsInContextMenu" ).isNull() ) if ( !preferences.namedItem( "maxDictionaryRefsInContextMenu" ).isNull() )
c.preferences.maxDictionaryRefsInContextMenu = preferences.namedItem( "maxDictionaryRefsInContextMenu" ).toElement().text().toUShort(); c.preferences.maxDictionaryRefsInContextMenu = preferences.namedItem( "maxDictionaryRefsInContextMenu" ).toElement().text().toUShort();
#ifndef Q_WS_X11
if ( !preferences.namedItem( "trackClipboardChanges" ).isNull() )
c.preferences.trackClipboardChanges = ( preferences.namedItem( "trackClipboardChanges" ).toElement().text() == "1" );
#endif
if ( !preferences.namedItem( "synonymSearchEnabled" ).isNull() ) if ( !preferences.namedItem( "synonymSearchEnabled" ).isNull() )
c.preferences.synonymSearchEnabled = ( preferences.namedItem( "synonymSearchEnabled" ).toElement().text() == "1" ); c.preferences.synonymSearchEnabled = ( preferences.namedItem( "synonymSearchEnabled" ).toElement().text() == "1" );
@ -1955,12 +1947,6 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( QString::number( c.preferences.maxDictionaryRefsInContextMenu ) ) ); opt.appendChild( dd.createTextNode( QString::number( c.preferences.maxDictionaryRefsInContextMenu ) ) );
preferences.appendChild( opt ); preferences.appendChild( opt );
#ifndef Q_WS_X11
opt = dd.createElement( "trackClipboardChanges" );
opt.appendChild( dd.createTextNode( c.preferences.trackClipboardChanges ? "1" : "0" ) );
preferences.appendChild( opt );
#endif
opt = dd.createElement( "synonymSearchEnabled" ); opt = dd.createElement( "synonymSearchEnabled" );
opt.appendChild( dd.createTextNode( c.preferences.synonymSearchEnabled ? "1" : "0" ) ); opt.appendChild( dd.createTextNode( c.preferences.synonymSearchEnabled ? "1" : "0" ) );
preferences.appendChild( opt ); preferences.appendChild( opt );

View file

@ -369,9 +369,6 @@ struct Preferences
InputPhrase sanitizeInputPhrase( QString const & inputPhrase ) const; InputPhrase sanitizeInputPhrase( QString const & inputPhrase ) const;
unsigned short maxDictionaryRefsInContextMenu; unsigned short maxDictionaryRefsInContextMenu;
#ifndef Q_WS_X11
bool trackClipboardChanges;
#endif
bool synonymSearchEnabled; bool synonymSearchEnabled;

View file

@ -406,12 +406,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ), SIGNAL( triggered() ), connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ), SIGNAL( triggered() ),
this, SLOT( showMainWindow() ) ); this, SLOT( showMainWindow() ) );
trayIconMenu.addAction( enableScanPopupAction ); trayIconMenu.addAction( enableScanPopupAction );
actTrackingClipboard = trayIconMenu.addAction( tr( "Tracking Clipboard" ) );
actTrackingClipboard->setCheckable(true);
actTrackingClipboard->setChecked(cfg.preferences.trackClipboardChanges);
// actTrackingClipboard->setVisible( cfg.preferences.enableScanPopup );
connect( actTrackingClipboard , SIGNAL( triggered(bool) ),
this, SLOT( trackingClipboard(bool) ) );
trayIconMenu.addSeparator(); trayIconMenu.addSeparator();
connect( trayIconMenu.addAction( tr( "&Quit" ) ), SIGNAL( triggered() ), connect( trayIconMenu.addAction( tr( "&Quit" ) ), SIGNAL( triggered() ),
this, SLOT( quitApp() ) ); this, SLOT( quitApp() ) );
@ -918,8 +913,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
void MainWindow::clipboardChange( ) void MainWindow::clipboardChange( )
{ {
qDebug() << "clipboard change ," << cfg.preferences.trackClipboardChanges << scanPopup.get(); qDebug() << "clipboard change ," << scanPopup.get();
if( scanPopup && cfg.preferences.trackClipboardChanges ) if( scanPopup )
{ {
scanPopup->translateWordFromClipboard(); scanPopup->translateWordFromClipboard();
} }
@ -1485,7 +1480,7 @@ void MainWindow::makeScanPopup()
scanPopup.reset(); scanPopup.reset();
// Later this will be remove, we want singluar way to toggling ScanPopup // Later this will be remove, we want singluar way to toggling ScanPopup
if ( !cfg.preferences.enableClipboardHotkey && !cfg.preferences.trackClipboardChanges ) if ( !cfg.preferences.enableClipboardHotkey )
return; return;
scanPopup = new ScanPopup( 0, cfg, articleNetMgr, audioPlayerFactory.player(), scanPopup = new ScanPopup( 0, cfg, articleNetMgr, audioPlayerFactory.player(),
@ -2181,9 +2176,7 @@ void MainWindow::editPreferences()
p.hideMenubar = cfg.preferences.hideMenubar; p.hideMenubar = cfg.preferences.hideMenubar;
p.searchInDock = cfg.preferences.searchInDock; p.searchInDock = cfg.preferences.searchInDock;
p.alwaysOnTop = cfg.preferences.alwaysOnTop; p.alwaysOnTop = cfg.preferences.alwaysOnTop;
#ifndef Q_WS_X11
p.trackClipboardChanges = cfg.preferences.trackClipboardChanges;
#endif
p.proxyServer.systemProxyUser = cfg.preferences.proxyServer.systemProxyUser; p.proxyServer.systemProxyUser = cfg.preferences.proxyServer.systemProxyUser;
p.proxyServer.systemProxyPassword = cfg.preferences.proxyServer.systemProxyPassword; p.proxyServer.systemProxyPassword = cfg.preferences.proxyServer.systemProxyPassword;
@ -3189,12 +3182,6 @@ void MainWindow::showMainWindow()
toggleMainWindow( true ); toggleMainWindow( true );
} }
void MainWindow::trackingClipboard( bool on )
{
cfg.preferences.trackClipboardChanges = on;
makeScanPopup();
}
void MainWindow::visitHomepage() void MainWindow::visitHomepage()
{ {
QDesktopServices::openUrl( QUrl( "http://goldendict.org/" ) ); QDesktopServices::openUrl( QUrl( "http://goldendict.org/" ) );

View file

@ -117,7 +117,6 @@ private:
QToolBar * navToolbar; QToolBar * navToolbar;
MainStatusBar * mainStatusBar; MainStatusBar * mainStatusBar;
QAction * navBack, * navForward, * navPronounce, * enableScanPopupAction; QAction * navBack, * navForward, * navPronounce, * enableScanPopupAction;
QAction * actTrackingClipboard;
QAction * beforeOptionsSeparator; QAction * beforeOptionsSeparator;
QAction * zoomIn, * zoomOut, * zoomBase; QAction * zoomIn, * zoomOut, * zoomBase;
QAction * wordsZoomIn, * wordsZoomOut, * wordsZoomBase; QAction * wordsZoomIn, * wordsZoomOut, * wordsZoomBase;
@ -416,8 +415,6 @@ private slots:
void showMainWindow(); void showMainWindow();
void trackingClipboard(bool);
void visitHomepage(); void visitHomepage();
void visitForum(); void visitForum();
void openConfigFolder(); void openConfigFolder();

View file

@ -515,9 +515,8 @@ void ScanPopup::delayShow()
void ScanPopup::clipboardChanged( QClipboard::Mode m ) void ScanPopup::clipboardChanged( QClipboard::Mode m )
{ {
// if( !cfg.preferences.trackClipboardChanges )
// return; if( !isScanningEnabled )
if( !isScanningEnabled && !cfg.preferences.trackClipboardChanges)
return; return;
#ifdef HAVE_X11 #ifdef HAVE_X11