add each plugin type to a seperate tab
This commit is contained in:
parent
503d264839
commit
efce32156e
|
@ -31,7 +31,6 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa
|
|||
m_enabled(new QCheckBox)
|
||||
{
|
||||
setLayout(m_layout);
|
||||
addRow("Type:", new QLabel(snorePlugin->typeName()));
|
||||
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||
// backends are handled through a combo box.
|
||||
addRow("Enabled:", m_enabled);
|
||||
|
|
|
@ -29,18 +29,23 @@ using namespace Snore;
|
|||
|
||||
SettingsDialog::SettingsDialog(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SettingsDialog),
|
||||
m_app(new Application("SnoreSettings", Icon(":/root/snore.png"))),
|
||||
m_alert(new Alert("Test", Icon(":/root/snore.png")))
|
||||
ui(new Ui::SettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_app->addAlert(*m_alert);
|
||||
|
||||
for (auto widget : SnoreCore::instance().settingWidgets()) {
|
||||
ui->tabWidget->addTab(widget, widget->name());
|
||||
m_tabs.append(widget);
|
||||
}
|
||||
auto addWidgets = [&](QTabWidget *target, QWidget *container, SnorePlugin::PluginTypes type){
|
||||
bool enabled = false;
|
||||
for (PluginSettingsWidget *widget : SnoreCore::instance().settingWidgets(type)) {
|
||||
target->addTab(widget, widget->name());
|
||||
m_tabs.append(widget);
|
||||
enabled = true;
|
||||
}
|
||||
ui->tabWidget->setTabEnabled(ui->tabWidget->indexOf(container), enabled);
|
||||
};
|
||||
addWidgets(ui->tabWidget_backends, ui->tab_backends, SnorePlugin::BACKEND);
|
||||
addWidgets(ui->tabWidget_secondary_backends, ui->tab_secondaryBackends, SnorePlugin::SECONDARY_BACKEND);
|
||||
addWidgets(ui->tabWidget_frontends, ui->tab_frontends, SnorePlugin::FRONTEND);
|
||||
addWidgets(ui->tabWidget_plugins, ui->tab_plugins, SnorePlugin::PLUGIN);
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog()
|
||||
|
@ -50,10 +55,8 @@ SettingsDialog::~SettingsDialog()
|
|||
|
||||
void Snore::SettingsDialog::on_pushButton_clicked()
|
||||
{
|
||||
if (!SnoreCore::instance().aplications().contains(m_app->name())) {
|
||||
SnoreCore::instance().registerApplication(*m_app);
|
||||
}
|
||||
Notification noti(*m_app, *m_alert, "Hello World",
|
||||
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
||||
Notification noti(app, app.alerts()["Default"], "Hello World",
|
||||
"<i>This is Snore</i><br>"
|
||||
"<a href=\"https://github.com/TheOneRing/Snorenotify\">Project Website</a><br>",
|
||||
Icon(":/root/snore.png"));
|
||||
|
@ -107,7 +110,6 @@ void SettingsDialog::accept()
|
|||
save();
|
||||
}
|
||||
|
||||
|
||||
void SettingsDialog::reset()
|
||||
{
|
||||
load();
|
||||
|
|
|
@ -61,8 +61,6 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::SettingsDialog *ui;
|
||||
QScopedPointer<Application> m_app;
|
||||
QScopedPointer<Alert> m_alert;
|
||||
QList<Snore::PluginSettingsWidget *> m_tabs;
|
||||
|
||||
};
|
||||
|
|
|
@ -67,6 +67,46 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_backends">
|
||||
<attribute name="title">
|
||||
<string>Primary Backends</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_backends"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_secondaryBackends">
|
||||
<attribute name="title">
|
||||
<string>Secondary Bckends</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_secondary_backends"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_frontends">
|
||||
<attribute name="title">
|
||||
<string>Frontends</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_frontends"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_plugins">
|
||||
<attribute name="title">
|
||||
<string>Plugins</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_plugins"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -188,12 +188,13 @@ void SnoreCore::setDefaultApplication(Application app)
|
|||
d->m_defaultApp = app;
|
||||
}
|
||||
|
||||
QList<PluginSettingsWidget *> SnoreCore::settingWidgets()
|
||||
QList<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes type)
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
QList<PluginSettingsWidget *> list;
|
||||
for (auto p : d->m_plugins) {
|
||||
for (auto name : d->m_pluginNames[type]) {
|
||||
//TODO: mem leak?
|
||||
SnorePlugin *p = d->m_plugins[name];
|
||||
PluginSettingsWidget *widget = p->settingsWidget();
|
||||
if (widget) {
|
||||
list.append(widget);
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
*
|
||||
* @return a list of plugins
|
||||
*/
|
||||
const QStringList pluginNames(SnorePlugin::PluginTypes type) const;
|
||||
const QStringList pluginNames(SnorePlugin::PluginTypes type = SnorePlugin::ALL) const;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
*
|
||||
* @return A list of widgets a settings dialog.
|
||||
*/
|
||||
QList<PluginSettingsWidget *> settingWidgets();
|
||||
QList<PluginSettingsWidget *> settingWidgets(SnorePlugin::PluginTypes type);
|
||||
|
||||
QVariant value(const QString &key, SettingsType type = GLOBAL_SETTING) const;
|
||||
void setValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
|
||||
|
|
|
@ -52,6 +52,9 @@ SnoreCorePrivate::~SnoreCorePrivate()
|
|||
|
||||
const Application SnoreCorePrivate::defaultApplication() const
|
||||
{
|
||||
if (!SnoreCore::instance().aplications().contains(m_defaultApp.name())) {
|
||||
SnoreCore::instance().registerApplication(m_defaultApp);
|
||||
}
|
||||
return m_defaultApp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue