diff --git a/mainwindow.cc b/mainwindow.cc index 3968c2d1..8a2973b3 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -915,7 +915,8 @@ void MainWindow::clipboardChange( QClipboard::Mode m) return; } - scanPopup->translateWordFromSelection(); + // Use delay show to prevent multiple popups while selection in progress + scanPopup->selectionDelayTimer.start(); } #else scanPopup ->translateWordFromClipboard(); diff --git a/scanpopup.cc b/scanpopup.cc index 12805fa3..59c7ac1e 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -288,10 +288,11 @@ ScanPopup::ScanPopup( QWidget * parent, translateWordFromSelection(); }); - delayTimer.setSingleShot( true ); - delayTimer.setInterval( 200 ); + // Use delay show to prevent multiple popups while selection in progress + selectionDelayTimer.setSingleShot( true ); + selectionDelayTimer.setInterval( 200 ); - connect( &delayTimer, &QTimer::timeout, this, &ScanPopup::delayShow ); + connect( &selectionDelayTimer, &QTimer::timeout, this, &ScanPopup::translateWordFromSelection ); #endif applyZoomFactor(); @@ -457,14 +458,6 @@ void ScanPopup::translateWord( QString const & word ) ); } -#ifdef HAVE_X11 -void ScanPopup::delayShow() -{ - QString subtype = "plain"; - handleInputWord( QApplication::clipboard()->text( subtype, QClipboard::Selection ) ); -} -#endif - [[deprecated("Favor the mainWindow's clipboardChanged ones")]] void ScanPopup::clipboardChanged( QClipboard::Mode m ) { @@ -487,7 +480,7 @@ void ScanPopup::clipboardChanged( QClipboard::Mode m ) if( m == QClipboard::Selection ) { // Use delay show to prevent multiple popups while selection in progress - delayTimer.start(); + selectionDelayTimer.start(); return; } #endif diff --git a/scanpopup.hh b/scanpopup.hh index 12f1b6fa..23ba454a 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -58,6 +58,8 @@ public: /// Interaction with scan flag window void showScanFlag(); void hideScanFlag(); + + QTimer selectionDelayTimer; #endif signals: @@ -146,7 +148,6 @@ private: #ifdef HAVE_X11 ScanFlag * scanFlag; - QTimer delayTimer; #endif bool mouseEnteredOnce; @@ -235,9 +236,6 @@ private slots: void titleChanged( ArticleView *, QString const & title ); -#ifdef HAVE_X11 - void delayShow(); -#endif }; #endif