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