mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
fix: enabled scanpopup at startup doesn't work
* also merge clipboard monitoring code with toolbar scanning action icon changing code together
This commit is contained in:
parent
7273f84682
commit
a0e32fdfa7
|
@ -233,14 +233,53 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
enableScanningAction->setCheckable( true );
|
||||
|
||||
navToolbar->widgetForAction( enableScanningAction )->setObjectName( "scanPopupButton" );
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
macClipboard = new gd_clipboard();
|
||||
connect(macClipboard, &gd_clipboard::changed, this, &MainWindow::clipboardChange );
|
||||
#endif
|
||||
|
||||
connect( enableScanningAction, &QAction::toggled, this, [ = ]( bool on ) {
|
||||
if( on )
|
||||
{
|
||||
enableScanningAction->setIcon( QIcon( ":/icons/wizard-selected.svg" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
enableScanningAction->setIcon( QIcon( ":/icons/wizard.svg" ) );
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
if( !MacMouseOver::isAXAPIEnabled() )
|
||||
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000, QPixmap( ":/icons/error.svg" ) );
|
||||
|
||||
if( on )
|
||||
{
|
||||
macClipboard->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
macClipboard->stop();
|
||||
}
|
||||
#else
|
||||
if( on ) {
|
||||
connect( QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange );
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnect(QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange);
|
||||
}
|
||||
#endif
|
||||
|
||||
installHotKeys();
|
||||
updateTrayIcon();
|
||||
} );
|
||||
|
||||
if( cfg.preferences.startWithScanPopupOn )
|
||||
{
|
||||
enableScanningAction->setIcon( QIcon( ":/icons/wizard-selected.svg" ) );
|
||||
enableScanningAction->setChecked( true );
|
||||
enableScanningAction->trigger();
|
||||
}
|
||||
|
||||
connect( enableScanningAction, &QAction::toggled, this, &MainWindow::scanEnableToggled );
|
||||
|
||||
navToolbar->addSeparator();
|
||||
|
||||
// sound
|
||||
|
@ -878,27 +917,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
|
||||
inspector.reset( new ArticleInspector( this ));
|
||||
|
||||
// Clipboard related
|
||||
#ifdef Q_OS_MAC
|
||||
macClipboard = new gd_clipboard();
|
||||
connect(macClipboard, &gd_clipboard::changed, this, &MainWindow::clipboardChange );
|
||||
connect(enableScanningAction,&QAction::changed,[this](){
|
||||
if (enableScanningAction->isChecked()){
|
||||
macClipboard->start();
|
||||
} else {
|
||||
macClipboard->stop();
|
||||
}
|
||||
});
|
||||
#else
|
||||
connect(enableScanningAction,&QAction::changed,[this](){
|
||||
if (enableScanningAction->isChecked()){
|
||||
connect( QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange );
|
||||
} else {
|
||||
disconnect(QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Regiser and update URL Scheme for windows
|
||||
// https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)
|
||||
|
@ -3177,30 +3195,6 @@ void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason r )
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::scanEnableToggled( bool on )
|
||||
{
|
||||
|
||||
if ( scanPopup )
|
||||
{
|
||||
if ( on )
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
if( !MacMouseOver::isAXAPIEnabled() )
|
||||
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
|
||||
QPixmap( ":/icons/error.svg" ) );
|
||||
#endif
|
||||
enableScanningAction->setIcon(QIcon(":/icons/wizard-selected.svg"));
|
||||
}
|
||||
else
|
||||
{
|
||||
enableScanningAction->setIcon(QIcon(":/icons/wizard.svg"));
|
||||
}
|
||||
}
|
||||
|
||||
installHotKeys();
|
||||
updateTrayIcon();
|
||||
}
|
||||
|
||||
void MainWindow::showMainWindow()
|
||||
{
|
||||
toggleMainWindow( true );
|
||||
|
|
|
@ -415,8 +415,6 @@ private slots:
|
|||
|
||||
void trayIconActivated( QSystemTrayIcon::ActivationReason );
|
||||
|
||||
void scanEnableToggled( bool );
|
||||
|
||||
void setAutostart( bool );
|
||||
|
||||
void showMainWindow();
|
||||
|
|
Loading…
Reference in a new issue