Warning, file /plasma/plasma-workspace/kcms/lookandfeel/lookandfeelmanager.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2014 Marco Martin <mart@kde.org> 0003 SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in> 0004 SPDX-FileCopyrightText: 2019 Cyril Rossi <cyril.rossi@enioka.com> 0005 SPDX-FileCopyrightText: 2021 Benjamin Port <benjamin.port@enioka.com> 0006 SPDX-FileCopyrightText: 2022 Dominic Hayes <ferenosdev@outlook.com> 0007 0008 SPDX-License-Identifier: LGPL-2.0-only 0009 */ 0010 0011 #pragma once 0012 0013 #include <KConfig> 0014 #include <KConfigGroup> 0015 #include <KPackage/Package> 0016 #include <KService> 0017 #include <QDir> 0018 #include <QObject> 0019 0020 class LookAndFeelData; 0021 class LookAndFeelSettings; 0022 0023 class LookAndFeelManager : public QObject 0024 { 0025 Q_OBJECT 0026 public: 0027 enum class Mode { 0028 Apply, // Apply the look and feel theme, i.e. change the active settings and set them up as new defaults. This is the default. 0029 Defaults // Only set up the options of the look and feel theme as new defaults without changing any active setting 0030 }; 0031 // Flags for storing values 0032 enum AppearanceToApplyFlags { 0033 Colors = 1 << 0, 0034 WidgetStyle = 1 << 1, 0035 WindowDecoration = 1 << 2, 0036 Icons = 1 << 3, 0037 PlasmaTheme = 1 << 4, 0038 Cursors = 1 << 5, 0039 Fonts = 1 << 6, 0040 WindowSwitcher = 1 << 7, 0041 SplashScreen = 1 << 8, 0042 LockScreen = 1 << 9, 0043 AppearanceSettings = (1 << 10) - 1, // Blanket switch - sets everything 0044 }; 0045 Q_DECLARE_FLAGS(AppearanceToApply, AppearanceToApplyFlags) 0046 Q_FLAG(AppearanceToApply) 0047 Q_PROPERTY(AppearanceToApply appearanceToApply READ appearanceToApply WRITE setAppearanceToApply NOTIFY appearanceToApplyChanged) 0048 0049 enum LayoutToApplyFlags { 0050 DesktopLayout = 1 << 0, 0051 TitlebarLayout = 1 << 1, 0052 WindowPlacement = 1 << 2, // FIXME: Do we still want these three? 0053 ShellPackage = 1 << 3, 0054 DesktopSwitcher = 1 << 4, 0055 LayoutSettings = (1 << 5) - 1, 0056 }; 0057 Q_DECLARE_FLAGS(LayoutToApply, LayoutToApplyFlags) 0058 Q_FLAG(LayoutToApply) 0059 Q_PROPERTY(LayoutToApply layoutToApply READ layoutToApply WRITE setLayoutToApply NOTIFY layoutToApplyChanged) 0060 0061 LookAndFeelManager(QObject *parent = nullptr); 0062 0063 void setMode(Mode mode); 0064 /** 0065 * Apply the theme represented by package, with oldPackage being the currently active package. 0066 * Effects depend upon the Mode of this object. If Mode is Defaults, oldPackage is ignored. 0067 */ 0068 void save(const KPackage::Package &package, const KPackage::Package &oldPackage); 0069 AppearanceToApply appearanceToApply() const; 0070 void setAppearanceToApply(AppearanceToApply value); 0071 LayoutToApply layoutToApply() const; 0072 void setLayoutToApply(LayoutToApply value); 0073 0074 QString colorSchemeFile(const QString &schemeName) const; 0075 0076 // Setters of the various theme pieces 0077 void setWidgetStyle(const QString &style); 0078 void setColors(const QString &scheme, const QString &colorFile); 0079 void setIcons(const QString &theme); 0080 void setPlasmaTheme(const QString &theme); 0081 void setCursorTheme(const QString theme); 0082 void setSplashScreen(const QString &theme); 0083 void setLatteLayout(const QString &filepath, const QString &name); 0084 void setLockScreen(const QString &theme); 0085 void setWindowSwitcher(const QString &theme); 0086 void setDesktopSwitcher(const QString &theme); 0087 void setWindowDecoration(const QString &library, const QString &theme, bool noPlugin); 0088 void setTitlebarLayout(const QString &leftbtns, const QString &rightbtns); 0089 void setBorderlessMaximized(const QString &value); 0090 void setWindowPlacement(const QString &value); 0091 void setShellPackage(const QString &name); 0092 0093 void setGeneralFont(const QString &font); 0094 void setFixedFont(const QString &font); 0095 void setSmallFont(const QString &font); 0096 void setSmallestReadableFont(const QString &font); 0097 void setToolbarFont(const QString &font); 0098 void setMenuFont(const QString &font); 0099 void setWindowTitleFont(const QString &font); 0100 0101 LookAndFeelSettings *settings() const; 0102 0103 Q_SIGNALS: 0104 void message(); 0105 void appearanceToApplyChanged(); 0106 void layoutToApplyChanged(); 0107 void iconsChanged(); 0108 void colorsChanged(); 0109 void styleChanged(const QString &newStyle); 0110 void cursorsChanged(const QString &newStyle); 0111 void fontsChanged(); 0112 void refreshServices(const QStringList &toStop, const KService::List &toStart); 0113 0114 private: 0115 void writeNewDefaults(const QString &filename, 0116 const QString &group, 0117 const QString &key, 0118 const QString &value, 0119 KConfig::WriteConfigFlags writeFlags = KConfig::Normal); 0120 void writeNewDefaults(KConfig &config, 0121 KConfig &configDefault, 0122 const QString &group, 0123 const QString &key, 0124 const QString &value, 0125 KConfig::WriteConfigFlags writeFlags = KConfig::Normal); 0126 void 0127 writeNewDefaults(KConfigGroup &cg, KConfigGroup &cgd, const QString &key, const QString &value, KConfig::WriteConfigFlags writeFlags = KConfig::Normal); 0128 static KConfig configDefaults(const QString &filename); 0129 0130 QStringList m_cursorSearchPaths; 0131 LookAndFeelData *const m_data; 0132 Mode m_mode = Mode::Apply; 0133 bool m_applyLatteLayout : 1; 0134 AppearanceToApply m_appearanceToApply; 0135 LayoutToApply m_layoutToApply; 0136 bool m_plasmashellChanged : 1; 0137 bool m_fontsChanged : 1; 0138 }; 0139 Q_DECLARE_OPERATORS_FOR_FLAGS(LookAndFeelManager::AppearanceToApply) 0140 Q_DECLARE_OPERATORS_FOR_FLAGS(LookAndFeelManager::LayoutToApply)