File indexing completed on 2024-05-12 04:45:34

0001 /*
0002     SnoreNotify is a Notification Framework based on Qt
0003     Copyright (C) 2013-2015  Hannah von Reth <vonreth@kde.org>
0004 
0005     SnoreNotify is free software: you can redistribute it and/or modify
0006     it under the terms of the GNU Lesser General Public License as published by
0007     the Free Software Foundation, either version 3 of the License, or
0008     (at your option) any later version.
0009 
0010     SnoreNotify is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013     GNU Lesser General Public License for more details.
0014 
0015     You should have received a copy of the GNU Lesser General Public License
0016     along with SnoreNotify.  If not, see <http://www.gnu.org/licenses/>.
0017 */
0018 #ifndef PLUGINSETTINGSWIDGET_H
0019 #define PLUGINSETTINGSWIDGET_H
0020 
0021 #include "libsnore/settings/snore_settings_exports.h"
0022 #include "libsnore/snoreglobals.h"
0023 
0024 #include <QWidget>
0025 #include <QFormLayout>
0026 #include <QCheckBox>
0027 
0028 namespace Snore
0029 {
0030 class SnorePlugin;
0031 
0032 class SNORE_SETTINGS_EXPORT PluginSettingsWidget : public QWidget
0033 {
0034     Q_OBJECT
0035 public:
0036     explicit PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *parent = nullptr);
0037     ~PluginSettingsWidget();
0038 
0039     const QString name() const;
0040 
0041     void addRow(const QString &label, QWidget *widget, const QString &toolTip = QString());
0042 
0043     void loadSettings();
0044     void saveSettings();
0045 
0046     bool isDirty();
0047 
0048 protected:
0049     QVariant settingsValue(const SettingsKey &key) const;
0050     void setSettingsValue(const SettingsKey &key, const QVariant &settingsValue);
0051 
0052     virtual void load();
0053     virtual void save();
0054 
0055 private:
0056     SnorePlugin *m_snorePlugin;
0057     QFormLayout *m_layout;
0058     QCheckBox *m_enabled;
0059     bool m_dirty = false;
0060 
0061 };
0062 }
0063 
0064 #endif // PLUGINSETTINGSWIDGET_H