From 9079e2125d0e2ab9e5d521b10e48355951dca126 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Mon, 6 Mar 2023 22:40:47 -0500 Subject: [PATCH] fix: move enableScanningAction code after scanPopup's initialization --- mainwindow.cc | 92 +++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/mainwindow.cc b/mainwindow.cc index 86cc085c..42ac091f 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -231,52 +231,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ): 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->trigger(); - } - navToolbar->addSeparator(); // sound @@ -840,6 +794,52 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( scanPopup, &ScanPopup::sendWordToFavorites, this, &MainWindow::addWordToFavorites ); connect( scanPopup, &ScanPopup::isWordPresentedInFavorites, this, &MainWindow::isWordPresentedInFavorites ); +#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->trigger(); + } + updateSearchPaneAndBar( cfg.preferences.searchInDock ); ui.searchPane->setVisible( cfg.preferences.searchInDock );