diff --git a/src/core/plugins/plugins.cpp b/src/core/plugins/plugins.cpp index 2c30250..6c2dbb2 100644 --- a/src/core/plugins/plugins.cpp +++ b/src/core/plugins/plugins.cpp @@ -90,7 +90,11 @@ void SnorePlugin::setDefaultValue(const QString &key, const QVariant &value, con Snore::PluginSettingsWidget *SnorePlugin::settingsWidget() { - return new PluginSettingsWidget(this); + if(type() != SnorePlugin::BACKEND) { + // don't display a useless default widget for backends + return new PluginSettingsWidget(this); + } + return nullptr; } QString SnorePlugin::normaliseKey(const QString &key) const diff --git a/src/core/plugins/pluginsettingswidget.cpp b/src/core/plugins/pluginsettingswidget.cpp index 38a4234..74ee39f 100644 --- a/src/core/plugins/pluginsettingswidget.cpp +++ b/src/core/plugins/pluginsettingswidget.cpp @@ -32,7 +32,10 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa { setLayout(m_layout); addRow("Type:", new QLabel(snorePlugin->typeName())); - addRow("Enabled:", m_enabled); + if (m_snorePlugin->type() != SnorePlugin::BACKEND) { + // backends are handled through a combo box. + addRow("Enabled:", m_enabled); + } } @@ -53,14 +56,19 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget) void PluginSettingsWidget::loadSettings() { - m_enabled->setChecked(m_snorePlugin->value("Enabled").toBool()); + if (m_snorePlugin->type() != SnorePlugin::BACKEND) { + m_enabled->setChecked(m_snorePlugin->value("Enabled").toBool()); + } load(); } void PluginSettingsWidget::saveSettings() { - m_snorePlugin->setValue("Enabled", m_enabled->isChecked()); - m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(), m_enabled->isChecked()); + if (m_snorePlugin->type() != SnorePlugin::BACKEND) { + m_snorePlugin->setValue("Enabled", m_enabled->isChecked()); + // we only allow one active primary backend + m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(), m_enabled->isChecked()); + } save(); } diff --git a/src/core/snore.cpp b/src/core/snore.cpp index 52fd0dd..8110e67 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -180,7 +180,10 @@ QList SnoreCore::settingWidgets() QList list; for (auto p : d->m_plugins) { //TODO: mem leak? - list.append(p->settingsWidget()); + PluginSettingsWidget *widget = p->settingsWidget(); + if (widget) { + list.append(p->settingsWidget()); + } } return list; }