mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
fix: add a mini delay for selection clipboard
This commit is contained in:
parent
a28aec3c9f
commit
bdc43650bb
|
@ -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();
|
||||
|
|
17
scanpopup.cc
17
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue