File indexing completed on 2024-11-17 05:01:38
0001 /* This file is part of the KDE libraries 0002 SPDX-FileCopyrightText: 2013 Alejandro Fiestas Olivares <afiestas@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef KHINTS_SETTINGS_H 0008 #define KHINTS_SETTINGS_H 0009 0010 #include <QDBusVariant> 0011 #include <QObject> 0012 #include <QVariant> 0013 0014 #include <ksharedconfig.h> 0015 #include <qpa/qplatformtheme.h> 0016 0017 class KConfigGroup; 0018 0019 class QPalette; 0020 class KHintsSettings : public QObject 0021 { 0022 Q_OBJECT 0023 public: 0024 /** 0025 * An identifier for change signals. 0026 * @note Copied from KGlobalSettings 0027 */ 0028 enum ChangeType { 0029 PaletteChanged = 0, 0030 FontChanged, 0031 StyleChanged, 0032 SettingsChanged, 0033 IconChanged, 0034 CursorChanged, 0035 ToolbarStyleChanged, 0036 ClipboardConfigChanged, 0037 BlockShortcuts, 0038 NaturalSortingChanged, 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 explicit KHintsSettings(const KSharedConfig::Ptr &kdeglobals = KSharedConfig::Ptr()); 0055 ~KHintsSettings() override; 0056 0057 inline QVariant hint(QPlatformTheme::ThemeHint hint) const 0058 { 0059 return m_hints[hint]; 0060 } 0061 0062 inline QPalette *palette(QPlatformTheme::Palette type) const 0063 { 0064 return m_palettes[type]; 0065 } 0066 QStringList xdgIconThemePaths() const; 0067 0068 private Q_SLOTS: 0069 void delayedDBusConnects(); 0070 void setupIconLoader(); 0071 void toolbarStyleChanged(); 0072 void slotNotifyChange(int type, int arg); 0073 void slotPortalSettingChanged(const QString &group, const QString &key, const QDBusVariant &value); 0074 0075 private: 0076 QVariant readConfigValue(const QString &group, const QString &key, const QVariant &defaultValue); 0077 QVariant readConfigValue(const KConfigGroup &cg, const QString &key, const QVariant &defaultValue) const; 0078 void loadPalettes(); 0079 void iconChanged(int group); 0080 void updateQtSettings(KConfigGroup &cg); 0081 void updateShowIconsInMenuItems(KConfigGroup &cg); 0082 Qt::ToolButtonStyle toolButtonStyle(const KConfigGroup &cg); 0083 void updateCursorTheme(); 0084 void updateX11CursorTheme(); 0085 void updatePortalSetting(); 0086 0087 QHash<QPlatformTheme::Palette, QPalette *> m_palettes; 0088 QHash<QPlatformTheme::ThemeHint, QVariant> m_hints; 0089 KSharedConfigPtr mKdeGlobals; 0090 QMap<QString, QVariantMap> mKdeGlobalsPortal; 0091 bool mUsePortal; 0092 }; 0093 0094 #endif // KHINTS_SETTINGS_H