| 193 | } |
| 194 | |
| 195 | void Settings::migrateSettings(QSettings& settings, const QVariant& version) |
| 196 | { |
| 197 | migrateValue("General/language", General_Language, settings); |
| 198 | if (migrateValue("MapEditor/click_tolerance", MapEditor_ClickToleranceMM, settings)) |
| 199 | settings.setValue(getSettingPath(MapEditor_ClickToleranceMM), Util::pixelToMMLogical(settings.value(getSettingPath(MapEditor_ClickToleranceMM)).toReal())); |
| 200 | if (migrateValue("MapEditor/snap_distance", MapEditor_SnapDistanceMM, settings)) |
| 201 | settings.setValue(getSettingPath(MapEditor_SnapDistanceMM), Util::pixelToMMLogical(settings.value(getSettingPath(MapEditor_SnapDistanceMM)).toReal())); |
| 202 | if (migrateValue("RectangleTool/helper_cross_radius", RectangleTool_HelperCrossRadiusMM, settings)) |
| 203 | settings.setValue(getSettingPath(RectangleTool_HelperCrossRadiusMM), Util::pixelToMMLogical(settings.value(getSettingPath(RectangleTool_HelperCrossRadiusMM)).toReal())); |
| 204 | |
| 205 | if (!settings.value(QLatin1String("MapEditor/units_rectified"), false).toBool()) |
| 206 | { |
| 207 | const auto factor = QGuiApplication::primaryScreen()->logicalDotsPerInch() |
| 208 | / getSetting(Settings::General_PixelsPerInch).toReal(); |
| 209 | for (auto setting : { SymbolWidget_IconSizeMM, MapEditor_ClickToleranceMM, MapEditor_SnapDistanceMM, RectangleTool_HelperCrossRadiusMM }) |
| 210 | { |
| 211 | const auto path = getSettingPath(setting); |
| 212 | const auto value = settings.value(path, getDefaultValue(setting)).toReal(); |
| 213 | settings.setValue(path, qRound(value * factor)); |
| 214 | } |
| 215 | settings.setValue(QLatin1String("MapEditor/units_rectified"), true); |
| 216 | } |
| 217 | |
| 218 | bool have_language_number; |
| 219 | auto language_number = getSetting(General_Language).toInt(&have_language_number); |
| 220 | if (have_language_number) |
| 221 | { |
| 222 | // Migrate old numeric language setting |
| 223 | auto language = QLocale(QLocale::Language(language_number)).name().left(2); |
| 224 | setSetting(Settings::General_Language, language); |
| 225 | } |
| 226 | |
| 227 | if (!settings.value(QLatin1String("new_ocd8_implementation_v0.6")).isNull()) |
| 228 | { |
| 229 | // Remove/reset to default |
| 230 | settings.remove(QLatin1String("new_ocd8_implementation_v0.6")); |
| 231 | settings.remove(QLatin1String("new_ocd8_implementation")); |
| 232 | } |
| 233 | |
| 234 | if (!version.toByteArray().startsWith("0.")) |
| 235 | { |
| 236 | // Future cleanup |
| 237 | settings.remove(QLatin1String("new_ocd8_implementation")); |
| 238 | settings.remove(QLatin1String("MapEditor/units_rectified")); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | bool Settings::migrateValue(const char* old_key_latin1, SettingsEnum new_setting, QSettings& settings) const |
| 243 | { |
nothing calls this directly
no test coverage detected