From 98350a16a8ff9c366700ec4c58aa757a59f57030 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 21 Sep 2024 16:14:08 -0700 Subject: [PATCH] Rename group name --- src/Settings/AutoConnectSettings.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Settings/AutoConnectSettings.cc b/src/Settings/AutoConnectSettings.cc index 0a2aac4c68a..d2ff37848f1 100644 --- a/src/Settings/AutoConnectSettings.cc +++ b/src/Settings/AutoConnectSettings.cc @@ -12,9 +12,29 @@ #include -DECLARE_SETTINGGROUP(AutoConnect, "LinkManager") +DECLARE_SETTINGGROUP(AutoConnect, "AutoConnect") { - qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "AutoConnectSettings", "Reference only"); \ + qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "AutoConnectSettings", "Reference only"); + + // Settings group name was changed from "LinkManager" to "AutoConnect" in v5.0.0 + // Copy over an old settings to the new name + QSettings settings; + static const char* deprecatedGroupName = "LinkManager"; + if (settings.childGroups().contains(deprecatedGroupName)) { + settings.beginGroup(deprecatedGroupName); + QList> values; + for (const QString& key: settings.childKeys()) { + values.append(QPair(key, settings.value(key))); + } + settings.endGroup(); + settings.remove(deprecatedGroupName); + + settings.beginGroup(_name); + for (const QPair& pair: values) { + settings.setValue(pair.first, pair.second); + } + settings.endGroup(); + } } DECLARE_SETTINGSFACT(AutoConnectSettings, autoConnectUDP)