diff --git a/scanpopup.cc b/scanpopup.cc index 7523d854..5cdf1a73 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -282,6 +282,12 @@ ScanPopup::ScanPopup( QWidget * parent, connect( scanFlag, SIGNAL( showScanPopup() ), this, SLOT( showEngagePopup() ) ); + + delayTimer.setSingleShot( true ); + delayTimer.setInterval( 200 ); + + connect( &delayTimer, SIGNAL( timeout() ), + this, SLOT( delayShow() ) ); #endif } @@ -375,6 +381,14 @@ void ScanPopup::translateWord( QString const & word ) ); } +#ifdef HAVE_X11 +void ScanPopup::delayShow() +{ + QString subtype = "plain"; + handleInputWord( QApplication::clipboard()->text( subtype, QClipboard::Selection ) ); +} +#endif + void ScanPopup::clipboardChanged( QClipboard::Mode m ) { if ( !isScanningEnabled ) @@ -382,6 +396,15 @@ void ScanPopup::clipboardChanged( QClipboard::Mode m ) GD_DPRINTF( "clipboard changed\n" ); +#ifdef HAVE_X11 + if( m == QClipboard::Selection ) + { + // Use delay show to prevent multiple popups while selection in progress + delayTimer.start(); + return; + } +#endif + QString subtype = "plain"; handleInputWord( QApplication::clipboard()->text( subtype, m ) ); diff --git a/scanpopup.hh b/scanpopup.hh index b26b0c48..b9e74ff8 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -133,6 +133,7 @@ private: #ifdef HAVE_X11 ScanFlag * scanFlag; + QTimer delayTimer; #endif bool mouseEnteredOnce; @@ -212,6 +213,10 @@ private slots: void focusTranslateLine(); void typingEvent( QString const & ); + +#ifdef HAVE_X11 + void delayShow(); +#endif }; #endif