File indexing completed on 2024-11-10 05:01:06

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only
0005  *
0006  */
0007 
0008 #ifndef GSETTINGSITEM_H
0009 #define GSETTINGSITEM_H
0010 
0011 #include <QObject>
0012 #include <QStringList>
0013 #include <QVariant>
0014 
0015 #include <gio/gio.h>
0016 
0017 class GSettingsItem : public QObject
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     explicit GSettingsItem(const QString &key, QObject *parent = nullptr);
0023     virtual ~GSettingsItem() override;
0024 
0025     QVariant value(const QString &key) const;
0026     void set(const QString &key, const QVariant &val);
0027 
0028     bool isValid() const;
0029 
0030 Q_SIGNALS:
0031     void subtreeChanged();
0032 
0033 private:
0034     GSettings *m_settings = nullptr;
0035 
0036     static void settingChanged(GSettings *settings, const gchar *key, gpointer data)
0037     {
0038         Q_UNUSED(settings)
0039         Q_UNUSED(key)
0040 
0041         auto *self = static_cast<GSettingsItem *>(data);
0042         Q_EMIT self->subtreeChanged();
0043     }
0044 };
0045 
0046 #endif // GCONFITEM_H