1 | // Copyright (C) 2023 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "thememanager_p.h" |
5 | #include "q3dtheme_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | const float defaultBuiltInColorLevel = 0.7f; // for built-in gradient themes |
10 | const float defaultColorLevel = 0.5f; // for built-in uniform themes |
11 | |
12 | ThemeManager::ThemeManager(Abstract3DController *controller) |
13 | : m_activeTheme(0), |
14 | m_controller(controller) |
15 | { |
16 | } |
17 | |
18 | ThemeManager::~ThemeManager() |
19 | { |
20 | } |
21 | |
22 | void ThemeManager::addTheme(Q3DTheme *theme) |
23 | { |
24 | Q_ASSERT(theme); |
25 | ThemeManager *owner = qobject_cast<ThemeManager *>(object: theme->parent()); |
26 | if (owner != this) { |
27 | Q_ASSERT_X(!owner, "addTheme" , "Theme already attached to a graph." ); |
28 | theme->setParent(this); |
29 | } |
30 | if (!m_themes.contains(t: theme)) |
31 | m_themes.append(t: theme); |
32 | } |
33 | |
34 | void ThemeManager::releaseTheme(Q3DTheme *theme) |
35 | { |
36 | if (theme && m_themes.contains(t: theme)) { |
37 | // Clear the default status from released default theme |
38 | if (theme->d_func()->isDefaultTheme()) |
39 | theme->d_func()->setDefaultTheme(false); |
40 | |
41 | // If the theme is in use, replace it with a temporary one |
42 | if (theme == m_activeTheme) |
43 | setActiveTheme(0); |
44 | |
45 | m_themes.removeAll(t: theme); |
46 | theme->setParent(0); |
47 | } |
48 | } |
49 | |
50 | void ThemeManager::setActiveTheme(Q3DTheme *theme) |
51 | { |
52 | // Setting null theme indicates using default theme |
53 | if (!theme) { |
54 | theme = new Q3DTheme; |
55 | theme->d_func()->setDefaultTheme(true); |
56 | } |
57 | |
58 | // If the old theme is default theme, delete it |
59 | Q3DTheme *oldTheme = m_activeTheme; |
60 | if (oldTheme) { |
61 | if (oldTheme->d_func()->isDefaultTheme()) { |
62 | m_themes.removeAll(t: oldTheme); |
63 | delete oldTheme; |
64 | oldTheme = 0; |
65 | } else { |
66 | // Disconnect the old theme from use |
67 | disconnect(sender: m_activeTheme->d_func(), signal: 0, receiver: m_controller, member: 0); |
68 | disconnect(sender: m_activeTheme, signal: 0, receiver: m_controller, member: 0); |
69 | } |
70 | } |
71 | |
72 | // Assume ownership |
73 | addTheme(theme); |
74 | |
75 | m_activeTheme = theme; |
76 | |
77 | // Reset all bits to dirty for sync |
78 | if (theme->d_func()->isForcePredefinedType()) |
79 | m_activeTheme->d_func()->resetDirtyBits(); |
80 | |
81 | // Connect signals from new one |
82 | connectThemeSignals(); |
83 | } |
84 | |
85 | Q3DTheme *ThemeManager::activeTheme() const |
86 | { |
87 | return m_activeTheme; |
88 | } |
89 | |
90 | QList<Q3DTheme *> ThemeManager::themes() const |
91 | { |
92 | return m_themes; |
93 | } |
94 | |
95 | void ThemeManager::connectThemeSignals() |
96 | { |
97 | connect(sender: m_activeTheme, signal: &Q3DTheme::colorStyleChanged, |
98 | context: m_controller, slot: &Abstract3DController::handleThemeColorStyleChanged); |
99 | connect(sender: m_activeTheme, signal: &Q3DTheme::baseColorsChanged, |
100 | context: m_controller, slot: &Abstract3DController::handleThemeBaseColorsChanged); |
101 | connect(sender: m_activeTheme, signal: &Q3DTheme::singleHighlightColorChanged, |
102 | context: m_controller, slot: &Abstract3DController::handleThemeSingleHighlightColorChanged); |
103 | connect(sender: m_activeTheme, signal: &Q3DTheme::multiHighlightColorChanged, |
104 | context: m_controller, slot: &Abstract3DController::handleThemeMultiHighlightColorChanged); |
105 | connect(sender: m_activeTheme, signal: &Q3DTheme::baseGradientsChanged, |
106 | context: m_controller, slot: &Abstract3DController::handleThemeBaseGradientsChanged); |
107 | connect(sender: m_activeTheme, signal: &Q3DTheme::singleHighlightGradientChanged, |
108 | context: m_controller, slot: &Abstract3DController::handleThemeSingleHighlightGradientChanged); |
109 | connect(sender: m_activeTheme, signal: &Q3DTheme::multiHighlightGradientChanged, |
110 | context: m_controller, slot: &Abstract3DController::handleThemeMultiHighlightGradientChanged); |
111 | connect(sender: m_activeTheme, signal: &Q3DTheme::typeChanged, |
112 | context: m_controller, slot: &Abstract3DController::handleThemeTypeChanged); |
113 | |
114 | connect(sender: m_activeTheme->d_func(), signal: &Q3DThemePrivate::needRender, |
115 | context: m_controller, slot: &Abstract3DController::needRender); |
116 | } |
117 | |
118 | void ThemeManager::setPredefinedPropertiesToTheme(Q3DTheme *theme, Q3DTheme::Theme type) |
119 | { |
120 | QList<QColor> baseColors; |
121 | QList<QLinearGradient> baseGradients; |
122 | switch (type) { |
123 | case Q3DTheme::ThemeQt: { |
124 | baseColors.append(t: QColor(QRgb(0x80c342))); |
125 | baseColors.append(t: QColor(QRgb(0x469835))); |
126 | baseColors.append(t: QColor(QRgb(0x006325))); |
127 | baseColors.append(t: QColor(QRgb(0x5caa15))); |
128 | baseColors.append(t: QColor(QRgb(0x328930))); |
129 | |
130 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
131 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
132 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
133 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
134 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
135 | |
136 | setBackgroundEnabled(theme, enabled: true); |
137 | setGridEnabled(theme, enabled: true); |
138 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
139 | setLabelBackgroundEnabled(theme, enabled: true); |
140 | setLightColor(theme, color: Qt::white); |
141 | setBaseColors(theme, colors: baseColors); |
142 | setBackgroundColor(theme, color: QColor(QRgb(0xffffff))); |
143 | setWindowColor(theme, color: QColor(QRgb(0xffffff))); |
144 | setTextColor(theme, color: QColor(QRgb(0x35322f))); |
145 | setTextBackgroundColor(theme, color: QColor(0xff, 0xff, 0xff, 0x99)); |
146 | setGridLineColor(theme, color: QColor(QRgb(0xd7d6d5))); |
147 | setSingleHighlightColor(theme, color: QColor(QRgb(0x14aaff))); |
148 | setMultiHighlightColor(theme, color: QColor(QRgb(0x6400aa))); |
149 | setLightStrength(theme, strength: 5.0f); |
150 | setAmbientLightStrength(theme, strength: 0.5f); |
151 | setHighlightLightStrength(theme, strength: 5.0f); |
152 | setLabelBorderEnabled(theme, enabled: true); |
153 | setLabelsEnabled(theme, enabled: true); |
154 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
155 | setBaseGradients(theme, gradients: baseGradients); |
156 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x14aaff)), |
157 | colorLevel: defaultColorLevel)); |
158 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x6400aa)), |
159 | colorLevel: defaultColorLevel)); |
160 | break; |
161 | } |
162 | |
163 | case Q3DTheme::ThemePrimaryColors: { |
164 | baseColors.append(t: QColor(QRgb(0xffe400))); |
165 | baseColors.append(t: QColor(QRgb(0xfaa106))); |
166 | baseColors.append(t: QColor(QRgb(0xf45f0d))); |
167 | baseColors.append(t: QColor(QRgb(0xfcba04))); |
168 | baseColors.append(t: QColor(QRgb(0xf7800a))); |
169 | |
170 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
171 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
172 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
173 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
174 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
175 | |
176 | setBackgroundEnabled(theme, enabled: true); |
177 | setGridEnabled(theme, enabled: true); |
178 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
179 | setLabelBackgroundEnabled(theme, enabled: true); |
180 | setLightColor(theme, color: Qt::white); |
181 | setBaseColors(theme, colors: baseColors); |
182 | setBackgroundColor(theme, color: QColor(QRgb(0xffffff))); |
183 | setWindowColor(theme, color: QColor(QRgb(0xffffff))); |
184 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
185 | setTextBackgroundColor(theme, color: QColor(0xff, 0xff, 0xff, 0x99)); |
186 | setGridLineColor(theme, color: QColor(QRgb(0xd7d6d5))); |
187 | setSingleHighlightColor(theme, color: QColor(QRgb(0x27beee))); |
188 | setMultiHighlightColor(theme, color: QColor(QRgb(0xee1414))); |
189 | setLightStrength(theme, strength: 5.0f); |
190 | setAmbientLightStrength(theme, strength: 0.5f); |
191 | setHighlightLightStrength(theme, strength: 5.0f); |
192 | setLabelBorderEnabled(theme, enabled: false); |
193 | setLabelsEnabled(theme, enabled: true); |
194 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
195 | setBaseGradients(theme, gradients: baseGradients); |
196 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x27beee)), |
197 | colorLevel: defaultColorLevel)); |
198 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xee1414)), |
199 | colorLevel: defaultColorLevel)); |
200 | break; |
201 | } |
202 | |
203 | case Q3DTheme::ThemeDigia: { |
204 | baseColors.append(t: QColor(QRgb(0xeaeaea))); |
205 | baseColors.append(t: QColor(QRgb(0xa0a0a0))); |
206 | baseColors.append(t: QColor(QRgb(0x626262))); |
207 | baseColors.append(t: QColor(QRgb(0xbebebe))); |
208 | baseColors.append(t: QColor(QRgb(0x818181))); |
209 | |
210 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultBuiltInColorLevel)); |
211 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultBuiltInColorLevel)); |
212 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultBuiltInColorLevel)); |
213 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultBuiltInColorLevel)); |
214 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultBuiltInColorLevel)); |
215 | |
216 | setBackgroundEnabled(theme, enabled: true); |
217 | setGridEnabled(theme, enabled: true); |
218 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
219 | setLabelBackgroundEnabled(theme, enabled: true); |
220 | setLightColor(theme, color: Qt::white); |
221 | setBaseColors(theme, colors: baseColors); |
222 | setBackgroundColor(theme, color: QColor(QRgb(0xffffff))); |
223 | setWindowColor(theme, color: QColor(QRgb(0xffffff))); |
224 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
225 | setTextBackgroundColor(theme, color: QColor(0xff, 0xff, 0xff, 0x80)); |
226 | setGridLineColor(theme, color: QColor(QRgb(0xd7d6d5))); |
227 | setSingleHighlightColor(theme, color: QColor(QRgb(0xfa0000))); |
228 | setMultiHighlightColor(theme, color: QColor(QRgb(0x333333))); |
229 | setLightStrength(theme, strength: 5.0f); |
230 | setAmbientLightStrength(theme, strength: 0.5f); |
231 | setHighlightLightStrength(theme, strength: 5.0f); |
232 | setLabelBorderEnabled(theme, enabled: false); |
233 | setLabelsEnabled(theme, enabled: true); |
234 | setColorStyle(theme, style: Q3DTheme::ColorStyleObjectGradient); |
235 | setBaseGradients(theme, gradients: baseGradients); |
236 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xfa0000)), |
237 | colorLevel: defaultBuiltInColorLevel)); |
238 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x333333)), |
239 | colorLevel: defaultBuiltInColorLevel)); |
240 | break; |
241 | } |
242 | |
243 | case Q3DTheme::ThemeStoneMoss: { |
244 | baseColors.append(t: QColor(QRgb(0xbeb32b))); |
245 | baseColors.append(t: QColor(QRgb(0x928327))); |
246 | baseColors.append(t: QColor(QRgb(0x665423))); |
247 | baseColors.append(t: QColor(QRgb(0xa69929))); |
248 | baseColors.append(t: QColor(QRgb(0x7c6c25))); |
249 | |
250 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
251 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
252 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
253 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
254 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
255 | |
256 | setBackgroundEnabled(theme, enabled: true); |
257 | setGridEnabled(theme, enabled: true); |
258 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
259 | setLabelBackgroundEnabled(theme, enabled: true); |
260 | setLightColor(theme, color: Qt::white); |
261 | setBaseColors(theme, colors: baseColors); |
262 | setBackgroundColor(theme, color: QColor(QRgb(0x4d4d4f))); |
263 | setWindowColor(theme, color: QColor(QRgb(0x4d4d4f))); |
264 | setTextColor(theme, color: QColor(QRgb(0xffffff))); |
265 | setTextBackgroundColor(theme, color: QColor(0x4d, 0x4d, 0x4f, 0xcd)); |
266 | setGridLineColor(theme, color: QColor(QRgb(0x3e3e40))); |
267 | setSingleHighlightColor(theme, color: QColor(QRgb(0xfbf6d6))); |
268 | setMultiHighlightColor(theme, color: QColor(QRgb(0x442f20))); |
269 | setLightStrength(theme, strength: 5.0f); |
270 | setAmbientLightStrength(theme, strength: 0.5f); |
271 | setHighlightLightStrength(theme, strength: 5.0f); |
272 | setLabelBorderEnabled(theme, enabled: true); |
273 | setLabelsEnabled(theme, enabled: true); |
274 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
275 | setBaseGradients(theme, gradients: baseGradients); |
276 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xfbf6d6)), |
277 | colorLevel: defaultColorLevel)); |
278 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x442f20)), |
279 | colorLevel: defaultColorLevel)); |
280 | break; |
281 | } |
282 | |
283 | case Q3DTheme::ThemeArmyBlue: { |
284 | baseColors.append(t: QColor(QRgb(0x495f76))); |
285 | baseColors.append(t: QColor(QRgb(0x81909f))); |
286 | baseColors.append(t: QColor(QRgb(0xbec5cd))); |
287 | baseColors.append(t: QColor(QRgb(0x687a8d))); |
288 | baseColors.append(t: QColor(QRgb(0xa3aeb9))); |
289 | |
290 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultBuiltInColorLevel)); |
291 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultBuiltInColorLevel)); |
292 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultBuiltInColorLevel)); |
293 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultBuiltInColorLevel)); |
294 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultBuiltInColorLevel)); |
295 | |
296 | setBackgroundEnabled(theme, enabled: true); |
297 | setGridEnabled(theme, enabled: true); |
298 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
299 | setLabelBackgroundEnabled(theme, enabled: true); |
300 | setLightColor(theme, color: Qt::white); |
301 | setBaseColors(theme, colors: baseColors); |
302 | setBackgroundColor(theme, color: QColor(QRgb(0xd5d6d7))); |
303 | setWindowColor(theme, color: QColor(QRgb(0xd5d6d7))); |
304 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
305 | setTextBackgroundColor(theme, color: QColor(0xd5, 0xd6, 0xd7, 0xcd)); |
306 | setGridLineColor(theme, color: QColor(QRgb(0xaeadac))); |
307 | setSingleHighlightColor(theme, color: QColor(QRgb(0x2aa2f9))); |
308 | setMultiHighlightColor(theme, color: QColor(QRgb(0x103753))); |
309 | setLightStrength(theme, strength: 5.0f); |
310 | setAmbientLightStrength(theme, strength: 0.5f); |
311 | setHighlightLightStrength(theme, strength: 5.0f); |
312 | setLabelBorderEnabled(theme, enabled: false); |
313 | setLabelsEnabled(theme, enabled: true); |
314 | setColorStyle(theme, style: Q3DTheme::ColorStyleObjectGradient); |
315 | setBaseGradients(theme, gradients: baseGradients); |
316 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x2aa2f9)), |
317 | colorLevel: defaultBuiltInColorLevel)); |
318 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x103753)), |
319 | colorLevel: defaultBuiltInColorLevel)); |
320 | break; |
321 | } |
322 | |
323 | case Q3DTheme::ThemeRetro: { |
324 | baseColors.append(t: QColor(QRgb(0x533b23))); |
325 | baseColors.append(t: QColor(QRgb(0x83715a))); |
326 | baseColors.append(t: QColor(QRgb(0xb3a690))); |
327 | baseColors.append(t: QColor(QRgb(0x6b563e))); |
328 | baseColors.append(t: QColor(QRgb(0x9b8b75))); |
329 | |
330 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultBuiltInColorLevel)); |
331 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultBuiltInColorLevel)); |
332 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultBuiltInColorLevel)); |
333 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultBuiltInColorLevel)); |
334 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultBuiltInColorLevel)); |
335 | |
336 | setBackgroundEnabled(theme, enabled: true); |
337 | setGridEnabled(theme, enabled: true); |
338 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
339 | setLabelBackgroundEnabled(theme, enabled: true); |
340 | setLightColor(theme, color: Qt::white); |
341 | setBaseColors(theme, colors: baseColors); |
342 | setBackgroundColor(theme, color: QColor(QRgb(0xe9e2ce))); |
343 | setWindowColor(theme, color: QColor(QRgb(0xe9e2ce))); |
344 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
345 | setTextBackgroundColor(theme, color: QColor(0xe9, 0xe2, 0xce, 0xc0)); |
346 | setGridLineColor(theme, color: QColor(QRgb(0xd0c0b0))); |
347 | setSingleHighlightColor(theme, color: QColor(QRgb(0x8ea317))); |
348 | setMultiHighlightColor(theme, color: QColor(QRgb(0xc25708))); |
349 | setLightStrength(theme, strength: 5.0f); |
350 | setAmbientLightStrength(theme, strength: 0.5f); |
351 | setHighlightLightStrength(theme, strength: 5.0f); |
352 | setLabelBorderEnabled(theme, enabled: false); |
353 | setLabelsEnabled(theme, enabled: true); |
354 | setColorStyle(theme, style: Q3DTheme::ColorStyleObjectGradient); |
355 | setBaseGradients(theme, gradients: baseGradients); |
356 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x8ea317)), |
357 | colorLevel: defaultBuiltInColorLevel)); |
358 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xc25708)), |
359 | colorLevel: defaultBuiltInColorLevel)); |
360 | break; |
361 | } |
362 | |
363 | case Q3DTheme::ThemeEbony: { |
364 | baseColors.append(t: QColor(QRgb(0xffffff))); |
365 | baseColors.append(t: QColor(QRgb(0x999999))); |
366 | baseColors.append(t: QColor(QRgb(0x474747))); |
367 | baseColors.append(t: QColor(QRgb(0xc7c7c7))); |
368 | baseColors.append(t: QColor(QRgb(0x6b6b6b))); |
369 | |
370 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
371 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
372 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
373 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
374 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
375 | |
376 | setBackgroundEnabled(theme, enabled: true); |
377 | setGridEnabled(theme, enabled: true); |
378 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
379 | setLabelBackgroundEnabled(theme, enabled: true); |
380 | setLightColor(theme, color: Qt::white); |
381 | setBaseColors(theme, colors: baseColors); |
382 | setBackgroundColor(theme, color: QColor(QRgb(0x000000))); |
383 | setWindowColor(theme, color: QColor(QRgb(0x000000))); |
384 | setTextColor(theme, color: QColor(QRgb(0xaeadac))); |
385 | setTextBackgroundColor(theme, color: QColor(0x00, 0x00, 0x00, 0xcd)); |
386 | setGridLineColor(theme, color: QColor(QRgb(0x35322f))); |
387 | setSingleHighlightColor(theme, color: QColor(QRgb(0xf5dc0d))); |
388 | setMultiHighlightColor(theme, color: QColor(QRgb(0xd72222))); |
389 | setLightStrength(theme, strength: 5.0f); |
390 | setAmbientLightStrength(theme, strength: 0.5f); |
391 | setHighlightLightStrength(theme, strength: 5.0f); |
392 | setLabelBorderEnabled(theme, enabled: false); |
393 | setLabelsEnabled(theme, enabled: true); |
394 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
395 | setBaseGradients(theme, gradients: baseGradients); |
396 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xf5dc0d)), |
397 | colorLevel: defaultColorLevel)); |
398 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xd72222)), |
399 | colorLevel: defaultColorLevel)); |
400 | break; |
401 | } |
402 | |
403 | case Q3DTheme::ThemeIsabelle: { |
404 | baseColors.append(t: QColor(QRgb(0xf9d900))); |
405 | baseColors.append(t: QColor(QRgb(0xf09603))); |
406 | baseColors.append(t: QColor(QRgb(0xe85506))); |
407 | baseColors.append(t: QColor(QRgb(0xf5b802))); |
408 | baseColors.append(t: QColor(QRgb(0xec7605))); |
409 | |
410 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
411 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
412 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
413 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
414 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
415 | |
416 | setBackgroundEnabled(theme, enabled: true); |
417 | setGridEnabled(theme, enabled: true); |
418 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
419 | setLabelBackgroundEnabled(theme, enabled: true); |
420 | setLightColor(theme, color: Qt::white); |
421 | setBaseColors(theme, colors: baseColors); |
422 | setBackgroundColor(theme, color: QColor(QRgb(0x000000))); |
423 | setWindowColor(theme, color: QColor(QRgb(0x000000))); |
424 | setTextColor(theme, color: QColor(QRgb(0xaeadac))); |
425 | setTextBackgroundColor(theme, color: QColor(0x00, 0x00, 0x00, 0xc0)); |
426 | setGridLineColor(theme, color: QColor(QRgb(0x35322f))); |
427 | setSingleHighlightColor(theme, color: QColor(QRgb(0xfff7cc))); |
428 | setMultiHighlightColor(theme, color: QColor(QRgb(0xde0a0a))); |
429 | setLightStrength(theme, strength: 5.0f); |
430 | setAmbientLightStrength(theme, strength: 0.5f); |
431 | setHighlightLightStrength(theme, strength: 5.0f); |
432 | setLabelBorderEnabled(theme, enabled: false); |
433 | setLabelsEnabled(theme, enabled: true); |
434 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
435 | setBaseGradients(theme, gradients: baseGradients); |
436 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xfff7cc)), |
437 | colorLevel: defaultColorLevel)); |
438 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xde0a0a)), |
439 | colorLevel: defaultColorLevel)); |
440 | break; |
441 | } |
442 | default: |
443 | break; |
444 | } |
445 | } |
446 | |
447 | QLinearGradient ThemeManager::createGradient(const QColor &color, float colorLevel) |
448 | { |
449 | QColor startColor; |
450 | QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth), |
451 | qreal(gradientTextureHeight), |
452 | 0.0, 0.0);; |
453 | startColor.setRed(color.red() * colorLevel); |
454 | startColor.setGreen(color.green() * colorLevel); |
455 | startColor.setBlue(color.blue() * colorLevel); |
456 | gradient.setColorAt(pos: 0.0, color: startColor); |
457 | gradient.setColorAt(pos: 1.0, color); |
458 | return gradient; |
459 | } |
460 | |
461 | void ThemeManager::setBaseColors(Q3DTheme *theme, const QList<QColor> &colors) |
462 | { |
463 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.baseColorDirty) |
464 | theme->setBaseColors(colors); |
465 | } |
466 | |
467 | void ThemeManager::setBackgroundColor(Q3DTheme *theme, const QColor &color) |
468 | { |
469 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.backgroundColorDirty) |
470 | theme->setBackgroundColor(color); |
471 | } |
472 | |
473 | void ThemeManager::setWindowColor(Q3DTheme *theme, const QColor &color) |
474 | { |
475 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.windowColorDirty) |
476 | theme->setWindowColor(color); |
477 | } |
478 | |
479 | void ThemeManager::setTextColor(Q3DTheme *theme, const QColor &color) |
480 | { |
481 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.labelTextColorDirty) |
482 | theme->setLabelTextColor(color); |
483 | } |
484 | |
485 | void ThemeManager::setTextBackgroundColor(Q3DTheme *theme, const QColor &color) |
486 | { |
487 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.labelBackgroundColorDirty) |
488 | theme->setLabelBackgroundColor(color); |
489 | } |
490 | |
491 | void ThemeManager::setGridLineColor(Q3DTheme *theme, const QColor &color) |
492 | { |
493 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.gridLineColorDirty) |
494 | theme->setGridLineColor(color); |
495 | } |
496 | |
497 | void ThemeManager::setSingleHighlightColor(Q3DTheme *theme, const QColor &color) |
498 | { |
499 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.singleHighlightColorDirty) |
500 | theme->setSingleHighlightColor(color); |
501 | } |
502 | |
503 | void ThemeManager::setMultiHighlightColor(Q3DTheme *theme, const QColor &color) |
504 | { |
505 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.multiHighlightColorDirty) |
506 | theme->setMultiHighlightColor(color); |
507 | } |
508 | |
509 | void ThemeManager::setLightColor(Q3DTheme *theme, const QColor &color) |
510 | { |
511 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.lightColorDirty) |
512 | theme->setLightColor(color); |
513 | } |
514 | |
515 | void ThemeManager::setBaseGradients(Q3DTheme *theme, const QList<QLinearGradient> &gradients) |
516 | { |
517 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.baseGradientDirty) |
518 | theme->setBaseGradients(gradients); |
519 | } |
520 | |
521 | void ThemeManager::setSingleHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient) |
522 | { |
523 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.singleHighlightGradientDirty) |
524 | theme->setSingleHighlightGradient(gradient); |
525 | } |
526 | |
527 | void ThemeManager::setMultiHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient) |
528 | { |
529 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.multiHighlightGradientDirty) |
530 | theme->setMultiHighlightGradient(gradient); |
531 | } |
532 | |
533 | void ThemeManager::setLightStrength(Q3DTheme *theme, float strength) |
534 | { |
535 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.lightStrengthDirty) |
536 | theme->setLightStrength(strength); |
537 | } |
538 | |
539 | void ThemeManager::setAmbientLightStrength(Q3DTheme *theme, float strength) |
540 | { |
541 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.ambientLightStrengthDirty) |
542 | theme->setAmbientLightStrength(strength); |
543 | } |
544 | |
545 | void ThemeManager::setHighlightLightStrength(Q3DTheme *theme, float strength) |
546 | { |
547 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.highlightLightStrengthDirty) |
548 | theme->setHighlightLightStrength(strength); |
549 | } |
550 | |
551 | void ThemeManager::setLabelBorderEnabled(Q3DTheme *theme, bool enabled) |
552 | { |
553 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.labelBorderEnabledDirty) |
554 | theme->setLabelBorderEnabled(enabled); |
555 | } |
556 | |
557 | void ThemeManager::setFont(Q3DTheme *theme, const QFont &font) |
558 | { |
559 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.fontDirty) |
560 | theme->setFont(font); |
561 | } |
562 | |
563 | void ThemeManager::setBackgroundEnabled(Q3DTheme *theme, bool enabled) |
564 | { |
565 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.backgroundEnabledDirty) |
566 | theme->setBackgroundEnabled(enabled); |
567 | } |
568 | |
569 | void ThemeManager::setGridEnabled(Q3DTheme *theme, bool enabled) |
570 | { |
571 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.gridEnabledDirty) |
572 | theme->setGridEnabled(enabled); |
573 | } |
574 | |
575 | void ThemeManager::setLabelBackgroundEnabled(Q3DTheme *theme, bool enabled) |
576 | { |
577 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.labelBackgroundEnabledDirty) |
578 | theme->setLabelBackgroundEnabled(enabled); |
579 | } |
580 | |
581 | void ThemeManager::setColorStyle(Q3DTheme *theme, Q3DTheme::ColorStyle style) |
582 | { |
583 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.colorStyleDirty) |
584 | theme->setColorStyle(style); |
585 | } |
586 | |
587 | void ThemeManager::setLabelsEnabled(Q3DTheme *theme, bool enabled) |
588 | { |
589 | if (theme->d_func()->isForcePredefinedType() || !theme->d_func()->m_dirtyBits.labelsEnabledDirty) |
590 | theme->setLabelsEnabled(enabled); |
591 | } |
592 | |
593 | QT_END_NAMESPACE |
594 | |