1 | // Copyright (C) 2016 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_ptr->isDefaultTheme()) |
39 | theme->d_ptr->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_ptr->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_ptr->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_ptr.data(), 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_ptr->isForcePredefinedType()) |
79 | m_activeTheme->d_ptr->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_ptr.data(), 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 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
154 | setBaseGradients(theme, gradients: baseGradients); |
155 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x14aaff)), |
156 | colorLevel: defaultColorLevel)); |
157 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x6400aa)), |
158 | colorLevel: defaultColorLevel)); |
159 | break; |
160 | } |
161 | |
162 | case Q3DTheme::ThemePrimaryColors: { |
163 | baseColors.append(t: QColor(QRgb(0xffe400))); |
164 | baseColors.append(t: QColor(QRgb(0xfaa106))); |
165 | baseColors.append(t: QColor(QRgb(0xf45f0d))); |
166 | baseColors.append(t: QColor(QRgb(0xfcba04))); |
167 | baseColors.append(t: QColor(QRgb(0xf7800a))); |
168 | |
169 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
170 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
171 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
172 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
173 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
174 | |
175 | setBackgroundEnabled(theme, enabled: true); |
176 | setGridEnabled(theme, enabled: true); |
177 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
178 | setLabelBackgroundEnabled(theme, enabled: true); |
179 | setLightColor(theme, color: Qt::white); |
180 | setBaseColors(theme, colors: baseColors); |
181 | setBackgroundColor(theme, color: QColor(QRgb(0xffffff))); |
182 | setWindowColor(theme, color: QColor(QRgb(0xffffff))); |
183 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
184 | setTextBackgroundColor(theme, color: QColor(0xff, 0xff, 0xff, 0x99)); |
185 | setGridLineColor(theme, color: QColor(QRgb(0xd7d6d5))); |
186 | setSingleHighlightColor(theme, color: QColor(QRgb(0x27beee))); |
187 | setMultiHighlightColor(theme, color: QColor(QRgb(0xee1414))); |
188 | setLightStrength(theme, strength: 5.0f); |
189 | setAmbientLightStrength(theme, strength: 0.5f); |
190 | setHighlightLightStrength(theme, strength: 5.0f); |
191 | setLabelBorderEnabled(theme, enabled: false); |
192 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
193 | setBaseGradients(theme, gradients: baseGradients); |
194 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x27beee)), |
195 | colorLevel: defaultColorLevel)); |
196 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xee1414)), |
197 | colorLevel: defaultColorLevel)); |
198 | break; |
199 | } |
200 | |
201 | case Q3DTheme::ThemeDigia: { |
202 | baseColors.append(t: QColor(QRgb(0xeaeaea))); |
203 | baseColors.append(t: QColor(QRgb(0xa0a0a0))); |
204 | baseColors.append(t: QColor(QRgb(0x626262))); |
205 | baseColors.append(t: QColor(QRgb(0xbebebe))); |
206 | baseColors.append(t: QColor(QRgb(0x818181))); |
207 | |
208 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultBuiltInColorLevel)); |
209 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultBuiltInColorLevel)); |
210 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultBuiltInColorLevel)); |
211 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultBuiltInColorLevel)); |
212 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultBuiltInColorLevel)); |
213 | |
214 | setBackgroundEnabled(theme, enabled: true); |
215 | setGridEnabled(theme, enabled: true); |
216 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
217 | setLabelBackgroundEnabled(theme, enabled: true); |
218 | setLightColor(theme, color: Qt::white); |
219 | setBaseColors(theme, colors: baseColors); |
220 | setBackgroundColor(theme, color: QColor(QRgb(0xffffff))); |
221 | setWindowColor(theme, color: QColor(QRgb(0xffffff))); |
222 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
223 | setTextBackgroundColor(theme, color: QColor(0xff, 0xff, 0xff, 0x80)); |
224 | setGridLineColor(theme, color: QColor(QRgb(0xd7d6d5))); |
225 | setSingleHighlightColor(theme, color: QColor(QRgb(0xfa0000))); |
226 | setMultiHighlightColor(theme, color: QColor(QRgb(0x333333))); |
227 | setLightStrength(theme, strength: 5.0f); |
228 | setAmbientLightStrength(theme, strength: 0.5f); |
229 | setHighlightLightStrength(theme, strength: 5.0f); |
230 | setLabelBorderEnabled(theme, enabled: false); |
231 | setColorStyle(theme, style: Q3DTheme::ColorStyleObjectGradient); |
232 | setBaseGradients(theme, gradients: baseGradients); |
233 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xfa0000)), |
234 | colorLevel: defaultBuiltInColorLevel)); |
235 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x333333)), |
236 | colorLevel: defaultBuiltInColorLevel)); |
237 | break; |
238 | } |
239 | |
240 | case Q3DTheme::ThemeStoneMoss: { |
241 | baseColors.append(t: QColor(QRgb(0xbeb32b))); |
242 | baseColors.append(t: QColor(QRgb(0x928327))); |
243 | baseColors.append(t: QColor(QRgb(0x665423))); |
244 | baseColors.append(t: QColor(QRgb(0xa69929))); |
245 | baseColors.append(t: QColor(QRgb(0x7c6c25))); |
246 | |
247 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
248 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
249 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
250 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
251 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
252 | |
253 | setBackgroundEnabled(theme, enabled: true); |
254 | setGridEnabled(theme, enabled: true); |
255 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
256 | setLabelBackgroundEnabled(theme, enabled: true); |
257 | setLightColor(theme, color: Qt::white); |
258 | setBaseColors(theme, colors: baseColors); |
259 | setBackgroundColor(theme, color: QColor(QRgb(0x4d4d4f))); |
260 | setWindowColor(theme, color: QColor(QRgb(0x4d4d4f))); |
261 | setTextColor(theme, color: QColor(QRgb(0xffffff))); |
262 | setTextBackgroundColor(theme, color: QColor(0x4d, 0x4d, 0x4f, 0xcd)); |
263 | setGridLineColor(theme, color: QColor(QRgb(0x3e3e40))); |
264 | setSingleHighlightColor(theme, color: QColor(QRgb(0xfbf6d6))); |
265 | setMultiHighlightColor(theme, color: QColor(QRgb(0x442f20))); |
266 | setLightStrength(theme, strength: 5.0f); |
267 | setAmbientLightStrength(theme, strength: 0.5f); |
268 | setHighlightLightStrength(theme, strength: 5.0f); |
269 | setLabelBorderEnabled(theme, enabled: true); |
270 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
271 | setBaseGradients(theme, gradients: baseGradients); |
272 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xfbf6d6)), |
273 | colorLevel: defaultColorLevel)); |
274 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x442f20)), |
275 | colorLevel: defaultColorLevel)); |
276 | break; |
277 | } |
278 | |
279 | case Q3DTheme::ThemeArmyBlue: { |
280 | baseColors.append(t: QColor(QRgb(0x495f76))); |
281 | baseColors.append(t: QColor(QRgb(0x81909f))); |
282 | baseColors.append(t: QColor(QRgb(0xbec5cd))); |
283 | baseColors.append(t: QColor(QRgb(0x687a8d))); |
284 | baseColors.append(t: QColor(QRgb(0xa3aeb9))); |
285 | |
286 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultBuiltInColorLevel)); |
287 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultBuiltInColorLevel)); |
288 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultBuiltInColorLevel)); |
289 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultBuiltInColorLevel)); |
290 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultBuiltInColorLevel)); |
291 | |
292 | setBackgroundEnabled(theme, enabled: true); |
293 | setGridEnabled(theme, enabled: true); |
294 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
295 | setLabelBackgroundEnabled(theme, enabled: true); |
296 | setLightColor(theme, color: Qt::white); |
297 | setBaseColors(theme, colors: baseColors); |
298 | setBackgroundColor(theme, color: QColor(QRgb(0xd5d6d7))); |
299 | setWindowColor(theme, color: QColor(QRgb(0xd5d6d7))); |
300 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
301 | setTextBackgroundColor(theme, color: QColor(0xd5, 0xd6, 0xd7, 0xcd)); |
302 | setGridLineColor(theme, color: QColor(QRgb(0xaeadac))); |
303 | setSingleHighlightColor(theme, color: QColor(QRgb(0x2aa2f9))); |
304 | setMultiHighlightColor(theme, color: QColor(QRgb(0x103753))); |
305 | setLightStrength(theme, strength: 5.0f); |
306 | setAmbientLightStrength(theme, strength: 0.5f); |
307 | setHighlightLightStrength(theme, strength: 5.0f); |
308 | setLabelBorderEnabled(theme, enabled: false); |
309 | setColorStyle(theme, style: Q3DTheme::ColorStyleObjectGradient); |
310 | setBaseGradients(theme, gradients: baseGradients); |
311 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x2aa2f9)), |
312 | colorLevel: defaultBuiltInColorLevel)); |
313 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x103753)), |
314 | colorLevel: defaultBuiltInColorLevel)); |
315 | break; |
316 | } |
317 | |
318 | case Q3DTheme::ThemeRetro: { |
319 | baseColors.append(t: QColor(QRgb(0x533b23))); |
320 | baseColors.append(t: QColor(QRgb(0x83715a))); |
321 | baseColors.append(t: QColor(QRgb(0xb3a690))); |
322 | baseColors.append(t: QColor(QRgb(0x6b563e))); |
323 | baseColors.append(t: QColor(QRgb(0x9b8b75))); |
324 | |
325 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultBuiltInColorLevel)); |
326 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultBuiltInColorLevel)); |
327 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultBuiltInColorLevel)); |
328 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultBuiltInColorLevel)); |
329 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultBuiltInColorLevel)); |
330 | |
331 | setBackgroundEnabled(theme, enabled: true); |
332 | setGridEnabled(theme, enabled: true); |
333 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
334 | setLabelBackgroundEnabled(theme, enabled: true); |
335 | setLightColor(theme, color: Qt::white); |
336 | setBaseColors(theme, colors: baseColors); |
337 | setBackgroundColor(theme, color: QColor(QRgb(0xe9e2ce))); |
338 | setWindowColor(theme, color: QColor(QRgb(0xe9e2ce))); |
339 | setTextColor(theme, color: QColor(QRgb(0x000000))); |
340 | setTextBackgroundColor(theme, color: QColor(0xe9, 0xe2, 0xce, 0xc0)); |
341 | setGridLineColor(theme, color: QColor(QRgb(0xd0c0b0))); |
342 | setSingleHighlightColor(theme, color: QColor(QRgb(0x8ea317))); |
343 | setMultiHighlightColor(theme, color: QColor(QRgb(0xc25708))); |
344 | setLightStrength(theme, strength: 5.0f); |
345 | setAmbientLightStrength(theme, strength: 0.5f); |
346 | setHighlightLightStrength(theme, strength: 5.0f); |
347 | setLabelBorderEnabled(theme, enabled: false); |
348 | setColorStyle(theme, style: Q3DTheme::ColorStyleObjectGradient); |
349 | setBaseGradients(theme, gradients: baseGradients); |
350 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0x8ea317)), |
351 | colorLevel: defaultBuiltInColorLevel)); |
352 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xc25708)), |
353 | colorLevel: defaultBuiltInColorLevel)); |
354 | break; |
355 | } |
356 | |
357 | case Q3DTheme::ThemeEbony: { |
358 | baseColors.append(t: QColor(QRgb(0xffffff))); |
359 | baseColors.append(t: QColor(QRgb(0x999999))); |
360 | baseColors.append(t: QColor(QRgb(0x474747))); |
361 | baseColors.append(t: QColor(QRgb(0xc7c7c7))); |
362 | baseColors.append(t: QColor(QRgb(0x6b6b6b))); |
363 | |
364 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
365 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
366 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
367 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
368 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
369 | |
370 | setBackgroundEnabled(theme, enabled: true); |
371 | setGridEnabled(theme, enabled: true); |
372 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
373 | setLabelBackgroundEnabled(theme, enabled: true); |
374 | setLightColor(theme, color: Qt::white); |
375 | setBaseColors(theme, colors: baseColors); |
376 | setBackgroundColor(theme, color: QColor(QRgb(0x000000))); |
377 | setWindowColor(theme, color: QColor(QRgb(0x000000))); |
378 | setTextColor(theme, color: QColor(QRgb(0xaeadac))); |
379 | setTextBackgroundColor(theme, color: QColor(0x00, 0x00, 0x00, 0xcd)); |
380 | setGridLineColor(theme, color: QColor(QRgb(0x35322f))); |
381 | setSingleHighlightColor(theme, color: QColor(QRgb(0xf5dc0d))); |
382 | setMultiHighlightColor(theme, color: QColor(QRgb(0xd72222))); |
383 | setLightStrength(theme, strength: 5.0f); |
384 | setAmbientLightStrength(theme, strength: 0.5f); |
385 | setHighlightLightStrength(theme, strength: 5.0f); |
386 | setLabelBorderEnabled(theme, enabled: false); |
387 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
388 | setBaseGradients(theme, gradients: baseGradients); |
389 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xf5dc0d)), |
390 | colorLevel: defaultColorLevel)); |
391 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xd72222)), |
392 | colorLevel: defaultColorLevel)); |
393 | break; |
394 | } |
395 | |
396 | case Q3DTheme::ThemeIsabelle: { |
397 | baseColors.append(t: QColor(QRgb(0xf9d900))); |
398 | baseColors.append(t: QColor(QRgb(0xf09603))); |
399 | baseColors.append(t: QColor(QRgb(0xe85506))); |
400 | baseColors.append(t: QColor(QRgb(0xf5b802))); |
401 | baseColors.append(t: QColor(QRgb(0xec7605))); |
402 | |
403 | baseGradients.append(t: createGradient(color: baseColors.at(i: 0), colorLevel: defaultColorLevel)); |
404 | baseGradients.append(t: createGradient(color: baseColors.at(i: 1), colorLevel: defaultColorLevel)); |
405 | baseGradients.append(t: createGradient(color: baseColors.at(i: 2), colorLevel: defaultColorLevel)); |
406 | baseGradients.append(t: createGradient(color: baseColors.at(i: 3), colorLevel: defaultColorLevel)); |
407 | baseGradients.append(t: createGradient(color: baseColors.at(i: 4), colorLevel: defaultColorLevel)); |
408 | |
409 | setBackgroundEnabled(theme, enabled: true); |
410 | setGridEnabled(theme, enabled: true); |
411 | setFont(theme, font: QFont(QStringLiteral("Arial" ))); |
412 | setLabelBackgroundEnabled(theme, enabled: true); |
413 | setLightColor(theme, color: Qt::white); |
414 | setBaseColors(theme, colors: baseColors); |
415 | setBackgroundColor(theme, color: QColor(QRgb(0x000000))); |
416 | setWindowColor(theme, color: QColor(QRgb(0x000000))); |
417 | setTextColor(theme, color: QColor(QRgb(0xaeadac))); |
418 | setTextBackgroundColor(theme, color: QColor(0x00, 0x00, 0x00, 0xc0)); |
419 | setGridLineColor(theme, color: QColor(QRgb(0x35322f))); |
420 | setSingleHighlightColor(theme, color: QColor(QRgb(0xfff7cc))); |
421 | setMultiHighlightColor(theme, color: QColor(QRgb(0xde0a0a))); |
422 | setLightStrength(theme, strength: 5.0f); |
423 | setAmbientLightStrength(theme, strength: 0.5f); |
424 | setHighlightLightStrength(theme, strength: 5.0f); |
425 | setLabelBorderEnabled(theme, enabled: false); |
426 | setColorStyle(theme, style: Q3DTheme::ColorStyleUniform); |
427 | setBaseGradients(theme, gradients: baseGradients); |
428 | setSingleHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xfff7cc)), |
429 | colorLevel: defaultColorLevel)); |
430 | setMultiHighlightGradient(theme, gradient: createGradient(color: QColor(QRgb(0xde0a0a)), |
431 | colorLevel: defaultColorLevel)); |
432 | break; |
433 | } |
434 | default: |
435 | break; |
436 | } |
437 | } |
438 | |
439 | QLinearGradient ThemeManager::createGradient(const QColor &color, float colorLevel) |
440 | { |
441 | QColor startColor; |
442 | QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth), |
443 | qreal(gradientTextureHeight), |
444 | 0.0, 0.0);; |
445 | startColor.setRed(color.red() * colorLevel); |
446 | startColor.setGreen(color.green() * colorLevel); |
447 | startColor.setBlue(color.blue() * colorLevel); |
448 | gradient.setColorAt(pos: 0.0, color: startColor); |
449 | gradient.setColorAt(pos: 1.0, color); |
450 | return gradient; |
451 | } |
452 | |
453 | void ThemeManager::setBaseColors(Q3DTheme *theme, const QList<QColor> &colors) |
454 | { |
455 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.baseColorDirty) |
456 | theme->setBaseColors(colors); |
457 | } |
458 | |
459 | void ThemeManager::setBackgroundColor(Q3DTheme *theme, const QColor &color) |
460 | { |
461 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.backgroundColorDirty) |
462 | theme->setBackgroundColor(color); |
463 | } |
464 | |
465 | void ThemeManager::setWindowColor(Q3DTheme *theme, const QColor &color) |
466 | { |
467 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.windowColorDirty) |
468 | theme->setWindowColor(color); |
469 | } |
470 | |
471 | void ThemeManager::setTextColor(Q3DTheme *theme, const QColor &color) |
472 | { |
473 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelTextColorDirty) |
474 | theme->setLabelTextColor(color); |
475 | } |
476 | |
477 | void ThemeManager::setTextBackgroundColor(Q3DTheme *theme, const QColor &color) |
478 | { |
479 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelBackgroundColorDirty) |
480 | theme->setLabelBackgroundColor(color); |
481 | } |
482 | |
483 | void ThemeManager::setGridLineColor(Q3DTheme *theme, const QColor &color) |
484 | { |
485 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.gridLineColorDirty) |
486 | theme->setGridLineColor(color); |
487 | } |
488 | |
489 | void ThemeManager::setSingleHighlightColor(Q3DTheme *theme, const QColor &color) |
490 | { |
491 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.singleHighlightColorDirty) |
492 | theme->setSingleHighlightColor(color); |
493 | } |
494 | |
495 | void ThemeManager::setMultiHighlightColor(Q3DTheme *theme, const QColor &color) |
496 | { |
497 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.multiHighlightColorDirty) |
498 | theme->setMultiHighlightColor(color); |
499 | } |
500 | |
501 | void ThemeManager::setLightColor(Q3DTheme *theme, const QColor &color) |
502 | { |
503 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.lightColorDirty) |
504 | theme->setLightColor(color); |
505 | } |
506 | |
507 | void ThemeManager::setBaseGradients(Q3DTheme *theme, const QList<QLinearGradient> &gradients) |
508 | { |
509 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.baseGradientDirty) |
510 | theme->setBaseGradients(gradients); |
511 | } |
512 | |
513 | void ThemeManager::setSingleHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient) |
514 | { |
515 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.singleHighlightGradientDirty) |
516 | theme->setSingleHighlightGradient(gradient); |
517 | } |
518 | |
519 | void ThemeManager::setMultiHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient) |
520 | { |
521 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.multiHighlightGradientDirty) |
522 | theme->setMultiHighlightGradient(gradient); |
523 | } |
524 | |
525 | void ThemeManager::setLightStrength(Q3DTheme *theme, float strength) |
526 | { |
527 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.lightStrengthDirty) |
528 | theme->setLightStrength(strength); |
529 | } |
530 | |
531 | void ThemeManager::setAmbientLightStrength(Q3DTheme *theme, float strength) |
532 | { |
533 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.ambientLightStrengthDirty) |
534 | theme->setAmbientLightStrength(strength); |
535 | } |
536 | |
537 | void ThemeManager::setHighlightLightStrength(Q3DTheme *theme, float strength) |
538 | { |
539 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.highlightLightStrengthDirty) |
540 | theme->setHighlightLightStrength(strength); |
541 | } |
542 | |
543 | void ThemeManager::setLabelBorderEnabled(Q3DTheme *theme, bool enabled) |
544 | { |
545 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelBorderEnabledDirty) |
546 | theme->setLabelBorderEnabled(enabled); |
547 | } |
548 | |
549 | void ThemeManager::setFont(Q3DTheme *theme, const QFont &font) |
550 | { |
551 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.fontDirty) |
552 | theme->setFont(font); |
553 | } |
554 | |
555 | void ThemeManager::setBackgroundEnabled(Q3DTheme *theme, bool enabled) |
556 | { |
557 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.backgroundEnabledDirty) |
558 | theme->setBackgroundEnabled(enabled); |
559 | } |
560 | |
561 | void ThemeManager::setGridEnabled(Q3DTheme *theme, bool enabled) |
562 | { |
563 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.gridEnabledDirty) |
564 | theme->setGridEnabled(enabled); |
565 | } |
566 | |
567 | void ThemeManager::setLabelBackgroundEnabled(Q3DTheme *theme, bool enabled) |
568 | { |
569 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelBackgroundEnabledDirty) |
570 | theme->setLabelBackgroundEnabled(enabled); |
571 | } |
572 | |
573 | void ThemeManager::setColorStyle(Q3DTheme *theme, Q3DTheme::ColorStyle style) |
574 | { |
575 | if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.colorStyleDirty) |
576 | theme->setColorStyle(style); |
577 | } |
578 | |
579 | QT_END_NAMESPACE |
580 | |