File indexing completed on 2024-04-28 16:55:48

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 <KConfigCore/KSharedConfig>
0016 
0017 class SettingsPortal : public QDBusAbstractAdaptor
0018 {
0019     Q_OBJECT
0020     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.impl.portal.Settings")
0021     Q_PROPERTY(uint version READ version CONSTANT)
0022 public:
0023     /**
0024      * An identifier for change signals.
0025      * @note Copied from KGlobalSettings
0026      */
0027     enum ChangeType {
0028         PaletteChanged = 0,
0029         FontChanged,
0030         StyleChanged,
0031         SettingsChanged,
0032         IconChanged,
0033         CursorChanged,
0034         ToolbarStyleChanged,
0035         ClipboardConfigChanged,
0036         BlockShortcuts,
0037         NaturalSortingChanged,
0038     };
0039 
0040     /**
0041      * Valid values for the settingsChanged signal
0042      * @note Copied from KGlobalSettings
0043      */
0044     enum SettingsCategory {
0045         SETTINGS_MOUSE,
0046         SETTINGS_COMPLETION,
0047         SETTINGS_PATHS,
0048         SETTINGS_POPUPMENU,
0049         SETTINGS_QT,
0050         SETTINGS_SHORTCUTS,
0051         SETTINGS_LOCALE,
0052         SETTINGS_STYLE,
0053     };
0054 
0055     explicit SettingsPortal(QObject *parent);
0056     ~SettingsPortal() override;
0057 
0058     uint version() const
0059     {
0060         return 1;
0061     }
0062 
0063 public Q_SLOTS:
0064     void ReadAll(const QStringList &groups);
0065     void Read(const QString &group, const QString &key);
0066 
0067 Q_SIGNALS:
0068     void SettingChanged(const QString &group, const QString &key, const QDBusVariant &value);
0069 
0070 private Q_SLOTS:
0071     void fontChanged();
0072     void globalSettingChanged(int type, int arg);
0073     void toolbarStyleChanged();
0074 
0075 private:
0076     QDBusVariant readProperty(const QString &group, const QString &key);
0077 
0078     /**
0079      * Returns a list that contains redF, blueF and greenF and represents
0080      * the current accent color.
0081      * Format: (ddd)
0082      */
0083     QDBusVariant readAccentColor() const;
0084     QDBusVariant readFdoColorScheme();
0085 
0086     KSharedConfigPtr m_kdeglobals;
0087 };
0088 
0089 #endif // XDG_DESKTOP_PORTAL_KDE_SETTINGS_H