1/*
2 * SPDX-FileCopyrightText: 2017 by Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef BASICTHEME_H
8#define BASICTHEME_H
9
10#include "platformtheme.h"
11
12#include "kirigamiplatform_export.h"
13
14namespace Kirigami
15{
16namespace Platform
17{
18class BasicTheme;
19
20class KIRIGAMIPLATFORM_EXPORT BasicThemeDefinition : public QObject
21{
22 Q_OBJECT
23 QML_ELEMENT
24
25 Q_PROPERTY(QColor textColor MEMBER textColor NOTIFY changed FINAL)
26 Q_PROPERTY(QColor disabledTextColor MEMBER disabledTextColor NOTIFY changed FINAL)
27
28 Q_PROPERTY(QColor highlightColor MEMBER highlightColor NOTIFY changed FINAL)
29 Q_PROPERTY(QColor highlightedTextColor MEMBER highlightedTextColor NOTIFY changed FINAL)
30 Q_PROPERTY(QColor backgroundColor MEMBER backgroundColor NOTIFY changed FINAL)
31 Q_PROPERTY(QColor alternateBackgroundColor MEMBER alternateBackgroundColor NOTIFY changed FINAL)
32
33 Q_PROPERTY(QColor focusColor MEMBER focusColor NOTIFY changed FINAL)
34 Q_PROPERTY(QColor hoverColor MEMBER hoverColor NOTIFY changed FINAL)
35
36 Q_PROPERTY(QColor activeTextColor MEMBER activeTextColor NOTIFY changed FINAL)
37 Q_PROPERTY(QColor activeBackgroundColor MEMBER activeBackgroundColor NOTIFY changed FINAL)
38 Q_PROPERTY(QColor linkColor MEMBER linkColor NOTIFY changed FINAL)
39 Q_PROPERTY(QColor linkBackgroundColor MEMBER linkBackgroundColor NOTIFY changed FINAL)
40 Q_PROPERTY(QColor visitedLinkColor MEMBER visitedLinkColor NOTIFY changed FINAL)
41 Q_PROPERTY(QColor visitedLinkBackgroundColor MEMBER visitedLinkBackgroundColor NOTIFY changed FINAL)
42 Q_PROPERTY(QColor negativeTextColor MEMBER negativeTextColor NOTIFY changed FINAL)
43 Q_PROPERTY(QColor negativeBackgroundColor MEMBER negativeBackgroundColor NOTIFY changed FINAL)
44 Q_PROPERTY(QColor neutralTextColor MEMBER neutralTextColor NOTIFY changed FINAL)
45 Q_PROPERTY(QColor neutralBackgroundColor MEMBER neutralBackgroundColor NOTIFY changed FINAL)
46 Q_PROPERTY(QColor positiveTextColor MEMBER positiveTextColor NOTIFY changed FINAL)
47 Q_PROPERTY(QColor positiveBackgroundColor MEMBER positiveBackgroundColor NOTIFY changed FINAL)
48
49 Q_PROPERTY(QColor buttonTextColor MEMBER buttonTextColor NOTIFY changed FINAL)
50 Q_PROPERTY(QColor buttonBackgroundColor MEMBER buttonBackgroundColor NOTIFY changed FINAL)
51 Q_PROPERTY(QColor buttonAlternateBackgroundColor MEMBER buttonAlternateBackgroundColor NOTIFY changed FINAL)
52 Q_PROPERTY(QColor buttonHoverColor MEMBER buttonHoverColor NOTIFY changed FINAL)
53 Q_PROPERTY(QColor buttonFocusColor MEMBER buttonFocusColor NOTIFY changed FINAL)
54
55 Q_PROPERTY(QColor viewTextColor MEMBER viewTextColor NOTIFY changed FINAL)
56 Q_PROPERTY(QColor viewBackgroundColor MEMBER viewBackgroundColor NOTIFY changed FINAL)
57 Q_PROPERTY(QColor viewAlternateBackgroundColor MEMBER viewAlternateBackgroundColor NOTIFY changed FINAL)
58 Q_PROPERTY(QColor viewHoverColor MEMBER viewHoverColor NOTIFY changed FINAL)
59 Q_PROPERTY(QColor viewFocusColor MEMBER viewFocusColor NOTIFY changed FINAL)
60
61 Q_PROPERTY(QColor selectionTextColor MEMBER selectionTextColor NOTIFY changed FINAL)
62 Q_PROPERTY(QColor selectionBackgroundColor MEMBER selectionBackgroundColor NOTIFY changed FINAL)
63 Q_PROPERTY(QColor selectionAlternateBackgroundColor MEMBER selectionAlternateBackgroundColor NOTIFY changed FINAL)
64 Q_PROPERTY(QColor selectionHoverColor MEMBER selectionHoverColor NOTIFY changed FINAL)
65 Q_PROPERTY(QColor selectionFocusColor MEMBER selectionFocusColor NOTIFY changed FINAL)
66
67 Q_PROPERTY(QColor tooltipTextColor MEMBER tooltipTextColor NOTIFY changed FINAL)
68 Q_PROPERTY(QColor tooltipBackgroundColor MEMBER tooltipBackgroundColor NOTIFY changed FINAL)
69 Q_PROPERTY(QColor tooltipAlternateBackgroundColor MEMBER tooltipAlternateBackgroundColor NOTIFY changed FINAL)
70 Q_PROPERTY(QColor tooltipHoverColor MEMBER tooltipHoverColor NOTIFY changed FINAL)
71 Q_PROPERTY(QColor tooltipFocusColor MEMBER tooltipFocusColor NOTIFY changed FINAL)
72
73 Q_PROPERTY(QColor complementaryTextColor MEMBER complementaryTextColor NOTIFY changed FINAL)
74 Q_PROPERTY(QColor complementaryBackgroundColor MEMBER complementaryBackgroundColor NOTIFY changed FINAL)
75 Q_PROPERTY(QColor complementaryAlternateBackgroundColor MEMBER complementaryAlternateBackgroundColor NOTIFY changed FINAL)
76 Q_PROPERTY(QColor complementaryHoverColor MEMBER complementaryHoverColor NOTIFY changed FINAL)
77 Q_PROPERTY(QColor complementaryFocusColor MEMBER complementaryFocusColor NOTIFY changed FINAL)
78
79 Q_PROPERTY(QColor headerTextColor MEMBER headerTextColor NOTIFY changed FINAL)
80 Q_PROPERTY(QColor headerBackgroundColor MEMBER headerBackgroundColor NOTIFY changed FINAL)
81 Q_PROPERTY(QColor headerAlternateBackgroundColor MEMBER headerAlternateBackgroundColor NOTIFY changed FINAL)
82 Q_PROPERTY(QColor headerHoverColor MEMBER headerHoverColor NOTIFY changed FINAL)
83 Q_PROPERTY(QColor headerFocusColor MEMBER headerFocusColor NOTIFY changed FINAL)
84
85 Q_PROPERTY(QFont defaultFont MEMBER defaultFont NOTIFY changed FINAL)
86 Q_PROPERTY(QFont smallFont MEMBER smallFont NOTIFY changed FINAL)
87
88public:
89 explicit BasicThemeDefinition(QObject *parent = nullptr);
90
91 virtual void syncToQml(PlatformTheme *object);
92
93 QColor textColor{0x31363b};
94 QColor disabledTextColor{0x31, 0x36, 0x3b, 0x99};
95
96 QColor highlightColor{0x2196F3};
97 QColor highlightedTextColor{0xeff0fa};
98 QColor backgroundColor{0xeff0f1};
99 QColor alternateBackgroundColor{0xbdc3c7};
100
101 QColor focusColor{0x2196F3};
102 QColor hoverColor{0x2196F3};
103
104 QColor activeTextColor{0x0176D3};
105 QColor activeBackgroundColor{0x0176D3};
106 QColor linkColor{0x2196F3};
107 QColor linkBackgroundColor{0x2196F3};
108 QColor visitedLinkColor{0x2196F3};
109 QColor visitedLinkBackgroundColor{0x2196F3};
110 QColor negativeTextColor{0xDA4453};
111 QColor negativeBackgroundColor{0xDA4453};
112 QColor neutralTextColor{0xF67400};
113 QColor neutralBackgroundColor{0xF67400};
114 QColor positiveTextColor{0x27AE60};
115 QColor positiveBackgroundColor{0x27AE60};
116
117 QColor buttonTextColor{0x31363b};
118 QColor buttonBackgroundColor{0xeff0f1};
119 QColor buttonAlternateBackgroundColor{0xbdc3c7};
120 QColor buttonHoverColor{0x2196F3};
121 QColor buttonFocusColor{0x2196F3};
122
123 QColor viewTextColor{0x31363b};
124 QColor viewBackgroundColor{0xfcfcfc};
125 QColor viewAlternateBackgroundColor{0xeff0f1};
126 QColor viewHoverColor{0x2196F3};
127 QColor viewFocusColor{0x2196F3};
128
129 QColor selectionTextColor{0xeff0fa};
130 QColor selectionBackgroundColor{0x2196F3};
131 QColor selectionAlternateBackgroundColor{0x1d99f3};
132 QColor selectionHoverColor{0x2196F3};
133 QColor selectionFocusColor{0x2196F3};
134
135 QColor tooltipTextColor{0xeff0f1};
136 QColor tooltipBackgroundColor{0x31363b};
137 QColor tooltipAlternateBackgroundColor{0x4d4d4d};
138 QColor tooltipHoverColor{0x2196F3};
139 QColor tooltipFocusColor{0x2196F3};
140
141 QColor complementaryTextColor{0xeff0f1};
142 QColor complementaryBackgroundColor{0x31363b};
143 QColor complementaryAlternateBackgroundColor{0x3b4045};
144 QColor complementaryHoverColor{0x2196F3};
145 QColor complementaryFocusColor{0x2196F3};
146
147 QColor headerTextColor{0x232629};
148 QColor headerBackgroundColor{0xe3e5e7};
149 QColor headerAlternateBackgroundColor{0xeff0f1};
150 QColor headerHoverColor{0x2196F3};
151 QColor headerFocusColor{0x93cee9};
152
153 QFont defaultFont;
154 QFont smallFont;
155
156 Q_SIGNAL void changed();
157 Q_SIGNAL void sync(QQuickItem *object);
158};
159
160class BasicThemeInstance : public QObject
161{
162 Q_OBJECT
163
164public:
165 explicit BasicThemeInstance(QObject *parent = nullptr);
166
167 BasicThemeDefinition &themeDefinition(QQmlEngine *engine);
168
169 QList<BasicTheme *> watchers;
170
171private:
172 void onDefinitionChanged();
173
174 std::unique_ptr<BasicThemeDefinition> m_themeDefinition;
175};
176
177class BasicTheme : public PlatformTheme
178{
179 Q_OBJECT
180
181public:
182 explicit BasicTheme(QObject *parent = nullptr);
183 ~BasicTheme() override;
184
185 void sync();
186
187protected:
188 bool event(QEvent *event) override;
189
190private:
191 QColor tint(const QColor &color);
192};
193
194}
195}
196
197#endif // BASICTHEME_H
198

source code of kirigami/src/platform/basictheme_p.h