mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +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() ),
|
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 ) );
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue