proxy: Actually fix settings migration logic
[quassel.git] / src / qtui / qtuiapplication.cpp
index fbc9f9a..927248f 100644 (file)
@@ -214,7 +214,7 @@ bool QtUiApplication::migrateSettings()
     //
     // NOTE:  If you increase the minor version, you MUST ALSO add new version upgrade logic in
     // applySettingsMigration()!  Otherwise, settings upgrades will fail.
-    const uint VERSION_MINOR_CURRENT = 6;
+    const uint VERSION_MINOR_CURRENT = 7;
     // Stored minor version
     uint versionMinor = s.versionMinor();
 
@@ -281,12 +281,17 @@ bool QtUiApplication::applySettingsMigration(QtUiSettings settings, const uint n
     // migrateSettings()!  Otherwise, your upgrade logic won't ever be called.
     case 7:
     {
-        // New default changes: ProxyType=3 (no proxy) now means QNetworkProxy::HttpProxy
-        // So we have to change it to ProxyType=2 (QNetworkProxy::NoProxy)
-        const QString proxyType = "ProxyType";
-        if (settings.valueExists(proxyType) && settings.value(proxyType)=="3") {
-            settings.setValue(proxyType, 2);
+        // New default changes: UseProxy is no longer used in CoreAccountSettings
+        CoreAccountSettings s;
+        for (auto &&accountId : s.knownAccounts()) {
+            auto map = s.retrieveAccountData(accountId);
+            if (!map.value("UseProxy", false).toBool()) {
+                map["ProxyType"] = static_cast<int>(QNetworkProxy::ProxyType::NoProxy);
+            }
+            map.remove("UseProxy");
+            s.storeAccountData(accountId, map);
         }
+
         // Migration complete!
         return true;
     }