Linux-specific: Small delay for show of popup window when selection changed (by Sun Wang) (issue #854)

This commit is contained in:
Abs62 2017-06-13 18:00:16 +03:00
parent 8fa93269a8
commit 58e41fe3ce
2 changed files with 28 additions and 0 deletions

View file

@ -282,6 +282,12 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( scanFlag, SIGNAL( showScanPopup() ), connect( scanFlag, SIGNAL( showScanPopup() ),
this, SLOT( showEngagePopup() ) ); this, SLOT( showEngagePopup() ) );
delayTimer.setSingleShot( true );
delayTimer.setInterval( 200 );
connect( &delayTimer, SIGNAL( timeout() ),
this, SLOT( delayShow() ) );
#endif #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 ) void ScanPopup::clipboardChanged( QClipboard::Mode m )
{ {
if ( !isScanningEnabled ) if ( !isScanningEnabled )
@ -382,6 +396,15 @@ void ScanPopup::clipboardChanged( QClipboard::Mode m )
GD_DPRINTF( "clipboard changed\n" ); 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"; QString subtype = "plain";
handleInputWord( QApplication::clipboard()->text( subtype, m ) ); handleInputWord( QApplication::clipboard()->text( subtype, m ) );

View file

@ -133,6 +133,7 @@ private:
#ifdef HAVE_X11 #ifdef HAVE_X11
ScanFlag * scanFlag; ScanFlag * scanFlag;
QTimer delayTimer;
#endif #endif
bool mouseEnteredOnce; bool mouseEnteredOnce;
@ -212,6 +213,10 @@ private slots:
void focusTranslateLine(); void focusTranslateLine();
void typingEvent( QString const & ); void typingEvent( QString const & );
#ifdef HAVE_X11
void delayShow();
#endif
}; };
#endif #endif