| 333 | } |
| 334 | |
| 335 | QJsonObject loadVirtualWheelSettings() |
| 336 | { |
| 337 | auto& appSettings = AppSettings::instance(); |
| 338 | const QString raw = appSettings.value(kVirtualWheelSettingsKey, QStringLiteral("{}")).toString(); |
| 339 | QJsonParseError error; |
| 340 | const QJsonDocument doc = QJsonDocument::fromJson(raw.toUtf8(), &error); |
| 341 | QJsonObject settings; |
| 342 | if (error.error != QJsonParseError::NoError || !doc.isObject()) { |
| 343 | settings = {}; |
| 344 | } else { |
| 345 | settings = doc.object(); |
| 346 | } |
| 347 | |
| 348 | if (!settings.contains(QStringLiteral("looseness")) |
| 349 | && appSettings.contains(kLegacyWheelLoosenessKey)) { |
| 350 | settings[QStringLiteral("looseness")] = |
| 351 | std::clamp(appSettings.value(kLegacyWheelLoosenessKey, kDefaultWheelLooseness).toInt(), |
| 352 | 0, 100); |
| 353 | } |
| 354 | |
| 355 | if (appSettings.contains(kLegacyWheelLoosenessKey)) { |
| 356 | appSettings.setValue(kVirtualWheelSettingsKey, QString::fromUtf8( |
| 357 | QJsonDocument(settings).toJson(QJsonDocument::Compact))); |
| 358 | appSettings.remove(kLegacyWheelLoosenessKey); |
| 359 | appSettings.save(); |
| 360 | } |
| 361 | return settings; |
| 362 | } |
| 363 | |
| 364 | void saveVirtualWheelSettings(const QJsonObject& settings) |
| 365 | { |
no test coverage detected