Splash Screen minimal show time. Issue #16264

This commit is contained in:
Frank Martinez
2024-09-20 18:20:05 +00:00
committed by Chris Hennes
parent a715a4d161
commit 9b409da59c
3 changed files with 29 additions and 6 deletions

View File

@@ -1917,13 +1917,18 @@ void MainWindow::startSplasher()
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General"); GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General");
// first search for an external image file // first search for an external image file
if (hGrp->GetBool("ShowSplasher", true)) { 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)) { if (!hGrp->GetBool("ShowSplasherMessages", false)) {
d->splashscreen->setShowMessages(false); d->splashscreen->setShowMessages(false);
} }
d->splashscreen->show(); d->splashscreen->show();
if (!isWayland) {
QApplication::processEvents();
}
} }
else { else {
d->splashscreen = nullptr; d->splashscreen = nullptr;
@@ -1933,11 +1938,24 @@ void MainWindow::startSplasher()
void MainWindow::stopSplasher() void MainWindow::stopSplasher()
{ {
if (d->splashscreen) { const auto isWayland = qGuiApp->platformName() == QLatin1String("wayland");
d->splashscreen->finish(this); if (isWayland) {
delete d->splashscreen; if (d->splashscreen) {
d->splashscreen = nullptr; 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 QPixmap MainWindow::aboutImage() const

View File

@@ -212,6 +212,7 @@ void StartupPostProcess::setLoadFromPythonModule(bool value)
void StartupPostProcess::execute() void StartupPostProcess::execute()
{ {
showSplashScreen();
setWindowTitle(); setWindowTitle();
setProcessMessages(); setProcessMessages();
setAutoSaving(); setAutoSaving();
@@ -420,7 +421,7 @@ bool StartupPostProcess::hiddenMainWindow() const
return hidden; return hidden;
} }
void StartupPostProcess::showMainWindow() void StartupPostProcess::showSplashScreen()
{ {
bool hidden = hiddenMainWindow(); bool hidden = hiddenMainWindow();
@@ -428,7 +429,10 @@ void StartupPostProcess::showMainWindow()
if (!hidden && !loadFromPythonModule) { if (!hidden && !loadFromPythonModule) {
mainWindow->startSplasher(); mainWindow->startSplasher();
} }
}
void StartupPostProcess::showMainWindow()
{
// running the GUI init script // running the GUI init script
try { try {
Base::Console().Log("Run Gui init script\n"); Base::Console().Log("Run Gui init script\n");

View File

@@ -74,6 +74,7 @@ private:
void setImportImageFormats(); void setImportImageFormats();
bool hiddenMainWindow() const; bool hiddenMainWindow() const;
void showMainWindow(); void showMainWindow();
void showSplashScreen();
void activateWorkbench(); void activateWorkbench();
void checkParameters(); void checkParameters();