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
This commit is contained in:
committed by
GitHub
parent
256cced4b8
commit
f5402a4687
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user