cleanup settings for backends
This commit is contained in:
parent
c07e04faeb
commit
d9aac2372f
|
@ -90,7 +90,11 @@ void SnorePlugin::setDefaultValue(const QString &key, const QVariant &value, con
|
||||||
|
|
||||||
Snore::PluginSettingsWidget *SnorePlugin::settingsWidget()
|
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
|
QString SnorePlugin::normaliseKey(const QString &key) const
|
||||||
|
|
|
@ -32,7 +32,10 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa
|
||||||
{
|
{
|
||||||
setLayout(m_layout);
|
setLayout(m_layout);
|
||||||
addRow("Type:", new QLabel(snorePlugin->typeName()));
|
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()
|
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();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginSettingsWidget::saveSettings()
|
void PluginSettingsWidget::saveSettings()
|
||||||
{
|
{
|
||||||
m_snorePlugin->setValue("Enabled", m_enabled->isChecked());
|
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||||
m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(), m_enabled->isChecked());
|
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();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,10 @@ QList<PluginSettingsWidget *> SnoreCore::settingWidgets()
|
||||||
QList<PluginSettingsWidget *> list;
|
QList<PluginSettingsWidget *> list;
|
||||||
for (auto p : d->m_plugins) {
|
for (auto p : d->m_plugins) {
|
||||||
//TODO: mem leak?
|
//TODO: mem leak?
|
||||||
list.append(p->settingsWidget());
|
PluginSettingsWidget *widget = p->settingsWidget();
|
||||||
|
if (widget) {
|
||||||
|
list.append(p->settingsWidget());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue