Changeset View
Changeset View
Standalone View
Standalone View
kcms/style/kcmstyle.h
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * KCMStyle | 2 | * KCMStyle | ||
3 | * Copyright (C) 2002 Karol Szwed <gallium@kde.org> | 3 | * Copyright (C) 2002 Karol Szwed <gallium@kde.org> | ||
4 | * Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org> | 4 | * Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org> | ||
5 | * Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org> | 5 | * Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org> | ||
6 | * Copyright (C) 2019 Kai Uwe Broulik <kde@broulik.de> | ||||
6 | * | 7 | * | ||
7 | * Portions Copyright (C) TrollTech AS. | 8 | * Portions Copyright (C) TrollTech AS. | ||
8 | * | 9 | * | ||
9 | * Based on kcmdisplay | 10 | * Based on kcmdisplay | ||
10 | * Copyright (C) 1997-2002 kcmdisplay Authors. | 11 | * Copyright (C) 1997-2002 kcmdisplay Authors. | ||
11 | * (see Help -> About Style Settings) | 12 | * (see Help -> About Style Settings) | ||
12 | * | 13 | * | ||
13 | * This program is free software; you can redistribute it and/or | 14 | * This program is free software; you can redistribute it and/or | ||
Show All 9 Lines | |||||
23 | * along with this program; see the file COPYING. If not, write to | 24 | * along with this program; see the file COPYING. If not, write to | ||
24 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
25 | * Boston, MA 02110-1301, USA. | 26 | * Boston, MA 02110-1301, USA. | ||
26 | */ | 27 | */ | ||
27 | 28 | | |||
28 | #ifndef KCMSTYLE_H | 29 | #ifndef KCMSTYLE_H | ||
29 | #define KCMSTYLE_H | 30 | #define KCMSTYLE_H | ||
30 | 31 | | |||
31 | #include <QHash> | 32 | #include <QPointer> | ||
32 | #include <QLayout> | 33 | | ||
33 | #include <QMap> | 34 | #include <KQuickAddons/ConfigModule> | ||
34 | 35 | | |||
35 | #include <kcmodule.h> | 36 | class QQuickItem; | ||
36 | | ||||
37 | class KConfig; | | |||
38 | class StylePreview; | | |||
39 | class StyleConfig; | | |||
40 | | ||||
41 | struct StyleEntry { | | |||
42 | QString name; | | |||
43 | QString desc; | | |||
44 | QString configPage; | | |||
45 | bool hidden; | | |||
46 | }; | | |||
47 | 37 | | |||
48 | class KCMStyle : public KCModule | 38 | class StylesModel; | ||
39 | class StyleConfigDialog; | ||||
40 | | ||||
41 | class KCMStyle : public KQuickAddons::ConfigModule | ||||
49 | { | 42 | { | ||
50 | Q_OBJECT | 43 | Q_OBJECT | ||
51 | 44 | | |||
45 | Q_PROPERTY(StylesModel *model READ model CONSTANT) | ||||
46 | | ||||
47 | Q_PROPERTY(bool iconsOnButtons READ iconsOnButtons WRITE setIconsOnButtons NOTIFY iconsOnButtonsChanged) | ||||
48 | Q_PROPERTY(bool iconsInMenus READ iconsInMenus WRITE setIconsInMenus NOTIFY iconsInMenusChanged) | ||||
49 | Q_PROPERTY(ToolBarStyle mainToolBarStyle READ mainToolBarStyle WRITE setMainToolBarStyle NOTIFY mainToolBarStyleChanged) | ||||
50 | Q_PROPERTY(ToolBarStyle otherToolBarStyle READ otherToolBarStyle WRITE setOtherToolBarStyle NOTIFY otherToolBarStyleChanged) | ||||
51 | | ||||
52 | public: | 52 | public: | ||
53 | KCMStyle( QWidget* parent, const QVariantList& ); | 53 | KCMStyle(QObject *parent, const QVariantList &args); | ||
54 | ~KCMStyle() override; | 54 | ~KCMStyle() override; | ||
55 | 55 | | |||
56 | enum ToolBarStyle { | ||||
57 | NoText, | ||||
58 | TextOnly, | ||||
59 | TextBesideIcon, | ||||
60 | TextUnderIcon | ||||
61 | }; | ||||
62 | Q_ENUM(ToolBarStyle) | ||||
63 | | ||||
64 | StylesModel *model() const; | ||||
65 | | ||||
66 | bool iconsOnButtons() const; | ||||
67 | void setIconsOnButtons(bool enable); | ||||
68 | Q_SIGNAL void iconsOnButtonsChanged(); | ||||
69 | | ||||
70 | bool iconsInMenus() const; | ||||
71 | void setIconsInMenus(bool enable); | ||||
72 | Q_SIGNAL void iconsInMenusChanged(); | ||||
73 | | ||||
74 | ToolBarStyle mainToolBarStyle() const; | ||||
75 | void setMainToolBarStyle(ToolBarStyle style); | ||||
76 | Q_SIGNAL void mainToolBarStyleChanged(); | ||||
77 | | ||||
78 | ToolBarStyle otherToolBarStyle() const; | ||||
79 | void setOtherToolBarStyle(ToolBarStyle style); | ||||
80 | Q_SIGNAL void otherToolBarStyleChanged(); | ||||
81 | | ||||
82 | Q_INVOKABLE void configure(const QString &styleName, QQuickItem *ctx = nullptr); | ||||
83 | | ||||
56 | void load() override; | 84 | void load() override; | ||
57 | void save() override; | 85 | void save() override; | ||
58 | void defaults() override; | 86 | void defaults() override; | ||
59 | 87 | | |||
60 | static QString defaultStyle(); | 88 | static QString defaultStyle(); | ||
61 | 89 | | |||
62 | protected: | 90 | Q_SIGNALS: | ||
63 | bool findStyle( const QString& str, int& combobox_item ); | 91 | void showErrorMessage(const QString &message); | ||
64 | void switchStyle(const QString& styleName, bool force = false); | | |||
65 | void setStyleRecursive(QWidget* w, QStyle* s); | | |||
66 | | ||||
67 | void loadStyle( KConfig& config ); | | |||
68 | void loadEffects( KConfig& config ); | | |||
69 | void addWhatsThis(); | | |||
70 | 92 | | |||
71 | void changeEvent( QEvent *event ) override; | 93 | void styleReconfigured(const QString &styleName); | ||
72 | 94 | | |||
73 | protected Q_SLOTS: | 95 | private: | ||
74 | void styleSpecificConfig(); | 96 | StylesModel *m_model; | ||
75 | void updateConfigButton(); | | |||
76 | 97 | | |||
77 | void setStyleDirty(); | 98 | bool m_selectedStyleDirty = false; | ||
78 | void setEffectsDirty(); | 99 | bool m_effectsDirty = false; | ||
79 | 100 | | |||
80 | void styleChanged(); | 101 | bool m_iconsOnButtons = false; | ||
102 | bool m_iconsInMenus = false; | ||||
103 | ToolBarStyle m_mainToolBarStyle = NoText; | ||||
104 | ToolBarStyle m_otherToolBarStyle = NoText; | ||||
81 | 105 | | |||
82 | private: | 106 | QPointer<StyleConfigDialog> m_styleConfigDialog; | ||
83 | QString currentStyle(); | | |||
84 | static QString toolbarButtonText(int index); | | |||
85 | static int toolbarButtonIndex(const QString &text); | | |||
86 | static QString menuBarStyleText(int index); | | |||
87 | static int menuBarStyleIndex(const QString &text); | | |||
88 | | ||||
89 | bool m_bStyleDirty, m_bEffectsDirty; | | |||
90 | QHash <QString,StyleEntry*> styleEntries; | | |||
91 | QMap <QString,QString> nameToStyleKey; | | |||
92 | | ||||
93 | QVBoxLayout* mainLayout; | | |||
94 | | ||||
95 | // Widgets | | |||
96 | StylePreview* stylePreview; | | |||
97 | StyleConfig* styleConfig; | | |||
98 | QStyle* appliedStyle; | | |||
99 | QPalette palette; | | |||
100 | }; | 107 | }; | ||
101 | 108 | | |||
102 | #endif // __KCMSTYLE_H | 109 | #endif // __KCMSTYLE_H | ||
103 | 110 | | |||
104 | // vim: set noet ts=4: | 111 | // vim: set noet ts=4: |