handle whether a plugin is enabled
This commit is contained in:
parent
4e0b906bb5
commit
331e9faaf1
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
#include "pluginsettingswidget.h"
|
#include "pluginsettingswidget.h"
|
||||||
#include "plugins.h"
|
#include "plugins.h"
|
||||||
|
#include "snore.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ void PluginSettingsWidget::loadSettings()
|
||||||
void PluginSettingsWidget::saveSettings()
|
void PluginSettingsWidget::saveSettings()
|
||||||
{
|
{
|
||||||
m_snorePlugin->setValue("Enabled",m_enabled->isChecked());
|
m_snorePlugin->setValue("Enabled",m_enabled->isChecked());
|
||||||
|
m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(),m_enabled->isChecked());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,16 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||||
case SnorePlugin::SECONDARY_BACKEND:
|
case SnorePlugin::SECONDARY_BACKEND:
|
||||||
case SnorePlugin::FRONTEND:
|
case SnorePlugin::FRONTEND:
|
||||||
case SnorePlugin::PLUGIN:
|
case SnorePlugin::PLUGIN:
|
||||||
if (!info->load()->initialize()) {
|
{
|
||||||
info->load()->deinitialize();
|
SnorePlugin *plugin = info->load();
|
||||||
info->unload();
|
if(plugin->value("Enabled").toBool()) {
|
||||||
break;
|
if (!plugin->initialize()) {
|
||||||
|
plugin->deinitialize();
|
||||||
|
info->unload();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type();
|
snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type();
|
||||||
|
|
|
@ -31,15 +31,6 @@ SettingsDialog::SettingsDialog(SnoreCore *snore, QWidget *parent) :
|
||||||
m_snore(snore)
|
m_snore(snore)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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())
|
for(auto widget : snore->settingWidgets())
|
||||||
{
|
{
|
||||||
ui->tabWidget->addTab(widget,widget->name());
|
ui->tabWidget->addTab(widget,widget->name());
|
||||||
|
|
|
@ -6,25 +6,23 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>979</width>
|
||||||
<height>300</height>
|
<height>300</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<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>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>-1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Active Backends</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout2"/>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -39,7 +37,9 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../data/snore.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
|
Loading…
Reference in New Issue