cleanup
This commit is contained in:
parent
d795a81a1d
commit
58657bfd5b
|
@ -129,7 +129,7 @@ QString SnorePlugin::typeToString(const SnorePlugin::PluginTypes t)
|
|||
return SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType")).valueToKey(t);
|
||||
}
|
||||
|
||||
const QList<SnorePlugin::PluginTypes> &SnorePlugin::types()
|
||||
QList<SnorePlugin::PluginTypes> SnorePlugin::types()
|
||||
{
|
||||
static QList<SnorePlugin::PluginTypes> t;
|
||||
if (t.isEmpty()) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
static PluginTypes typeFromString(const QString &t);
|
||||
static QString typeToString(const PluginTypes t);
|
||||
static const QList<PluginTypes> &types();
|
||||
static QList<PluginTypes> types();
|
||||
|
||||
SnorePlugin(const QString &name);
|
||||
virtual ~SnorePlugin();
|
||||
|
|
|
@ -146,8 +146,8 @@ void SnoreCorePrivate::init()
|
|||
void SnoreCorePrivate::syncSettings()
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
QString newBackend = q->value("PrimaryBackend", LOCAL_SETTING);
|
||||
if (newBackend) {
|
||||
QString newBackend = q->value("PrimaryBackend", LOCAL_SETTING).toString();
|
||||
if (!newBackend.isEmpty()) {
|
||||
QString oldBackend;
|
||||
if (m_notificationBackend) {
|
||||
oldBackend = m_notificationBackend->name();
|
||||
|
@ -159,25 +159,19 @@ void SnoreCorePrivate::syncSettings()
|
|||
setBackendIfAvailible(oldBackend);
|
||||
}
|
||||
}
|
||||
//TODO: cleanup
|
||||
auto syncPluginStatus = [&](const QString & pluginName) {
|
||||
SnorePlugin *plugin = m_plugins.value(pluginName);
|
||||
bool enable = m_plugins[pluginName]->value("Enabled", LOCAL_SETTING).toBool();
|
||||
if (!plugin->isInitialized() && enable) {
|
||||
plugin->initialize();
|
||||
} else if (plugin->isInitialized() && !enable) {
|
||||
plugin->deinitialize();
|
||||
}
|
||||
};
|
||||
|
||||
for (auto pluginName : m_pluginNames[SnorePlugin::SECONDARY_BACKEND]) {
|
||||
syncPluginStatus(pluginName);
|
||||
}
|
||||
for (auto pluginName : m_pluginNames[SnorePlugin::FRONTEND]) {
|
||||
syncPluginStatus(pluginName);
|
||||
}
|
||||
for (auto pluginName : m_pluginNames[SnorePlugin::PLUGIN]) {
|
||||
syncPluginStatus(pluginName);
|
||||
auto types = SnorePlugin::types();
|
||||
types.removeOne(SnorePlugin::BACKEND);
|
||||
for(auto type : types) {
|
||||
for (auto &pluginName : m_pluginNames[type]) {
|
||||
SnorePlugin *plugin = m_plugins.value(pluginName);
|
||||
bool enable = m_plugins[pluginName]->value("Enabled", LOCAL_SETTING).toBool();
|
||||
if (!plugin->isInitialized() && enable) {
|
||||
plugin->initialize();
|
||||
} else if (plugin->isInitialized() && !enable) {
|
||||
plugin->deinitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue