From 36ca0d0994f696e56538fa9ddabd4a2611813b7e Mon Sep 17 00:00:00 2001 From: shenlebantongying Date: Sun, 6 Aug 2023 09:30:17 -0400 Subject: [PATCH] fix: adjust the order of Mainwindow's show() and restoreState/restoreGeometry --- src/ui/mainwindow.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 9ac3aff9..3ae73757 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -769,7 +769,19 @@ MainWindow::MainWindow( Config::Class & cfg_ ): view->showDefinition( tr( "Welcome!" ), Instances::Group::HelpGroupId ); history.enableAdd( cfg.preferences.storeHistory ); - translateLine->setFocus(); + // restore should be called after all UI initialized but not necessarily after show() + // This must be called before show() as of Qt6.5 on Windows, not sure if it is a bug + // Due to a bug of WebEngine, this also must be called after WebEngine has a view loaded https://bugreports.qt.io/browse/QTBUG-115074 + if ( cfg.mainWindowState.size() && !cfg.resetState ) + restoreState( cfg.mainWindowState ); + if ( cfg.mainWindowGeometry.size() ) + restoreGeometry( cfg.mainWindowGeometry ); + + // Show window unless it is configured not to + if ( !cfg.preferences.enableTrayIcon || !cfg.preferences.startToTray ) { + show(); + focusTranslateLine(); + } // Scanpopup related scanPopup = @@ -860,12 +872,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ): on_alwaysOnTop_triggered( true ); } - // Only show window initially if it wasn't configured differently - if ( !cfg.preferences.enableTrayIcon || !cfg.preferences.startToTray ) { - show(); - focusTranslateLine(); - } - if ( cfg.preferences.hideMenubar ) { toggleMenuBarTriggered( false ); } @@ -911,12 +917,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ): urlRegistry.endGroup(); #endif - // restore should be called after all UI initialized. - if ( cfg.mainWindowState.size() && !cfg.resetState ) - restoreState( cfg.mainWindowState ); - if ( cfg.mainWindowGeometry.size() ) - restoreGeometry( cfg.mainWindowGeometry ); - useSmallIconsInToolbarsTriggered(); if ( cfg.preferences.checkForNewReleases ) {