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()
|
||||||
{
|
{
|
||||||
|
if(type() != SnorePlugin::BACKEND) {
|
||||||
|
// don't display a useless default widget for backends
|
||||||
return new PluginSettingsWidget(this);
|
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()));
|
||||||
|
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||||
|
// backends are handled through a combo box.
|
||||||
addRow("Enabled:", m_enabled);
|
addRow("Enabled:", m_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +56,19 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget)
|
||||||
|
|
||||||
void PluginSettingsWidget::loadSettings()
|
void PluginSettingsWidget::loadSettings()
|
||||||
{
|
{
|
||||||
|
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||||
m_enabled->setChecked(m_snorePlugin->value("Enabled").toBool());
|
m_enabled->setChecked(m_snorePlugin->value("Enabled").toBool());
|
||||||
|
}
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginSettingsWidget::saveSettings()
|
void PluginSettingsWidget::saveSettings()
|
||||||
{
|
{
|
||||||
|
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||||
m_snorePlugin->setValue("Enabled", 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());
|
m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(), m_enabled->isChecked());
|
||||||
|
}
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,11 @@ 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?
|
||||||
|
PluginSettingsWidget *widget = p->settingsWidget();
|
||||||
|
if (widget) {
|
||||||
list.append(p->settingsWidget());
|
list.append(p->settingsWidget());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue