mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 14:29:42 -05:00
Filter out non-image files from the launcher collection (closes #1693)
This commit is contained in:
@@ -312,8 +312,24 @@ void LauncherWindow::setBackgroundImage(const std::string& syncPath) {
|
||||
std::mt19937 g(rd());
|
||||
std::shuffle(files.begin(), files.end(), g);
|
||||
// We know there has to be at least one folder, so it's fine to just pick the first
|
||||
std::string image = files.front();
|
||||
_backgroundImage->setPixmap(QPixmap(QString::fromStdString(image)));
|
||||
while (!files.empty()) {
|
||||
std::string p = files.front();
|
||||
if (std::filesystem::path(p).extension() == ".png") {
|
||||
// If the top path starts with the png extension, we have found our candidate
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// There shouldn't be any non-png images in here, but you never know. So we
|
||||
// just remove non-image files here
|
||||
files.erase(files.begin());
|
||||
}
|
||||
}
|
||||
|
||||
// There better be at least one file left, but just in in case
|
||||
if (!files.empty()) {
|
||||
std::string image = files.front();
|
||||
_backgroundImage->setPixmap(QPixmap(QString::fromStdString(image)));
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherWindow::populateProfilesList(std::string preset) {
|
||||
|
||||
Reference in New Issue
Block a user