diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2020-11-18 10:01:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-18 10:01:27 +0100 |
| commit | ddba54382aab3cb5548485d14c85e2611272f3cb (patch) | |
| tree | e3b1aa7f86c3d6852f2f749e40ff61971c0961b3 /src/settings.cpp | |
| parent | 06686403382a98d23685232d404dfe5837ffb8a1 (diff) | |
| parent | 61554d3df7be909acf6609b4b7465b03d7f16081 (diff) | |
Merge pull request #1292 from Holt59/iplugin-isactive-refactoring
IPlugin::isActive refactoring
Diffstat (limited to 'src/settings.cpp')
| -rw-r--r-- | src/settings.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 75e2fd83..d325c02f 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1280,9 +1280,17 @@ void PluginSettings::registerPlugin(IPlugin *plugin) const QString settingName = plugin->name() + "/" + setting.key; QVariant temp = get<QVariant>( - m_Settings, "Plugins", settingName, setting.defaultValue); + m_Settings, "Plugins", settingName, QVariant()); - if (!temp.convert(setting.defaultValue.type())) { + // No previous enabled? Skip. + if (setting.key == "enabled" && (!temp.isValid() || !temp.canConvert<bool>())) { + continue; + } + + if (!temp.isValid()) { + temp = setting.defaultValue; + } + else if (!temp.convert(setting.defaultValue.type())) { log::warn( "failed to interpret \"{}\" as correct type for \"{}\" in plugin \"{}\", using default", temp.toString(), setting.key, plugin->name()); @@ -1296,6 +1304,17 @@ void PluginSettings::registerPlugin(IPlugin *plugin) .arg(setting.description) .arg(setting.defaultValue.toString()); } + + // Handle previous "enabled" settings: + if (m_PluginSettings[plugin->name()].contains("enabled")) { + setPersistent(plugin->name(), "enabled", m_PluginSettings[plugin->name()]["enabled"].toBool(), true); + m_PluginSettings[plugin->name()].remove("enabled"); + m_PluginDescriptions[plugin->name()].remove("enabled"); + + // We need to drop it manually in Settings since it is not possible to remove plugin + // settings: + remove(m_Settings, "Plugins", plugin->name() + "/enabled"); + } } std::vector<MOBase::IPlugin*> PluginSettings::plugins() const |
