opt: optimize the function in tracking clipboard in trayicon

This commit is contained in:
Xiao YiFang 2022-08-02 22:27:14 +08:00
parent 25c9c38e96
commit fa64d450ea
3 changed files with 13 additions and 9 deletions

View file

@ -411,7 +411,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
actTrackingClipboard = trayIconMenu.addAction( tr( "Tracking Clipboard" ) );
actTrackingClipboard->setCheckable(true);
actTrackingClipboard->setChecked(cfg.preferences.trackClipboardChanges);
actTrackingClipboard->setVisible( cfg.preferences.enableScanPopup );
// actTrackingClipboard->setVisible( cfg.preferences.enableScanPopup );
connect( actTrackingClipboard , SIGNAL( triggered(bool) ),
this, SLOT( trackingClipboard(bool) ) );
trayIconMenu.addSeparator();
@ -918,6 +918,16 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
}
inspector = new ArticleInspector( this );
connect( QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange );
}
void MainWindow::clipboardChange( QClipboard::Mode mode )
{
if( scanPopup && cfg.preferences.trackClipboardChanges )
{
scanPopup->translateWordFromClipboard();
}
}
void MainWindow::ctrlTabPressed()

View file

@ -487,6 +487,8 @@ private slots:
void showGDHelp();
void hideGDHelp();
void clipboardChange( QClipboard::Mode mode );
signals:
/// Set optional parts expand mode for all tabs
void setExpandOptionalParts( bool expand );

View file

@ -514,14 +514,6 @@ void ScanPopup::delayShow()
void ScanPopup::clipboardChanged( QClipboard::Mode m )
{
if( cfg.preferences.trackClipboardChanges )
{
QString subtype = "plain";
handleInputWord( QApplication::clipboard()->text( subtype, m ) );
return;
}
if( !isScanningEnabled )
return;