From f5402a46872d8fcd1ef0095d1b14722efd5612c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Insaurralde=20Avalos?= <36372335+adrianinsaval@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:49:35 -0400 Subject: [PATCH] GUI: Fix splashscreen for single image (#16428) * fix splashscreen for single image * improve clarity of splashscreen load order logic * fix splashscreen with no _2x variant --- src/Gui/MainWindow.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index bdcd77b117..798ec1e463 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -2029,18 +2029,8 @@ QPixmap MainWindow::splashImage() const if (fi.isFile() && fi.exists()) splash_image.load(fi.filePath(), "PNG"); - // determine the count of splashes - std::string splash_path = App::Application::Config()["SplashScreen"]; - QStringList pixmaps = Gui::BitmapFactory().findIconFiles().filter(QString::fromStdString(splash_path)); - // divide by 2 since there's two sets (normal and 2x) - // minus 1 to ignore the default splash that isn't numbered - int splash_count = pixmaps.count()/2 - 1; - - // set a random splash path - int random = rand() % splash_count; - splash_path += std::to_string(random); - // if no image was found try the config + std::string splash_path = App::Application::Config()["SplashScreen"]; if (splash_image.isNull()) { QString path = QString::fromUtf8(splash_path.c_str()); if (QDir(path).isRelative()) { @@ -2054,6 +2044,17 @@ QPixmap MainWindow::splashImage() const // now try the icon paths float pixelRatio (1.0); if (splash_image.isNull()) { + // determine the count of splashes + QStringList pixmaps = Gui::BitmapFactory().findIconFiles().filter(QString::fromStdString(splash_path)); + // divide by 2 since there's two sets (normal and 2x) + // minus 1 to ignore the default splash that isn't numbered + int splash_count = pixmaps.count()/2 - 1; + + // set a random splash path + if (splash_count > 0) { + int random = rand() % splash_count; + splash_path += std::to_string(random); + } if (qApp->devicePixelRatio() > 1.0) { // For HiDPI screens, we have a double-resolution version of the splash image splash_path += "_2x";