mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Linux-specific: Small delay for show of popup window when selection changed (by Sun Wang) (issue #854)
This commit is contained in:
parent
8fa93269a8
commit
58e41fe3ce
23
scanpopup.cc
23
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 ) );
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue