From 4ea77ee749e148e656bd4b3e4b62d12a346adb44 Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 24 Feb 2023 19:58:21 +1100 Subject: [PATCH] feat(cpn): Show splash screen after main window - resolves delay and position save issues on MacOS (#3210) - Don't create splash objects unless needed - Show main window before showing splash (fixes MacOS issues) - Delay showing splash until app.exec() started (fixes MacOS issues) --- companion/src/companion.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/companion/src/companion.cpp b/companion/src/companion.cpp index 62c8b480c..7f93f1645 100644 --- a/companion/src/companion.cpp +++ b/companion/src/companion.cpp @@ -240,27 +240,24 @@ int main(int argc, char *argv[]) profile.fwName(""); } - QString splashScreen; - splashScreen = ":/images/splash.png"; - - QPixmap pixmap = QPixmap(splashScreen); - QSplashScreen *splash = new QSplashScreen(pixmap); - Firmware::setCurrentVariant(Firmware::getFirmwareForId(g.profile[g.id()].fwType())); MainWindow *mainWin = new MainWindow(); + mainWin->show(); + if (g.showSplash()) { - splash->show(); - QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close())); - QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show())); - } - else { - mainWin->show(); + QSplashScreen *splash = new QSplashScreen(QPixmap(":/images/splash.png")); + QTimer::singleShot(1, [=] { + splash->show(); + }); + QTimer::singleShot(1000*SPLASH_TIME, [=] { + splash->close(); + delete splash; + }); } int result = app.exec(); - delete splash; delete mainWin; SimulatorLoader::unregisterSimulators();