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 /// Returns true if all Modifiers present within the given mask are pressed
/// right now. /// right now.
bool checkModifiersPressed( int mask ); bool static checkModifiersPressed( int mask );
}; };
#endif #endif

View file

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

View file

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

View file

@ -522,11 +522,15 @@ void ScanPopup::clipboardChanged( QClipboard::Mode m )
#ifdef HAVE_X11 #ifdef HAVE_X11
if( cfg.preferences.ignoreOwnClipboardChanges && ownsClipboardMode( m ) ) if( cfg.preferences.ignoreOwnClipboardChanges && ownsClipboardMode( m ) )
return; 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 ) 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