diff options
| author | Seth Riley <17361645+Qudix@users.noreply.github.com> | 2020-12-01 15:55:50 -0600 |
|---|---|---|
| committer | Seth Riley <17361645+Qudix@users.noreply.github.com> | 2020-12-01 15:55:50 -0600 |
| commit | 852d8745a1ac3ef2aaa83ae21d473d20428d7d30 (patch) | |
| tree | 7ff242377cd3ec72571cd96cd631c28bbaac6470 /src/settings.cpp | |
| parent | 60688ecf5bc6e44795472cb22888ec5994a904a8 (diff) | |
| parent | 1ec3ab2b8a845f75495b4cacbeb17c86ea137a01 (diff) | |
Merge https://github.com/ModOrganizer2/modorganizer into ignore_alt
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 |
