LameXP development repository
Revision | 9aa6c39d933470b195b129e6803f40a208e628f5 (tree) |
---|---|
Zeit | 2020-04-21 04:22:04 |
Autor | LoRd_MuldeR <mulder2@gmx....> |
Commiter | LoRd_MuldeR |
Some code refactoring in Model_Settings class.
@@ -35,7 +35,7 @@ | ||
35 | 35 | #define VER_LAMEXP_MINOR_LO 9 |
36 | 36 | #define VER_LAMEXP_TYPE Alpha |
37 | 37 | #define VER_LAMEXP_PATCH 4 |
38 | -#define VER_LAMEXP_BUILD 2261 | |
38 | +#define VER_LAMEXP_BUILD 2264 | |
39 | 39 | #define VER_LAMEXP_CONFG 2188 |
40 | 40 | |
41 | 41 | /////////////////////////////////////////////////////////////////////////////// |
@@ -55,7 +55,7 @@ | ||
55 | 55 | class SettingsCache |
56 | 56 | { |
57 | 57 | public: |
58 | - SettingsCache(QSettings *configFile) | |
58 | + SettingsCache(QSettings *const configFile) | |
59 | 59 | : |
60 | 60 | m_configFile(configFile), |
61 | 61 | m_cache(new cache_data_t()), |
@@ -284,7 +284,7 @@ LAMEXP_MAKE_ID(neroAACEnable2Pass, "AdvancedOptions/AACEnc/Enable2Pass | ||
284 | 284 | LAMEXP_MAKE_ID(neroAacNotificationsEnabled, "Flags/EnableNeroAacNotifications"); |
285 | 285 | LAMEXP_MAKE_ID(normalizationFilterEnabled, "AdvancedOptions/VolumeNormalization/Enabled"); |
286 | 286 | LAMEXP_MAKE_ID(normalizationFilterDynamic, "AdvancedOptions/VolumeNormalization/UseDynAudNorm"); |
287 | -LAMEXP_MAKE_ID(normalizationFilterCoupled, "AdvancedOptions/VolumeNormalization/ChannelCoupling"); | |
287 | +LAMEXP_MAKE_ID(normalizationFilterCoupled, "AdvancedOptions/VolumeNormalization/ChannelCoupling"); | |
288 | 288 | LAMEXP_MAKE_ID(normalizationFilterMaxVolume, "AdvancedOptions/VolumeNormalization/MaxVolume"); |
289 | 289 | LAMEXP_MAKE_ID(normalizationFilterSize, "AdvancedOptions/VolumeNormalization/FilterLength"); |
290 | 290 | LAMEXP_MAKE_ID(opusComplexity, "AdvancedOptions/Opus/EncodingComplexity"); |
@@ -355,28 +355,42 @@ SettingsModel::SettingsModel(void) | ||
355 | 355 | } |
356 | 356 | |
357 | 357 | //Create settings |
358 | - QSettings *configFile = new QSettings(configPath, QSettings::IniFormat); | |
359 | - const QString groupKey = QString().sprintf("LameXP.%04X", lamexp_version_confg()); | |
358 | + const QString groupKey = QString().sprintf("LameXP.%u", lamexp_version_confg()); | |
359 | + QScopedPointer<QSettings> configFile(new QSettings(configPath, QSettings::IniFormat)); | |
360 | 360 | const QStringList childGroups = configFile->childGroups(); |
361 | 361 | |
362 | + //Import legacy settings | |
363 | + if ((lamexp_version_confg() == 2188U) && (!childGroups.contains(groupKey, Qt::CaseInsensitive))) | |
364 | + { | |
365 | + const char* const LEGACY_GROUPS[] = { "LameXP_41802188", "LameXP_41702188", NULL }; | |
366 | + for (size_t i = 0; LEGACY_GROUPS[i]; ++i) | |
367 | + { | |
368 | + const QString legacyGroupName = QString::fromLatin1(LEGACY_GROUPS[i]); | |
369 | + if (childGroups.contains(legacyGroupName)) | |
370 | + { | |
371 | + qWarning("Importing legay settings: %s -> %s", MUTILS_UTF8(legacyGroupName), MUTILS_UTF8(groupKey)); | |
372 | + configFile->beginGroup(legacyGroupName); | |
373 | + const QStringList existingKeys = configFile->allKeys(); | |
374 | + configFile->endGroup(); | |
375 | + for (QStringList::ConstIterator iter = existingKeys.constBegin(); iter != existingKeys.constEnd(); iter++) | |
376 | + { | |
377 | + configFile->setValue(QString("%1/%2").arg(groupKey, *iter), configFile->value(QString("%1/%2").arg(legacyGroupName, *iter))); | |
378 | + } | |
379 | + break; | |
380 | + } | |
381 | + } | |
382 | + } | |
383 | + | |
362 | 384 | //Clean-up settings |
363 | 385 | if (!childGroups.empty()) |
364 | 386 | { |
365 | - static const int MAX_GROUPS = 3; | |
366 | - QRegExp filter("^LameXP_(\\d+)(\\d\\d)(\\d\\d\\d\\d\\d)$"); | |
387 | + static const int MAX_GROUPS = 5; | |
367 | 388 | QStringList obsoleteGroups; |
368 | 389 | for (QStringList::ConstIterator iter = childGroups.constBegin(); iter != childGroups.constEnd(); iter++) |
369 | 390 | { |
370 | - if (filter.indexIn(*iter) >= 0) | |
391 | + if (iter->compare(groupKey, Qt::CaseInsensitive) != 0) | |
371 | 392 | { |
372 | - quint32 temp[3] = { 0, 0, 0 }; | |
373 | - if (MUtils::regexp_parse_uint32(filter, temp, 3)) | |
374 | - { | |
375 | - if ((temp[0] < lamexp_version_major()) || ((temp[0] == lamexp_version_major()) && ((temp[1] < lamexp_version_minor()) || ((temp[1] == lamexp_version_minor()) && (temp[2] < lamexp_version_confg()))))) | |
376 | - { | |
377 | - obsoleteGroups.append(*iter); | |
378 | - } | |
379 | - } | |
393 | + obsoleteGroups.append(*iter); | |
380 | 394 | } |
381 | 395 | } |
382 | 396 | if (obsoleteGroups.count() > MAX_GROUPS) |
@@ -400,7 +414,7 @@ SettingsModel::SettingsModel(void) | ||
400 | 414 | configFile->sync(); |
401 | 415 | |
402 | 416 | //Create the cache |
403 | - m_configCache = new SettingsCache(configFile); | |
417 | + m_configCache = new SettingsCache(configFile.take()); | |
404 | 418 | } |
405 | 419 | |
406 | 420 | //////////////////////////////////////////////////////////// |