diff --git a/src/app/main.cpp b/src/app/main.cpp index 1fffae4da..2a9f84862 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -237,6 +237,8 @@ int main(int argc, char *argv[]) #endif if (!firstTimeUser) { + handleChangedDefaults(DefaultPreferencesMode::Legacy); + #ifndef DISABLE_GUI if (!upgrade()) return EXIT_FAILURE; #elif defined(Q_OS_WIN) @@ -248,6 +250,10 @@ int main(int argc, char *argv[]) && isatty(fileno(stdout)))) return EXIT_FAILURE; #endif } + else { + handleChangedDefaults(DefaultPreferencesMode::Current); + } + #if defined(DISABLE_GUI) && !defined(Q_OS_WIN) if (params.shouldDaemonize) { app.reset(); // Destroy current application diff --git a/src/app/upgrade.cpp b/src/app/upgrade.cpp index 99bcde1a0..e0a1060cc 100644 --- a/src/app/upgrade.cpp +++ b/src/app/upgrade.cpp @@ -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 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)); + } +} diff --git a/src/app/upgrade.h b/src/app/upgrade.h index 28c336fd2..62bea4c42 100644 --- a/src/app/upgrade.h +++ b/src/app/upgrade.h @@ -28,4 +28,11 @@ #pragma once +enum class DefaultPreferencesMode +{ + Legacy, + Current +}; + +void handleChangedDefaults(DefaultPreferencesMode mode); bool upgrade(bool ask = true);