Mercurial > hg > tony
diff main/Analyser.cpp @ 673:90ee5448c205
Fix inconsistency between MainWindow and Analyser in the default value of the lowampsuppression option, and enforce default values in a single place. As it stood, the menu option was showing "checked" (on first run) but the parameter was actually unset until you toggled it or used the reset-to-default function.
author | Chris Cannam |
---|---|
date | Mon, 18 Nov 2019 15:07:19 +0000 |
parents | 327177b6bd3a |
children |
line wrap: on
line diff
--- a/main/Analyser.cpp Mon Nov 18 15:05:26 2019 +0000 +++ b/main/Analyser.cpp Mon Nov 18 15:07:19 2019 +0000 @@ -67,6 +67,16 @@ { } +std::map<QString, QVariant> +Analyser::getAnalysisSettings() +{ + return { { "precision-analysis", false }, + { "lowamp-analysis", true }, + { "onset-analysis", true }, + { "prune-analysis", true } + }; +} + QString Analyser::newFileLoaded(Document *doc, ModelId model, PaneStack *paneStack, Pane *pane) @@ -398,10 +408,27 @@ QSettings settings; settings.beginGroup("Analyser"); - bool precise = settings.value("precision-analysis", false).toBool(); - bool lowamp = settings.value("lowamp-analysis", false).toBool(); - bool onset = settings.value("onset-analysis", true).toBool(); // should these be the same as in MainWindow.cpp? - bool prune = settings.value("prune-analysis", true).toBool(); + + bool precise = false, lowamp = true, onset = true, prune = true; + + std::map<QString, bool &> flags { + { "precision-analysis", precise }, + { "lowamp-analysis", lowamp }, + { "onset-analysis", onset }, + { "prune-analysis", prune } + }; + + auto keyMap = getAnalysisSettings(); + + for (auto p: flags) { + auto ki = keyMap.find(p.first); + if (ki != keyMap.end()) { + p.second = settings.value(ki->first, ki->second).toBool(); + } else { + throw std::logic_error("Internal error: One or more analysis settings keys not found in map: check addAnalyses and getAnalysisSettings"); + } + } + settings.endGroup(); Transform t = tf->getDefaultTransformFor