handle whether a plugin is enabled

This commit is contained in:
Patrick von Reth 2015-02-03 12:11:46 +01:00
parent 4e0b906bb5
commit 331e9faaf1
4 changed files with 21 additions and 23 deletions

View File

@ -17,6 +17,7 @@
*/
#include "pluginsettingswidget.h"
#include "plugins.h"
#include "snore.h"
#include <QCheckBox>
@ -58,6 +59,7 @@ void PluginSettingsWidget::loadSettings()
void PluginSettingsWidget::saveSettings()
{
m_snorePlugin->setValue("Enabled",m_enabled->isChecked());
m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(),m_enabled->isChecked());
save();
}

View File

@ -62,11 +62,16 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
case SnorePlugin::SECONDARY_BACKEND:
case SnorePlugin::FRONTEND:
case SnorePlugin::PLUGIN:
if (!info->load()->initialize()) {
info->load()->deinitialize();
info->unload();
break;
{
SnorePlugin *plugin = info->load();
if(plugin->value("Enabled").toBool()) {
if (!plugin->initialize()) {
plugin->deinitialize();
info->unload();
break;
}
}
}
break;
default:
snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type();

View File

@ -31,15 +31,6 @@ SettingsDialog::SettingsDialog(SnoreCore *snore, QWidget *parent) :
m_snore(snore)
{
ui->setupUi(this);
for(const QString &plugin : snore->pluginNames(SnorePlugin::PluginTypes(SnorePlugin::ALL) ^ SnorePlugin::BACKEND))
{
QCheckBox *box = new QCheckBox(plugin);
box->setChecked(snore->pluginIsEnabled(plugin));
connect(box,&QCheckBox::toggled,[plugin,snore,box](bool checked){
box->setChecked(snore->setPluginEnabled(plugin,checked));
});
ui->verticalLayout2->addWidget(box);
}
for(auto widget : snore->settingWidgets())
{
ui->tabWidget->addTab(widget,widget->name());

View File

@ -6,25 +6,23 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>979</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="../../data/snore.qrc">
<normaloff>:/root/snore.png</normaloff>:/root/snore.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>-1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Active Backends</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout2"/>
</widget>
</widget>
</item>
<item>
@ -39,7 +37,9 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../data/snore.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>