fix: move enableScanningAction code after scanPopup's initialization

This commit is contained in:
shenleban tongying 2023-03-06 22:40:47 -05:00 committed by xiaoyifang
parent afa77a8f31
commit 9079e2125d

View file

@ -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 );