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)
This commit is contained in:
philmoz
2023-02-24 18:58:21 +10:00
committed by GitHub
parent 4fa666e680
commit 4ea77ee749
+10 -13
View File
@@ -240,27 +240,24 @@ int main(int argc, char *argv[])
profile.fwName(""); 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())); Firmware::setCurrentVariant(Firmware::getFirmwareForId(g.profile[g.id()].fwType()));
MainWindow *mainWin = new MainWindow(); MainWindow *mainWin = new MainWindow();
mainWin->show();
if (g.showSplash()) { if (g.showSplash()) {
splash->show(); QSplashScreen *splash = new QSplashScreen(QPixmap(":/images/splash.png"));
QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close())); QTimer::singleShot(1, [=] {
QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show())); splash->show();
} });
else { QTimer::singleShot(1000*SPLASH_TIME, [=] {
mainWin->show(); splash->close();
delete splash;
});
} }
int result = app.exec(); int result = app.exec();
delete splash;
delete mainWin; delete mainWin;
SimulatorLoader::unregisterSimulators(); SimulatorLoader::unregisterSimulators();