Merge pull request #1049 from shenlebantongying/fix_restores

fix: adjust the order of Mainwindow's show() and restoreState/restoreGeometry
This commit is contained in:
xiaoyifang 2023-08-07 09:53:22 +08:00 committed by GitHub
commit fd42f877f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -769,7 +769,19 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
view->showDefinition( tr( "Welcome!" ), Instances::Group::HelpGroupId ); view->showDefinition( tr( "Welcome!" ), Instances::Group::HelpGroupId );
history.enableAdd( cfg.preferences.storeHistory ); 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 related
scanPopup = scanPopup =
@ -860,12 +872,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
on_alwaysOnTop_triggered( true ); 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 ) { if ( cfg.preferences.hideMenubar ) {
toggleMenuBarTriggered( false ); toggleMenuBarTriggered( false );
} }
@ -911,12 +917,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
urlRegistry.endGroup(); urlRegistry.endGroup();
#endif #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(); useSmallIconsInToolbarsTriggered();
if ( cfg.preferences.checkForNewReleases ) { if ( cfg.preferences.checkForNewReleases ) {