mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 08:34:08 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scanPopup->translateWordFromSelection();
|
// Use delay show to prevent multiple popups while selection in progress
|
||||||
|
scanPopup->selectionDelayTimer.start();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
scanPopup ->translateWordFromClipboard();
|
scanPopup ->translateWordFromClipboard();
|
||||||
|
|
17
scanpopup.cc
17
scanpopup.cc
|
@ -288,10 +288,11 @@ ScanPopup::ScanPopup( QWidget * parent,
|
||||||
translateWordFromSelection();
|
translateWordFromSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
delayTimer.setSingleShot( true );
|
// Use delay show to prevent multiple popups while selection in progress
|
||||||
delayTimer.setInterval( 200 );
|
selectionDelayTimer.setSingleShot( true );
|
||||||
|
selectionDelayTimer.setInterval( 200 );
|
||||||
|
|
||||||
connect( &delayTimer, &QTimer::timeout, this, &ScanPopup::delayShow );
|
connect( &selectionDelayTimer, &QTimer::timeout, this, &ScanPopup::translateWordFromSelection );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
applyZoomFactor();
|
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")]]
|
[[deprecated("Favor the mainWindow's clipboardChanged ones")]]
|
||||||
void ScanPopup::clipboardChanged( QClipboard::Mode m )
|
void ScanPopup::clipboardChanged( QClipboard::Mode m )
|
||||||
{
|
{
|
||||||
|
@ -487,7 +480,7 @@ void ScanPopup::clipboardChanged( QClipboard::Mode m )
|
||||||
if( m == QClipboard::Selection )
|
if( m == QClipboard::Selection )
|
||||||
{
|
{
|
||||||
// Use delay show to prevent multiple popups while selection in progress
|
// Use delay show to prevent multiple popups while selection in progress
|
||||||
delayTimer.start();
|
selectionDelayTimer.start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -58,6 +58,8 @@ public:
|
||||||
/// Interaction with scan flag window
|
/// Interaction with scan flag window
|
||||||
void showScanFlag();
|
void showScanFlag();
|
||||||
void hideScanFlag();
|
void hideScanFlag();
|
||||||
|
|
||||||
|
QTimer selectionDelayTimer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -146,7 +148,6 @@ private:
|
||||||
|
|
||||||
#ifdef HAVE_X11
|
#ifdef HAVE_X11
|
||||||
ScanFlag * scanFlag;
|
ScanFlag * scanFlag;
|
||||||
QTimer delayTimer;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool mouseEnteredOnce;
|
bool mouseEnteredOnce;
|
||||||
|
@ -235,9 +236,6 @@ private slots:
|
||||||
|
|
||||||
void titleChanged( ArticleView *, QString const & title );
|
void titleChanged( ArticleView *, QString const & title );
|
||||||
|
|
||||||
#ifdef HAVE_X11
|
|
||||||
void delayShow();
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue