File indexing completed on 2024-12-01 05:07:28
0001 /* 0002 * SPDX-FileCopyrightText: 2018-2019 Red Hat Inc 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 * 0006 * SPDX-FileCopyrightText: 2018-2019 Jan Grulich <jgrulich@redhat.com> 0007 */ 0008 0009 #ifndef XDG_DESKTOP_PORTAL_KDE_SETTINGS_H 0010 #define XDG_DESKTOP_PORTAL_KDE_SETTINGS_H 0011 0012 #include <QDBusAbstractAdaptor> 0013 #include <QDBusObjectPath> 0014 0015 #include <KSharedConfig> 0016 0017 #include "dbushelpers.h" 0018 0019 class DesktopPortal; 0020 class FdoAppearanceSettings; 0021 class KDEGlobalsSettings; 0022 class SettingsModule; 0023 0024 class SettingsModule : public QObject 0025 { 0026 Q_OBJECT 0027 public: 0028 using QObject::QObject; 0029 ~SettingsModule() override = default; 0030 Q_DISABLE_COPY_MOVE(SettingsModule); 0031 virtual inline QString group() = 0; 0032 virtual VariantMapMap readAll(const QStringList &groups) = 0; 0033 virtual QVariant read(const QString &group, const QString &key) = 0; 0034 Q_SIGNAL void settingChanged(const QString &group, const QString &key, const QDBusVariant &value); 0035 }; 0036 0037 class SettingsPortal : public QDBusAbstractAdaptor 0038 { 0039 Q_OBJECT 0040 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.impl.portal.Settings") 0041 Q_PROPERTY(uint version READ version CONSTANT) 0042 public: 0043 explicit SettingsPortal(DesktopPortal *parent); 0044 0045 uint version() const 0046 { 0047 return 1; 0048 } 0049 0050 public Q_SLOTS: 0051 void ReadAll(const QStringList &groups); 0052 void Read(const QString &group, const QString &key); 0053 0054 Q_SIGNALS: 0055 void SettingChanged(const QString &group, const QString &key, const QDBusVariant &value); 0056 0057 private: 0058 DesktopPortal *const m_parent; 0059 std::vector<std::unique_ptr<SettingsModule>> m_settings; 0060 }; 0061 0062 #endif // XDG_DESKTOP_PORTAL_KDE_SETTINGS_H