Keep legacy defaults for existing users

This commit is contained in:
Vladimir Golovnev (Glassez)
2020-01-09 14:35:25 +03:00
parent 86c95db91d
commit 0c6c65f6f8
3 changed files with 33 additions and 0 deletions

View File

@@ -82,3 +82,23 @@ bool upgrade(const bool /*ask*/)
exportWebUIHttpsFiles();
return true;
}
void handleChangedDefaults(const DefaultPreferencesMode mode)
{
struct DefaultValue
{
QString name;
QVariant legacy;
QVariant current;
};
const QVector<DefaultValue> changedDefaults {
{QLatin1String {"BitTorrent/Session/QueueingSystemEnabled"}, true, false}
};
SettingsStorage *settingsStorage {SettingsStorage::instance()};
for (auto it = changedDefaults.cbegin(); it != changedDefaults.cend(); ++it) {
if (settingsStorage->loadValue(it->name).isNull())
settingsStorage->storeValue(it->name, (mode == DefaultPreferencesMode::Legacy ? it->legacy : it->current));
}
}