From b3b740854affc7138935ed872be9cee780b052ff Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Sat, 19 Nov 2022 10:30:31 -0500 Subject: [PATCH] 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 --- config.cc | 14 -------------- config.hh | 3 --- mainwindow.cc | 23 +++++------------------ mainwindow.hh | 3 --- scanpopup.cc | 5 ++--- 5 files changed, 7 insertions(+), 41 deletions(-) diff --git a/config.cc b/config.cc index a17789f9..9a3d3689 100644 --- a/config.cc +++ b/config.cc @@ -263,9 +263,6 @@ Preferences::Preferences(): , limitInputPhraseLength( false ) , inputPhraseLengthLimit( 1000 ) , maxDictionaryRefsInContextMenu ( 20 ) -#ifndef Q_WS_X11 -, trackClipboardChanges( false ) -#endif , synonymSearchEnabled( true ) { } @@ -1000,11 +997,6 @@ Class load() if ( !preferences.namedItem( "maxDictionaryRefsInContextMenu" ).isNull() ) 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() ) 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 ) ) ); 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.appendChild( dd.createTextNode( c.preferences.synonymSearchEnabled ? "1" : "0" ) ); preferences.appendChild( opt ); diff --git a/config.hh b/config.hh index 5bd498ab..2d7554d1 100644 --- a/config.hh +++ b/config.hh @@ -369,9 +369,6 @@ struct Preferences InputPhrase sanitizeInputPhrase( QString const & inputPhrase ) const; unsigned short maxDictionaryRefsInContextMenu; -#ifndef Q_WS_X11 - bool trackClipboardChanges; -#endif bool synonymSearchEnabled; diff --git a/mainwindow.cc b/mainwindow.cc index b8875f24..e7cf0abc 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -406,12 +406,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ), SIGNAL( triggered() ), this, SLOT( showMainWindow() ) ); 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(); connect( trayIconMenu.addAction( tr( "&Quit" ) ), SIGNAL( triggered() ), this, SLOT( quitApp() ) ); @@ -918,8 +913,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ): void MainWindow::clipboardChange( ) { - qDebug() << "clipboard change ," << cfg.preferences.trackClipboardChanges << scanPopup.get(); - if( scanPopup && cfg.preferences.trackClipboardChanges ) + qDebug() << "clipboard change ," << scanPopup.get(); + if( scanPopup ) { scanPopup->translateWordFromClipboard(); } @@ -1485,7 +1480,7 @@ void MainWindow::makeScanPopup() scanPopup.reset(); // Later this will be remove, we want singluar way to toggling ScanPopup - if ( !cfg.preferences.enableClipboardHotkey && !cfg.preferences.trackClipboardChanges ) + if ( !cfg.preferences.enableClipboardHotkey ) return; scanPopup = new ScanPopup( 0, cfg, articleNetMgr, audioPlayerFactory.player(), @@ -2181,9 +2176,7 @@ void MainWindow::editPreferences() p.hideMenubar = cfg.preferences.hideMenubar; p.searchInDock = cfg.preferences.searchInDock; p.alwaysOnTop = cfg.preferences.alwaysOnTop; -#ifndef Q_WS_X11 - p.trackClipboardChanges = cfg.preferences.trackClipboardChanges; -#endif + p.proxyServer.systemProxyUser = cfg.preferences.proxyServer.systemProxyUser; p.proxyServer.systemProxyPassword = cfg.preferences.proxyServer.systemProxyPassword; @@ -3189,12 +3182,6 @@ void MainWindow::showMainWindow() toggleMainWindow( true ); } -void MainWindow::trackingClipboard( bool on ) -{ - cfg.preferences.trackClipboardChanges = on; - makeScanPopup(); -} - void MainWindow::visitHomepage() { QDesktopServices::openUrl( QUrl( "http://goldendict.org/" ) ); diff --git a/mainwindow.hh b/mainwindow.hh index dfb991a2..dfe553a3 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -117,7 +117,6 @@ private: QToolBar * navToolbar; MainStatusBar * mainStatusBar; QAction * navBack, * navForward, * navPronounce, * enableScanPopupAction; - QAction * actTrackingClipboard; QAction * beforeOptionsSeparator; QAction * zoomIn, * zoomOut, * zoomBase; QAction * wordsZoomIn, * wordsZoomOut, * wordsZoomBase; @@ -416,8 +415,6 @@ private slots: void showMainWindow(); - void trackingClipboard(bool); - void visitHomepage(); void visitForum(); void openConfigFolder(); diff --git a/scanpopup.cc b/scanpopup.cc index 81fcb627..25b73664 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -515,9 +515,8 @@ void ScanPopup::delayShow() void ScanPopup::clipboardChanged( QClipboard::Mode m ) { -// if( !cfg.preferences.trackClipboardChanges ) -// return; - if( !isScanningEnabled && !cfg.preferences.trackClipboardChanges) + + if( !isScanningEnabled ) return; #ifdef HAVE_X11