1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-06 19:12:30 +01:00

Change profile to be reset on invalid config

This commit is contained in:
Elias Steurer 2021-09-04 21:18:10 +02:00
parent 0a602bd10a
commit 4da2632d8e

View File

@ -90,7 +90,12 @@ void ScreenPlayManager::init(
});
}
loadProfiles();
// Reset to default settings if we are unable to load
// the existing one
if (!loadProfiles()) {
qInfo() << "Reset default profiles.json at:" << m_globalVariables->localSettingsPath();
m_settings->writeJsonFileFromResource("profiles");
}
}
/*!
@ -559,6 +564,20 @@ bool ScreenPlayManager::loadProfiles()
if (wallpaper.toObject().value("name").toString() != "default")
continue;
// Dry run to check if the config is outdated. This is when a wallpaper is configured
// but no longer available.
for (QJsonValueRef wallpaper : wallpaper.toObject().value("wallpaper").toArray()) {
QJsonObject wallpaperObj = wallpaper.toObject();
if (wallpaperObj.empty())
continue;
const QString absolutePath = wallpaperObj.value("absolutePath").toString();
if (!QFile(absolutePath).exists()) {
qWarning() << "Specified file does not exist! This means the profiles.json is no longer valid.";
return false;
}
}
for (QJsonValueRef wallpaper : wallpaper.toObject().value("wallpaper").toArray()) {
QJsonObject wallpaperObj = wallpaper.toObject();