Put conditions on the ClipboardChange for X11

This commit is contained in:
shenleban tongying 2022-11-19 13:48:26 -05:00
parent e6b9810cc7
commit 06a296c99f
4 changed files with 26 additions and 10 deletions

View file

@ -27,7 +27,7 @@ public:
/// Returns true if all Modifiers present within the given mask are pressed
/// right now.
bool checkModifiersPressed( int mask );
bool static checkModifiersPressed( int mask );
};
#endif

View file

@ -49,6 +49,8 @@
#include "ui_authentication.h"
#include "resourceschemehandler.h"
#include "keyboardstate.hh"
#ifdef Q_OS_MAC
#include "macmouseover.hh"
#endif
@ -908,16 +910,26 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
inspector.reset( new ArticleInspector( this ));
connect( QApplication::clipboard(), &QClipboard::dataChanged, this, &MainWindow::clipboardChange );
connect( QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange );
}
void MainWindow::clipboardChange( )
void MainWindow::clipboardChange( QClipboard::Mode m)
{
qDebug() << "clipboard change ," << scanPopup.get();
if( scanPopup && enableScanningAction->isChecked() )
{
if ( cfg.preferences.enableScanPopupModifiers && KeyboardState::checkModifiersPressed(cfg.preferences.scanPopupModifiers))
{
if(m == QClipboard::Clipboard){
if(!cfg.preferences.trackClipboardScan) return;
scanPopup->translateWordFromClipboard();
}
if(m == QClipboard::Selection){
if(!cfg.preferences.trackSelectionScan) return;
scanPopup->translateWordFromSelection();
}
}
}
}
void MainWindow::ctrlTabPressed()

View file

@ -484,7 +484,7 @@ private slots:
void showGDHelp();
void hideGDHelp();
void clipboardChange( );
void clipboardChange(QClipboard::Mode m);
void inspectElement( QWebEnginePage * );

View file

@ -522,11 +522,15 @@ void ScanPopup::clipboardChanged( QClipboard::Mode m )
#ifdef HAVE_X11
if( cfg.preferences.ignoreOwnClipboardChanges && ownsClipboardMode( m ) )
return;
#endif
GD_DPRINTF( "clipboard changed\n" );
if(m == QClipboard::Clipboard && !cfg.preferences.trackClipboardScan){
return;
}
if(m == QClipboard::Selection && !cfg.preferences.trackSelectionScan){
return;
}
#ifdef HAVE_X11
if( m == QClipboard::Selection )
{
// Use delay show to prevent multiple popups while selection in progress