diff --git a/mainwindow.cc b/mainwindow.cc index 40a68739..47a7a117 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -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 ); diff --git a/mainwindow.hh b/mainwindow.hh index a41f2079..84672355 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -415,8 +415,6 @@ private slots: void trayIconActivated( QSystemTrayIcon::ActivationReason ); - void scanEnableToggled( bool ); - void setAutostart( bool ); void showMainWindow();