From 9b409da59c34ba0d302d15cd2046685091e8a06f Mon Sep 17 00:00:00 2001 From: Frank Martinez Date: Fri, 20 Sep 2024 18:20:05 +0000 Subject: [PATCH] Splash Screen minimal show time. Issue #16264 --- src/Gui/MainWindow.cpp | 28 +++++++++++++++++++++++----- src/Gui/StartupProcess.cpp | 6 +++++- src/Gui/StartupProcess.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 798ec1e463..7f7e28c4fd 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1917,13 +1917,18 @@ void MainWindow::startSplasher() GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General"); // first search for an external image file if (hGrp->GetBool("ShowSplasher", true)) { - d->splashscreen = new SplashScreen(this->splashImage()); + const auto isWayland = qGuiApp->platformName() == QLatin1String("wayland"); + const auto flags = isWayland ? Qt::WindowFlags() : Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint; + d->splashscreen = new SplashScreen(this->splashImage(), flags); if (!hGrp->GetBool("ShowSplasherMessages", false)) { d->splashscreen->setShowMessages(false); } d->splashscreen->show(); + if (!isWayland) { + QApplication::processEvents(); + } } else { d->splashscreen = nullptr; @@ -1933,11 +1938,24 @@ void MainWindow::startSplasher() void MainWindow::stopSplasher() { - if (d->splashscreen) { - d->splashscreen->finish(this); - delete d->splashscreen; - d->splashscreen = nullptr; + const auto isWayland = qGuiApp->platformName() == QLatin1String("wayland"); + if (isWayland) { + if (d->splashscreen) { + d->splashscreen->finish(this); + d->splashscreen->deleteLater(); + d->splashscreen = nullptr; + } + return; } + + QApplication::processEvents(); + QTimer::singleShot(3000, this, [this]() { + if (d->splashscreen) { + d->splashscreen->finish(this); + d->splashscreen->deleteLater(); + d->splashscreen = nullptr; + } + }); } QPixmap MainWindow::aboutImage() const diff --git a/src/Gui/StartupProcess.cpp b/src/Gui/StartupProcess.cpp index 65f46e9b07..b91b0d7e1e 100644 --- a/src/Gui/StartupProcess.cpp +++ b/src/Gui/StartupProcess.cpp @@ -212,6 +212,7 @@ void StartupPostProcess::setLoadFromPythonModule(bool value) void StartupPostProcess::execute() { + showSplashScreen(); setWindowTitle(); setProcessMessages(); setAutoSaving(); @@ -420,7 +421,7 @@ bool StartupPostProcess::hiddenMainWindow() const return hidden; } -void StartupPostProcess::showMainWindow() +void StartupPostProcess::showSplashScreen() { bool hidden = hiddenMainWindow(); @@ -428,7 +429,10 @@ void StartupPostProcess::showMainWindow() if (!hidden && !loadFromPythonModule) { mainWindow->startSplasher(); } +} +void StartupPostProcess::showMainWindow() +{ // running the GUI init script try { Base::Console().Log("Run Gui init script\n"); diff --git a/src/Gui/StartupProcess.h b/src/Gui/StartupProcess.h index 75a2c3a824..eb9b007c71 100644 --- a/src/Gui/StartupProcess.h +++ b/src/Gui/StartupProcess.h @@ -74,6 +74,7 @@ private: void setImportImageFormats(); bool hiddenMainWindow() const; void showMainWindow(); + void showSplashScreen(); void activateWorkbench(); void checkParameters();