Merge lp:~zsombi/ubuntu-ui-toolkit/05-setpalette into lp:ubuntu-ui-toolkit/staging
- 05-setpalette
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Cris Dywan |
Approved revision: | 1477 |
Merged at revision: | 1480 |
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/05-setpalette |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Prerequisite: | lp:~zsombi/ubuntu-ui-toolkit/04-apply-styleset |
Diff against target: |
1213 lines (+864/-27) 23 files modified
components.api (+3/-3) modules/Ubuntu/Components/MainViewBase.qml (+10/-3) modules/Ubuntu/Components/Themes/Ambiance/Palette.qml (+4/-4) modules/Ubuntu/Components/Themes/Palette.qml (+3/-3) modules/Ubuntu/Components/Themes/SuruDark/Palette.qml (+2/-2) modules/Ubuntu/Components/Themes/qmldir (+4/-0) modules/Ubuntu/Components/plugin/uctheme.cpp (+227/-2) modules/Ubuntu/Components/plugin/uctheme.h (+52/-3) tests/resources/subtheming/Simple.qml (+36/-2) tests/unit/tst_performance/PaletteConfigurationAllColors.qml (+58/-0) tests/unit/tst_performance/PaletteConfigurationOneColor.qml (+33/-0) tests/unit/tst_performance/StyledItemNewTheming.qml (+72/-0) tests/unit/tst_performance/tst_performance.cpp (+4/-1) tests/unit/tst_performance/tst_performance.pro (+4/-1) tests/unit_x11/tst_subtheming/ChangeDefaultPaletteInChildren.qml (+38/-0) tests/unit_x11/tst_subtheming/ChangePaletteValueWhenParentChanges.qml (+34/-0) tests/unit_x11/tst_subtheming/DynamicPalette.qml (+47/-0) tests/unit_x11/tst_subtheming/InvalidPalette.qml (+23/-0) tests/unit_x11/tst_subtheming/MultiplePaletteInstances.qml (+38/-0) tests/unit_x11/tst_subtheming/SameNamedPaletteSettings.qml (+39/-0) tests/unit_x11/tst_subtheming/themes/CustomTheme/Palette.qml (+29/-0) tests/unit_x11/tst_subtheming/tst_subtheming.cpp (+95/-0) tests/unit_x11/tst_subtheming/tst_subtheming.pro (+9/-3) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/05-setpalette |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Cris Dywan | Approve | ||
Review via email: mp+253500@code.launchpad.net |
Commit message
Make ThemeSettings.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1470. By Zsombor Egri
-
more performance tests added to see the performance difference between old and new theming solutions
- 1471. By Zsombor Egri
-
more tests of that type
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1471
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1472. By Zsombor Egri
-
prereq sync
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1472
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1473. By Zsombor Egri
-
prereq sync
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1473
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1474. By Zsombor Egri
-
prereq sync
- 1475. By Zsombor Egri
-
prereq sync
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1475
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
tests/resources
Focussing InnerText and selecting the other one doesn't correctly use PaletteValues.field - if you add normal.field and selected.field you can see how normal.field will only be applied once initially and selected.field will stick indefinitely.
In staging using SuruDark in the gallery works fine with regard to TextField background color.
Can we unit test the 'Not a Palette component' error?
- 1476. By Zsombor Egri
-
fixing TextAreaStyle not picking the field colors properly; removed unnecessary PaletteValue instances
- 1477. By Zsombor Egri
-
text input style change rolled back; missing test added
Cris Dywan (kalikiana) wrote : | # |
FTR the issue of the fild color is bug 1378231.
Thank you good sir for adding the test. Looking splendid now!
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'components.api' |
2 | --- components.api 2015-04-15 13:53:28 +0000 |
3 | +++ components.api 2015-04-16 14:02:59 +0000 |
4 | @@ -626,11 +626,11 @@ |
5 | function undo() |
6 | function remove(start, end) |
7 | function getText(start, end) |
8 | -Palette 0.1 |
9 | +Palette 0.1 1.0 |
10 | QtObject |
11 | property PaletteValues normal |
12 | property PaletteValues selected |
13 | -PaletteValues 0.1 |
14 | +PaletteValues 0.1 1.0 |
15 | QtObject |
16 | property color background |
17 | property color backgroundText |
18 | @@ -1074,7 +1074,7 @@ |
19 | exports: ["ThemeSettings 1.3"] |
20 | Property { name: "parentTheme"; type: "UCTheme"; isReadonly: true; isPointer: true } |
21 | Property { name: "name"; type: "string" } |
22 | - Property { name: "palette"; type: "QObject"; isReadonly: true; isPointer: true } |
23 | + Property { name: "palette"; type: "QObject"; isPointer: true } |
24 | Method { |
25 | name: "createStyleComponent" |
26 | Parameter { name: "styleName"; type: "string" } |
27 | |
28 | === modified file 'modules/Ubuntu/Components/MainViewBase.qml' |
29 | --- modules/Ubuntu/Components/MainViewBase.qml 2015-04-16 14:02:58 +0000 |
30 | +++ modules/Ubuntu/Components/MainViewBase.qml 2015-04-16 14:02:59 +0000 |
31 | @@ -48,11 +48,18 @@ |
32 | |
33 | Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712 |
34 | */ |
35 | - property string autoThemeName: (ColorUtils.luminance(backgroundColor) >= 0.85) ? |
36 | - "Ambiance" : "SuruDark" |
37 | + |
38 | + onBackgroundColorChanged: { |
39 | + if (backgroundColor != theme.palette.normal.background) { |
40 | + // custom color, proceed with auto-theming |
41 | + autoThemeName = (ColorUtils.luminance(backgroundColor) >= 0.85) ? |
42 | + "Ambiance" : "SuruDark"; |
43 | + } |
44 | + } |
45 | + property string autoThemeName |
46 | onAutoThemeNameChanged: { |
47 | // only change the theme if the current one is a system one. |
48 | - if (autoThemeName !== "" && (theme.name.search("Ubuntu.Components.Themes") >= 0)) { |
49 | + if (autoThemeName !== "" && (theme.name.search("Ubuntu.Components.Themes") == 0)) { |
50 | mainView.theme.name = "Ubuntu.Components.Themes.%1".arg(autoThemeName); |
51 | } |
52 | } |
53 | |
54 | === modified file 'modules/Ubuntu/Components/Themes/Ambiance/Palette.qml' |
55 | --- modules/Ubuntu/Components/Themes/Ambiance/Palette.qml 2015-03-03 13:47:48 +0000 |
56 | +++ modules/Ubuntu/Components/Themes/Ambiance/Palette.qml 2015-04-16 14:02:59 +0000 |
57 | @@ -19,7 +19,7 @@ |
58 | import Ubuntu.Components.Themes 0.1 |
59 | |
60 | Palette { |
61 | - normal: PaletteValues { |
62 | + normal { |
63 | background: "#EDEDED" |
64 | backgroundText: "#81888888" |
65 | base: Qt.rgba(0, 0, 0, 0.1) |
66 | @@ -28,13 +28,13 @@ |
67 | foregroundText: "#FFFFFF" |
68 | overlay: "#FDFDFD" |
69 | overlayText: UbuntuColors.lightGrey |
70 | - field: "#FAFAFA" |
71 | + field: "lightgray" |
72 | fieldText: UbuntuColors.darkGrey |
73 | } |
74 | - selected: PaletteValues { |
75 | + selected { |
76 | background: Qt.rgba(0, 0, 0, 0.05) |
77 | backgroundText: UbuntuColors.darkGrey |
78 | - selection: foreground // unused |
79 | + selection: selected.foreground // unused |
80 | foreground: Qt.rgba(UbuntuColors.blue.r, UbuntuColors.blue.g, UbuntuColors.blue.b, 0.2) |
81 | foregroundText: UbuntuColors.darkGrey |
82 | field: "#FFFFFF" |
83 | |
84 | === modified file 'modules/Ubuntu/Components/Themes/Palette.qml' |
85 | --- modules/Ubuntu/Components/Themes/Palette.qml 2015-04-16 14:02:58 +0000 |
86 | +++ modules/Ubuntu/Components/Themes/Palette.qml 2015-04-16 14:02:59 +0000 |
87 | @@ -18,7 +18,7 @@ |
88 | |
89 | /*! |
90 | \qmltype Palette |
91 | - \inqmlmodule Ubuntu.Components.Themes 0.1 |
92 | + \inqmlmodule Ubuntu.Components.Themes 1.0 |
93 | \ingroup theming |
94 | \brief Palette of colors from the theme that widgets use to draw themselves. |
95 | |
96 | @@ -50,10 +50,10 @@ |
97 | /*! |
98 | Color palette to use when the widget is not in any particular state. |
99 | */ |
100 | - property PaletteValues normal |
101 | + property PaletteValues normal: PaletteValues{} |
102 | /*! |
103 | Color palette to use when the widget is selected, for example when |
104 | a tab is the current one. |
105 | */ |
106 | - property PaletteValues selected |
107 | + property PaletteValues selected: PaletteValues{} |
108 | } |
109 | |
110 | === modified file 'modules/Ubuntu/Components/Themes/SuruDark/Palette.qml' |
111 | --- modules/Ubuntu/Components/Themes/SuruDark/Palette.qml 2015-03-03 13:47:48 +0000 |
112 | +++ modules/Ubuntu/Components/Themes/SuruDark/Palette.qml 2015-04-16 14:02:59 +0000 |
113 | @@ -19,7 +19,7 @@ |
114 | import Ubuntu.Components.Themes 0.1 |
115 | |
116 | Palette { |
117 | - normal: PaletteValues { |
118 | + normal { |
119 | background: "#221E1C" |
120 | backgroundText: "#33F3F3E7" |
121 | base: "#19000000" |
122 | @@ -31,7 +31,7 @@ |
123 | field: "#19000000" |
124 | fieldText: "#7F7F7F7F" |
125 | } |
126 | - selected: PaletteValues { |
127 | + selected { |
128 | background: "#88D6D6D6" // FIXME: not from design |
129 | backgroundText: "#FFFFFF" |
130 | selection: Qt.rgba(UbuntuColors.blue.r, UbuntuColors.blue.g, UbuntuColors.blue.b, 0.2) |
131 | |
132 | === modified file 'modules/Ubuntu/Components/Themes/qmldir' |
133 | --- modules/Ubuntu/Components/Themes/qmldir 2013-07-01 06:32:40 +0000 |
134 | +++ modules/Ubuntu/Components/Themes/qmldir 2015-04-16 14:02:59 +0000 |
135 | @@ -1,3 +1,7 @@ |
136 | module Ubuntu.Components.Themes |
137 | Palette 0.1 Palette.qml |
138 | PaletteValues 0.1 PaletteValues.qml |
139 | + |
140 | +#version 1.0 |
141 | +Palette 1.0 Palette.qml |
142 | +PaletteValues 1.0 PaletteValues.qml |
143 | |
144 | === modified file 'modules/Ubuntu/Components/plugin/uctheme.cpp' |
145 | --- modules/Ubuntu/Components/plugin/uctheme.cpp 2015-04-16 14:02:58 +0000 |
146 | +++ modules/Ubuntu/Components/plugin/uctheme.cpp 2015-04-16 14:02:59 +0000 |
147 | @@ -36,6 +36,12 @@ |
148 | #include <QtGui/QGuiApplication> |
149 | #include <QtGui/QFont> |
150 | |
151 | +#include <QtQml/private/qqmlproperty_p.h> |
152 | +#include <QtQml/private/qqmlabstractbinding_p.h> |
153 | +#define foreach Q_FOREACH |
154 | +#include <QtQml/private/qqmlbinding_p.h> |
155 | +#undef foreach |
156 | + |
157 | /*! |
158 | * \qmltype ThemeSettings |
159 | * \instantiates UCTheme |
160 | @@ -199,6 +205,133 @@ |
161 | return parentTheme; |
162 | } |
163 | |
164 | +/****************************************************************************** |
165 | + * Theme::PaletteConfig |
166 | + */ |
167 | + |
168 | +// builds configuration list and applies the configuration on the palette |
169 | +void UCTheme::PaletteConfig::configurePalette(QObject *themePalette) |
170 | +{ |
171 | + if (!palette || !themePalette || configured) { |
172 | + return; |
173 | + } |
174 | + if (configList.isEmpty()) { |
175 | + // need to build config list first |
176 | + buildConfig(); |
177 | + } |
178 | + if (!configList.isEmpty()) { |
179 | + apply(themePalette); |
180 | + } |
181 | +} |
182 | + |
183 | +void UCTheme::PaletteConfig::restorePalette() |
184 | +{ |
185 | + if (!palette || configList.isEmpty() || !configured) { |
186 | + return; |
187 | + } |
188 | + |
189 | + for (int i = 0; i < configList.count(); i++) { |
190 | + Data &config = configList[i]; |
191 | + if (!config.paletteProperty.isValid()) { |
192 | + continue; |
193 | + } |
194 | + |
195 | + // restore the config binding to the config target |
196 | + if (config.configBinding && config.configBinding->bindingType() == QQmlAbstractBinding::Binding) { |
197 | + QQmlBinding *qmlBinding = static_cast<QQmlBinding*>(config.configBinding); |
198 | + qmlBinding->removeFromObject(); |
199 | + qmlBinding->setTarget(config.configProperty); |
200 | + } |
201 | + |
202 | + if (config.paletteBinding) { |
203 | + // restore the binding to the palette |
204 | + QQmlAbstractBinding *prev = QQmlPropertyPrivate::setBinding(config.paletteProperty, config.paletteBinding); |
205 | + if (prev && prev != config.paletteBinding && prev != config.configBinding) { |
206 | + prev->destroy(); |
207 | + } |
208 | + config.paletteBinding->update(); |
209 | + } else { |
210 | + config.paletteProperty.write(config.paletteValue); |
211 | + } |
212 | + |
213 | + config.paletteProperty = QQmlProperty(); |
214 | + config.paletteBinding = NULL; |
215 | + config.paletteValue.clear(); |
216 | + } |
217 | + |
218 | + configured = false; |
219 | +} |
220 | + |
221 | +// build palette configuration list |
222 | +void UCTheme::PaletteConfig::buildConfig() |
223 | +{ |
224 | + if (!palette) { |
225 | + return; |
226 | + } |
227 | + const char *valueSetList[10] = {"normal", "selected"}; |
228 | + QQmlContext *configContext = qmlContext(palette); |
229 | + |
230 | + for (int i = 0; i < 2; i++) { |
231 | + const char *valueSet = valueSetList[i]; |
232 | + QObject *configObject = palette->property(valueSet).value<QObject*>(); |
233 | + const QMetaObject *mo = configObject->metaObject(); |
234 | + |
235 | + for (int ii = mo->propertyOffset(); ii < mo->propertyCount(); ii++) { |
236 | + const QMetaProperty prop = mo->property(ii); |
237 | + QString propertyName = QString("%1.%2").arg(valueSet).arg(prop.name()); |
238 | + QQmlProperty configProperty(palette, propertyName, configContext); |
239 | + |
240 | + // first we need to check whether the property has a binding or not |
241 | + QQmlAbstractBinding *binding = QQmlPropertyPrivate::binding(configProperty); |
242 | + if (binding) { |
243 | + configList << Data(propertyName, configProperty, binding); |
244 | + } else { |
245 | + QVariant value = configProperty.read(); |
246 | + QColor color = value.value<QColor>(); |
247 | + if (color.isValid()) { |
248 | + configList << Data(propertyName, configProperty); |
249 | + } |
250 | + } |
251 | + } |
252 | + } |
253 | +} |
254 | + |
255 | +// apply configuration on the palette |
256 | +void UCTheme::PaletteConfig::apply(QObject *themePalette) |
257 | +{ |
258 | + QQmlContext *context = qmlContext(themePalette); |
259 | + for (int i = 0; i < configList.count(); i++) { |
260 | + Data &config = configList[i]; |
261 | + config.paletteProperty = QQmlProperty(themePalette, config.propertyName, context); |
262 | + |
263 | + // backup |
264 | + config.paletteBinding = QQmlPropertyPrivate::binding(config.paletteProperty); |
265 | + if (!config.paletteBinding) { |
266 | + config.paletteValue = config.paletteProperty.read(); |
267 | + } |
268 | + |
269 | + // apply configuration |
270 | + if (config.configBinding) { |
271 | + // transfer binding's target |
272 | + if (config.configBinding->bindingType() == QQmlAbstractBinding::Binding) { |
273 | + QQmlBinding *qmlBinding = static_cast<QQmlBinding*>(config.configBinding); |
274 | + qmlBinding->setTarget(config.paletteProperty); |
275 | + } |
276 | + QQmlPropertyPrivate::setBinding(config.paletteProperty, config.configBinding); |
277 | + } else { |
278 | + if (config.paletteBinding) { |
279 | + // remove binding so the property doesn't clear it |
280 | + QQmlPropertyPrivate::setBinding(config.paletteProperty, 0); |
281 | + } |
282 | + config.paletteProperty.write(config.configProperty.read()); |
283 | + } |
284 | + } |
285 | + configured = true; |
286 | +} |
287 | + |
288 | +/****************************************************************************** |
289 | + * Theme |
290 | + */ |
291 | UCTheme::UCTheme(QObject *parent) |
292 | : QObject(parent) |
293 | , m_palette(UCTheme::defaultTheme().m_palette) |
294 | @@ -318,7 +451,59 @@ |
295 | |
296 | /*! |
297 | * \qmlproperty Palette ThemeSettings::palette |
298 | - * The palette of the current theme. |
299 | + * The palette of the current theme. When set, only the valid palette values will |
300 | + * be taken into account, which will override the theme defined palette values. |
301 | + * The following example will set the system's default theme palette normal background |
302 | + * color to Ubuntu blue. All other palette values will be untouched. |
303 | + * \qml |
304 | + * import QtQuick 2.4 |
305 | + * import Ubuntu.Components 1.3 |
306 | + * import Ubuntu.Components.Themes 1.0 |
307 | + * |
308 | + * MainView { |
309 | + * // your code |
310 | + * theme.palette: Palette { |
311 | + * normal.background: UbuntuColors.blue |
312 | + * } |
313 | + * } |
314 | + * \endqml |
315 | + * \note Palette values applied on inherited themes will be rolled back once the |
316 | + * component declaring the palette is unloaded. This can be demonstracted using |
317 | + * a Loader element: |
318 | + * \qml |
319 | + * import QtQuick 2.4 |
320 | + * import Ubuntu.Components 1.3 |
321 | + * import Ubuntu.Components.Themes 1.0 |
322 | + * |
323 | + * MainView { |
324 | + * width: units.gu(40) |
325 | + * height: units.gu(71) |
326 | + * |
327 | + * Loader { |
328 | + * id: loader |
329 | + * onItemChanged: if (item) button.theme.palette = item |
330 | + * } |
331 | + * Component { |
332 | + * id: dynamicPalette |
333 | + * Palette { |
334 | + * normal.background: UbuntuColors.blue |
335 | + * } |
336 | + * } |
337 | + * Button { |
338 | + * id: button |
339 | + * text: "Toggle palette" |
340 | + * onClicked: { |
341 | + * if (loader.item) { |
342 | + * loader.sourceComponent = undefined; |
343 | + * } else { |
344 | + * loader.sourceComponent = dynamicPalette; |
345 | + * } |
346 | + * } |
347 | + * } |
348 | + * } |
349 | + * \endqml |
350 | + * The palette doesn't need to be reset as it automatically resets when the |
351 | + * palette used for configuration is destroyed. |
352 | */ |
353 | QObject* UCTheme::palette() |
354 | { |
355 | @@ -327,6 +512,39 @@ |
356 | } |
357 | return m_palette; |
358 | } |
359 | +void UCTheme::setPalette(QObject *config) |
360 | +{ |
361 | + if (config == m_palette || config == m_config.palette) { |
362 | + return; |
363 | + } |
364 | + if (config && !QuickUtils::inherits(config, "Palette")) { |
365 | + qmlInfo(config) << UbuntuI18n::instance().tr("Not a Palette component."); |
366 | + return; |
367 | + } |
368 | + |
369 | + // 1. restore original palette values |
370 | + m_config.restorePalette(); |
371 | + // 2. clear config list |
372 | + m_config.reset(); |
373 | + // disconnect the reset from the previous palette |
374 | + if (m_config.palette) { |
375 | + disconnect(m_config.palette, &QObject::destroyed, |
376 | + this, 0); |
377 | + } |
378 | + // 3. apply palette configuration |
379 | + m_config.palette = config; |
380 | + if (m_config.palette) { |
381 | + connect(m_config.palette, &QObject::destroyed, |
382 | + this, &UCTheme::resetPalette, |
383 | + Qt::DirectConnection); |
384 | + m_config.configurePalette(m_palette); |
385 | + } |
386 | + Q_EMIT paletteChanged(); |
387 | +} |
388 | +void UCTheme::resetPalette() |
389 | +{ |
390 | + setPalette(NULL); |
391 | +} |
392 | |
393 | QUrl UCTheme::styleUrl(const QString& styleName) |
394 | { |
395 | @@ -394,13 +612,20 @@ |
396 | if (!m_engine) { |
397 | return; |
398 | } |
399 | - if (!m_palette.isNull()) { |
400 | + if (m_palette) { |
401 | + // restore bindings to the config palette before we delete |
402 | + m_config.restorePalette(); |
403 | delete m_palette; |
404 | + m_palette = 0; |
405 | } |
406 | // theme may not have palette defined |
407 | QUrl paletteUrl = styleUrl("Palette.qml"); |
408 | if (paletteUrl.isValid()) { |
409 | m_palette = QuickUtils::instance().createQmlObject(paletteUrl, m_engine); |
410 | + if (m_palette) { |
411 | + m_palette->setParent(this); |
412 | + } |
413 | + m_config.configurePalette(m_palette); |
414 | if (notify) { |
415 | Q_EMIT paletteChanged(); |
416 | } |
417 | |
418 | === modified file 'modules/Ubuntu/Components/plugin/uctheme.h' |
419 | --- modules/Ubuntu/Components/plugin/uctheme.h 2015-04-16 14:02:58 +0000 |
420 | +++ modules/Ubuntu/Components/plugin/uctheme.h 2015-04-16 14:02:59 +0000 |
421 | @@ -26,17 +26,19 @@ |
422 | #include <QtCore/QString> |
423 | #include <QtQml/QQmlComponent> |
424 | #include <QtQml/QQmlParserStatus> |
425 | +#include <QtQml/QQmlProperty> |
426 | |
427 | #include "ucdefaulttheme.h" |
428 | |
429 | class UCStyledItemBase; |
430 | +class QQmlAbstractBinding; |
431 | class UCTheme : public QObject, public QQmlParserStatus |
432 | { |
433 | Q_OBJECT |
434 | Q_INTERFACES(QQmlParserStatus) |
435 | - Q_PROPERTY(UCTheme *parentTheme READ parentTheme NOTIFY parentThemeChanged) |
436 | - Q_PROPERTY(QString name READ name WRITE setName RESET resetName NOTIFY nameChanged) |
437 | - Q_PROPERTY(QObject* palette READ palette NOTIFY paletteChanged) |
438 | + Q_PROPERTY(UCTheme *parentTheme READ parentTheme NOTIFY parentThemeChanged FINAL) |
439 | + Q_PROPERTY(QString name READ name WRITE setName RESET resetName NOTIFY nameChanged FINAL) |
440 | + Q_PROPERTY(QObject* palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL) |
441 | public: |
442 | explicit UCTheme(QObject *parent = 0); |
443 | static UCTheme &defaultTheme() |
444 | @@ -51,6 +53,7 @@ |
445 | void setName(const QString& name); |
446 | void resetName(); |
447 | QObject* palette(); |
448 | + void setPalette(QObject *config); |
449 | |
450 | Q_INVOKABLE QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent); |
451 | static void registerToContext(QQmlContext* context); |
452 | @@ -71,6 +74,7 @@ |
453 | } |
454 | |
455 | private Q_SLOTS: |
456 | + void resetPalette(); |
457 | void _q_defaultThemeChanged(); |
458 | |
459 | private: |
460 | @@ -81,9 +85,54 @@ |
461 | QUrl styleUrl(const QString& styleName); |
462 | void loadPalette(bool notify = true); |
463 | |
464 | + class PaletteConfig |
465 | + { |
466 | + public: |
467 | + PaletteConfig() |
468 | + : palette(0), configured(false) |
469 | + {} |
470 | + ~PaletteConfig() |
471 | + { |
472 | + restorePalette(); |
473 | + } |
474 | + |
475 | + void configurePalette(QObject *themePalette); |
476 | + void restorePalette(); |
477 | + void reset() |
478 | + { |
479 | + configList.clear(); |
480 | + } |
481 | + |
482 | + QObject *palette; |
483 | + private: |
484 | + void buildConfig(); |
485 | + void apply(QObject *palette); |
486 | + |
487 | + struct Data { |
488 | + Data(const QString &name, const QQmlProperty &prop) |
489 | + : propertyName(name), configProperty(prop), configBinding(0), paletteBinding(0) |
490 | + {} |
491 | + Data(const QString &name, const QQmlProperty &prop, QQmlAbstractBinding *binding) |
492 | + : propertyName(name), configProperty(prop), configBinding(binding), paletteBinding(0) |
493 | + {} |
494 | + |
495 | + QString propertyName; |
496 | + QQmlProperty configProperty; |
497 | + QQmlProperty paletteProperty; |
498 | + QVariant paletteValue; |
499 | + QQmlAbstractBinding *configBinding; |
500 | + QQmlAbstractBinding *paletteBinding; |
501 | + }; |
502 | + |
503 | + // configuration palette, not the original theme one |
504 | + bool configured:1; |
505 | + QList<Data> configList; |
506 | + }; |
507 | + |
508 | QString m_name; |
509 | QPointer<QObject> m_palette; // the palette might be from the default style if the theme doesn't define palette |
510 | QQmlEngine *m_engine; |
511 | + PaletteConfig m_config; |
512 | QList<QUrl> m_themePaths; |
513 | UCDefaultTheme m_defaultTheme; |
514 | bool m_defaultStyle:1; |
515 | |
516 | === modified file 'tests/resources/subtheming/Simple.qml' |
517 | --- tests/resources/subtheming/Simple.qml 2015-03-23 17:24:32 +0000 |
518 | +++ tests/resources/subtheming/Simple.qml 2015-04-16 14:02:59 +0000 |
519 | @@ -16,13 +16,15 @@ |
520 | |
521 | import QtQuick 2.4 |
522 | import Ubuntu.Components 1.3 |
523 | +import Ubuntu.Components.Themes 1.0 |
524 | |
525 | -Item { |
526 | - id: component1 |
527 | +MainView { |
528 | objectName: "TopItem" |
529 | width: units.gu(50) |
530 | height: units.gu(100) |
531 | |
532 | + theme.objectName: "MasterTheme" |
533 | + |
534 | Column { |
535 | objectName: "Column" |
536 | anchors.fill: parent |
537 | @@ -33,6 +35,13 @@ |
538 | text: "Theme change" |
539 | onClicked: theme.name = "Ubuntu.Components.Themes.SuruDark" |
540 | } |
541 | + Button { |
542 | + text: "Reset palette" |
543 | + onClicked: customTheme.theme.palette = undefined |
544 | + } |
545 | + Button { |
546 | + text: "Lo" |
547 | + } |
548 | |
549 | TextField { |
550 | objectName: "OuterText" |
551 | @@ -40,9 +49,34 @@ |
552 | onStyleNameChanged: print(objectName, styleName) |
553 | } |
554 | StyledItem { |
555 | + id: customTheme |
556 | objectName: "SuruDarkStyled" |
557 | width: parent.width |
558 | height: units.gu(10) |
559 | + theme: ThemeSettings { |
560 | + objectName: "InnerTheme" |
561 | + id: thisTheme |
562 | + name: parentTheme.name |
563 | +// name: "Ubuntu.Components.Themes.SuruDark" |
564 | + palette: Palette { |
565 | + id: config |
566 | + normal { |
567 | + foregroundText: UbuntuColors.blue |
568 | + overlayText: "#BAFEDC" |
569 | + field: "lime" |
570 | + } |
571 | + selected { |
572 | + field: "teal" |
573 | + fieldText: "brown" |
574 | + foregroundText: Qt.rgba(0, 0, 1, 1) |
575 | + overlayText: config.normal.overlayText |
576 | + foreground: UbuntuColors.green |
577 | + } |
578 | + } |
579 | + } |
580 | + property color myColor: theme.palette.selected.overlayText |
581 | + onMyColorChanged: print(myColor) |
582 | + |
583 | TextField { |
584 | objectName: "InnerText" |
585 | property string styleName: theme.name |
586 | |
587 | === added file 'tests/unit/tst_performance/PaletteConfigurationAllColors.qml' |
588 | --- tests/unit/tst_performance/PaletteConfigurationAllColors.qml 1970-01-01 00:00:00 +0000 |
589 | +++ tests/unit/tst_performance/PaletteConfigurationAllColors.qml 2015-04-16 14:02:59 +0000 |
590 | @@ -0,0 +1,58 @@ |
591 | +/* |
592 | + * Copyright 2015 Canonical Ltd. |
593 | + * |
594 | + * This program is free software; you can redistribute it and/or modify |
595 | + * it under the terms of the GNU Lesser General Public License as published by |
596 | + * the Free Software Foundation; version 3. |
597 | + * |
598 | + * This program is distributed in the hope that it will be useful, |
599 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
600 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
601 | + * GNU Lesser General Public License for more details. |
602 | + * |
603 | + * You should have received a copy of the GNU Lesser General Public License |
604 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
605 | + */ |
606 | + |
607 | +import QtQuick 2.4 |
608 | +import Ubuntu.Components 1.3 |
609 | +import Ubuntu.Components.Themes 1.0 |
610 | + |
611 | +StyledItem { |
612 | + width: 100 |
613 | + height: 62 |
614 | + |
615 | + property string newTheme |
616 | + |
617 | + theme: ThemeSettings { |
618 | + name: newTheme |
619 | + palette: Palette { |
620 | + normal { |
621 | + background: "#ABCDEF" |
622 | + backgroundText: "#0F0F0F" |
623 | + base: "#ABCDEF" |
624 | + baseText: "#0F0F0F" |
625 | + foreground: "#ABCDEF" |
626 | + foregroundText: "#0F0F0F" |
627 | + overlay: "#ABCDEF" |
628 | + overlayText: "#0F0F0F" |
629 | + field: "#ABCDEF" |
630 | + fieldText: "#0F0F0F" |
631 | + selection: "#ABCDEF" |
632 | + } |
633 | + selected { |
634 | + background: "#ABCDEF" |
635 | + backgroundText: "#0F0F0F" |
636 | + base: "#ABCDEF" |
637 | + baseText: "#0F0F0F" |
638 | + foreground: "#ABCDEF" |
639 | + foregroundText: "#0F0F0F" |
640 | + overlay: "#ABCDEF" |
641 | + overlayText: "#0F0F0F" |
642 | + field: "#ABCDEF" |
643 | + fieldText: "#0F0F0F" |
644 | + selection: "#ABCDEF" |
645 | + } |
646 | + } |
647 | + } |
648 | +} |
649 | |
650 | === added file 'tests/unit/tst_performance/PaletteConfigurationOneColor.qml' |
651 | --- tests/unit/tst_performance/PaletteConfigurationOneColor.qml 1970-01-01 00:00:00 +0000 |
652 | +++ tests/unit/tst_performance/PaletteConfigurationOneColor.qml 2015-04-16 14:02:59 +0000 |
653 | @@ -0,0 +1,33 @@ |
654 | +/* |
655 | + * Copyright 2015 Canonical Ltd. |
656 | + * |
657 | + * This program is free software; you can redistribute it and/or modify |
658 | + * it under the terms of the GNU Lesser General Public License as published by |
659 | + * the Free Software Foundation; version 3. |
660 | + * |
661 | + * This program is distributed in the hope that it will be useful, |
662 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
663 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
664 | + * GNU Lesser General Public License for more details. |
665 | + * |
666 | + * You should have received a copy of the GNU Lesser General Public License |
667 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
668 | + */ |
669 | + |
670 | +import QtQuick 2.4 |
671 | +import Ubuntu.Components 1.3 |
672 | +import Ubuntu.Components.Themes 1.0 |
673 | + |
674 | +StyledItem { |
675 | + width: 100 |
676 | + height: 62 |
677 | + |
678 | + property string newTheme |
679 | + |
680 | + theme: ThemeSettings { |
681 | + name: newTheme |
682 | + palette: Palette { |
683 | + normal.background: "#ABCDEF" |
684 | + } |
685 | + } |
686 | +} |
687 | |
688 | === added file 'tests/unit/tst_performance/StyledItemNewTheming.qml' |
689 | --- tests/unit/tst_performance/StyledItemNewTheming.qml 1970-01-01 00:00:00 +0000 |
690 | +++ tests/unit/tst_performance/StyledItemNewTheming.qml 2015-04-16 14:02:59 +0000 |
691 | @@ -0,0 +1,72 @@ |
692 | +/* |
693 | + * Copyright 2015 Canonical Ltd. |
694 | + * |
695 | + * This program is free software; you can redistribute it and/or modify |
696 | + * it under the terms of the GNU Lesser General Public License as published by |
697 | + * the Free Software Foundation; version 3. |
698 | + * |
699 | + * This program is distributed in the hope that it will be useful, |
700 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
701 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
702 | + * GNU Lesser General Public License for more details. |
703 | + * |
704 | + * You should have received a copy of the GNU Lesser General Public License |
705 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
706 | + */ |
707 | + |
708 | +import QtQuick 2.4 |
709 | +import Ubuntu.Components 1.2 |
710 | + |
711 | +StyledItem { |
712 | + id: component1 |
713 | + width: units.gu(50) |
714 | + height: units.gu(100) |
715 | + |
716 | + property string newTheme |
717 | + onNewThemeChanged: theme.name = newTheme |
718 | + |
719 | + Column { |
720 | + anchors.fill: parent |
721 | + StyledItem { |
722 | + id: component2 |
723 | + width: units.gu(40) |
724 | + height: units.gu(80) |
725 | + |
726 | + StyledItem { |
727 | + id: component3 |
728 | + width: units.gu(40) |
729 | + height: units.gu(80) |
730 | + Item { |
731 | + anchors.fill: parent |
732 | + StyledItem { |
733 | + id: component4 |
734 | + width: units.gu(40) |
735 | + height: units.gu(80) |
736 | + } |
737 | + Loader { |
738 | + id: loader1 |
739 | + width: units.gu(30) |
740 | + height: units.gu(30) |
741 | + sourceComponent: dynamicItem |
742 | + } |
743 | + } |
744 | + } |
745 | + } |
746 | + Component { |
747 | + id: dynamicItem |
748 | + Item { |
749 | + StyledItem { |
750 | + id: component5 |
751 | + anchors.fill: parent |
752 | + } |
753 | + } |
754 | + } |
755 | + |
756 | + Loader { |
757 | + id: loader2 |
758 | + width: units.gu(30) |
759 | + height: units.gu(30) |
760 | + sourceComponent: dynamicItem |
761 | + } |
762 | + } |
763 | +} |
764 | |
765 | === modified file 'tests/unit/tst_performance/tst_performance.cpp' |
766 | --- tests/unit/tst_performance/tst_performance.cpp 2015-04-16 14:02:58 +0000 |
767 | +++ tests/unit/tst_performance/tst_performance.cpp 2015-04-16 14:02:59 +0000 |
768 | @@ -72,11 +72,14 @@ |
769 | { |
770 | QTest::addColumn<QString>("document"); |
771 | QTest::addColumn<QUrl>("theme"); |
772 | - QTest::addColumn<QString>("warning"); |
773 | |
774 | + QTest::newRow("new theming, subtheming enabled, no theme change") << "StyledItemNewTheming.qml" << QUrl(); |
775 | + QTest::newRow("new theming, subtheming enabled, with theme change") << "StyledItemNewTheming.qml" << QUrl("Ubuntu.Components.Themes.SuruDark"); |
776 | QTest::newRow("old theming, subtheming enabled") << "StyledItemOldTheming.qml" << QUrl("Ubuntu.Components.Themes.SuruDark"); |
777 | QTest::newRow("subtheming, no changes on themes") << "Styling.qml" << QUrl(); |
778 | QTest::newRow("subtheming, change mid item") << "Styling.qml" << QUrl("Ubuntu.Components.Themes.SuruDark"); |
779 | + QTest::newRow("Palette configuration of one color") << "PaletteConfigurationOneColor.qml" << QUrl("Ubuntu.Components.Themes.SuruDark"); |
780 | + QTest::newRow("Palette configuration of all colors") << "PaletteConfigurationAllColors.qml" << QUrl("Ubuntu.Components.Themes.SuruDark"); |
781 | } |
782 | void benchmark_theming() |
783 | { |
784 | |
785 | === modified file 'tests/unit/tst_performance/tst_performance.pro' |
786 | --- tests/unit/tst_performance/tst_performance.pro 2015-03-10 16:00:16 +0000 |
787 | +++ tests/unit/tst_performance/tst_performance.pro 2015-04-16 14:02:59 +0000 |
788 | @@ -27,4 +27,7 @@ |
789 | ListItemWithInlineActionsList.qml \ |
790 | ListItemWithActionsList.qml \ |
791 | StyledItemOldTheming.qml \ |
792 | - Styling.qml |
793 | + Styling.qml \ |
794 | + PaletteConfigurationOneColor.qml \ |
795 | + PaletteConfigurationAllColors.qml \ |
796 | + StyledItemNewTheming.qml |
797 | |
798 | === added file 'tests/unit_x11/tst_subtheming/ChangeDefaultPaletteInChildren.qml' |
799 | --- tests/unit_x11/tst_subtheming/ChangeDefaultPaletteInChildren.qml 1970-01-01 00:00:00 +0000 |
800 | +++ tests/unit_x11/tst_subtheming/ChangeDefaultPaletteInChildren.qml 2015-04-16 14:02:59 +0000 |
801 | @@ -0,0 +1,38 @@ |
802 | +/* |
803 | + * Copyright 2015 Canonical Ltd. |
804 | + * |
805 | + * This program is free software; you can redistribute it and/or modify |
806 | + * it under the terms of the GNU Lesser General Public License as published by |
807 | + * the Free Software Foundation; version 3. |
808 | + * |
809 | + * This program is distributed in the hope that it will be useful, |
810 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
811 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
812 | + * GNU Lesser General Public License for more details. |
813 | + * |
814 | + * You should have received a copy of the GNU Lesser General Public License |
815 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
816 | + */ |
817 | + |
818 | +import QtQuick 2.4 |
819 | +import Ubuntu.Components 1.3 |
820 | +import Ubuntu.Components.Themes 1.0 |
821 | + |
822 | +StyledItem { |
823 | + theme.objectName: "MasterTheme" |
824 | + Loader { |
825 | + objectName: "loader" |
826 | + anchors.fill: parent |
827 | + sourceComponent: dynamicItem |
828 | + } |
829 | + |
830 | + Component { |
831 | + id: dynamicItem |
832 | + StyledItem { |
833 | + theme.palette: Palette { |
834 | + normal.background: "blue" |
835 | + } |
836 | + } |
837 | + } |
838 | +} |
839 | + |
840 | |
841 | === added file 'tests/unit_x11/tst_subtheming/ChangePaletteValueWhenParentChanges.qml' |
842 | --- tests/unit_x11/tst_subtheming/ChangePaletteValueWhenParentChanges.qml 1970-01-01 00:00:00 +0000 |
843 | +++ tests/unit_x11/tst_subtheming/ChangePaletteValueWhenParentChanges.qml 2015-04-16 14:02:59 +0000 |
844 | @@ -0,0 +1,34 @@ |
845 | +/* |
846 | + * Copyright 2015 Canonical Ltd. |
847 | + * |
848 | + * This program is free software; you can redistribute it and/or modify |
849 | + * it under the terms of the GNU Lesser General Public License as published by |
850 | + * the Free Software Foundation; version 3. |
851 | + * |
852 | + * This program is distributed in the hope that it will be useful, |
853 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
854 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
855 | + * GNU Lesser General Public License for more details. |
856 | + * |
857 | + * You should have received a copy of the GNU Lesser General Public License |
858 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
859 | + */ |
860 | + |
861 | +import QtQuick 2.4 |
862 | +import Ubuntu.Components 1.3 |
863 | +import Ubuntu.Components.Themes 1.0 |
864 | + |
865 | +// the style of the root object will be changed |
866 | +StyledItem { |
867 | + theme.objectName: "MasterTheme" |
868 | + StyledItem { |
869 | + theme: ThemeSettings { |
870 | + objectName: "firstTheme" |
871 | + name: parentTheme.name |
872 | + palette: Palette { |
873 | + normal.background: "blue" |
874 | + } |
875 | + } |
876 | + } |
877 | +} |
878 | + |
879 | |
880 | === added file 'tests/unit_x11/tst_subtheming/DynamicPalette.qml' |
881 | --- tests/unit_x11/tst_subtheming/DynamicPalette.qml 1970-01-01 00:00:00 +0000 |
882 | +++ tests/unit_x11/tst_subtheming/DynamicPalette.qml 2015-04-16 14:02:59 +0000 |
883 | @@ -0,0 +1,47 @@ |
884 | +/* |
885 | + * Copyright 2015 Canonical Ltd. |
886 | + * |
887 | + * This program is free software; you can redistribute it and/or modify |
888 | + * it under the terms of the GNU Lesser General Public License as published by |
889 | + * the Free Software Foundation; version 3. |
890 | + * |
891 | + * This program is distributed in the hope that it will be useful, |
892 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
893 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
894 | + * GNU Lesser General Public License for more details. |
895 | + * |
896 | + * You should have received a copy of the GNU Lesser General Public License |
897 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
898 | + */ |
899 | + |
900 | +import QtQuick 2.4 |
901 | +import Ubuntu.Components 1.3 |
902 | +import Ubuntu.Components.Themes 1.0 |
903 | + |
904 | +StyledItem { |
905 | + theme.objectName: "MasterTheme" |
906 | + StyledItem { |
907 | + id: styled |
908 | + theme: ThemeSettings { |
909 | + objectName: "theme" |
910 | + } |
911 | + Loader { |
912 | + objectName: "paletteLoader" |
913 | + sourceComponent: paletteComponent |
914 | + onItemChanged: { |
915 | + if (item) { |
916 | + styled.theme.palette = item; |
917 | + } |
918 | + } |
919 | + } |
920 | + } |
921 | + |
922 | + Component { |
923 | + id: paletteComponent |
924 | + Palette { |
925 | + objectName: "palette" |
926 | + normal.background: "blue" |
927 | + } |
928 | + } |
929 | +} |
930 | + |
931 | |
932 | === added file 'tests/unit_x11/tst_subtheming/InvalidPalette.qml' |
933 | --- tests/unit_x11/tst_subtheming/InvalidPalette.qml 1970-01-01 00:00:00 +0000 |
934 | +++ tests/unit_x11/tst_subtheming/InvalidPalette.qml 2015-04-16 14:02:59 +0000 |
935 | @@ -0,0 +1,23 @@ |
936 | +/* |
937 | + * Copyright 2015 Canonical Ltd. |
938 | + * |
939 | + * This program is free software; you can redistribute it and/or modify |
940 | + * it under the terms of the GNU Lesser General Public License as published by |
941 | + * the Free Software Foundation; version 3. |
942 | + * |
943 | + * This program is distributed in the hope that it will be useful, |
944 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
945 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
946 | + * GNU Lesser General Public License for more details. |
947 | + * |
948 | + * You should have received a copy of the GNU Lesser General Public License |
949 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
950 | + */ |
951 | + |
952 | +import QtQuick 2.4 |
953 | +import Ubuntu.Components 1.3 |
954 | + |
955 | +StyledItem { |
956 | + id: item |
957 | + theme.palette: QtObject{} |
958 | +} |
959 | |
960 | === added file 'tests/unit_x11/tst_subtheming/MultiplePaletteInstances.qml' |
961 | --- tests/unit_x11/tst_subtheming/MultiplePaletteInstances.qml 1970-01-01 00:00:00 +0000 |
962 | +++ tests/unit_x11/tst_subtheming/MultiplePaletteInstances.qml 2015-04-16 14:02:59 +0000 |
963 | @@ -0,0 +1,38 @@ |
964 | +/* |
965 | + * Copyright 2015 Canonical Ltd. |
966 | + * |
967 | + * This program is free software; you can redistribute it and/or modify |
968 | + * it under the terms of the GNU Lesser General Public License as published by |
969 | + * the Free Software Foundation; version 3. |
970 | + * |
971 | + * This program is distributed in the hope that it will be useful, |
972 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
973 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
974 | + * GNU Lesser General Public License for more details. |
975 | + * |
976 | + * You should have received a copy of the GNU Lesser General Public License |
977 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
978 | + */ |
979 | + |
980 | +import QtQuick 2.4 |
981 | +import Ubuntu.Components 1.3 |
982 | +import Ubuntu.Components.Themes 1.0 |
983 | + |
984 | +StyledItem { |
985 | + theme.objectName: "MasterTheme" |
986 | + StyledItem { |
987 | + theme: ThemeSettings { |
988 | + objectName: "theme" |
989 | + } |
990 | + } |
991 | + |
992 | + Palette { |
993 | + objectName: "palette1" |
994 | + normal.background: "blue" |
995 | + } |
996 | + Palette { |
997 | + objectName: "palette2" |
998 | + normal.background: "pink" |
999 | + } |
1000 | +} |
1001 | + |
1002 | |
1003 | === added file 'tests/unit_x11/tst_subtheming/SameNamedPaletteSettings.qml' |
1004 | --- tests/unit_x11/tst_subtheming/SameNamedPaletteSettings.qml 1970-01-01 00:00:00 +0000 |
1005 | +++ tests/unit_x11/tst_subtheming/SameNamedPaletteSettings.qml 2015-04-16 14:02:59 +0000 |
1006 | @@ -0,0 +1,39 @@ |
1007 | +/* |
1008 | + * Copyright 2015 Canonical Ltd. |
1009 | + * |
1010 | + * This program is free software; you can redistribute it and/or modify |
1011 | + * it under the terms of the GNU Lesser General Public License as published by |
1012 | + * the Free Software Foundation; version 3. |
1013 | + * |
1014 | + * This program is distributed in the hope that it will be useful, |
1015 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1016 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1017 | + * GNU Lesser General Public License for more details. |
1018 | + * |
1019 | + * You should have received a copy of the GNU Lesser General Public License |
1020 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1021 | + */ |
1022 | + |
1023 | +import QtQuick 2.4 |
1024 | +import Ubuntu.Components 1.3 |
1025 | +import Ubuntu.Components.Themes 1.0 |
1026 | + |
1027 | +Item { |
1028 | + StyledItem { |
1029 | + theme: ThemeSettings { |
1030 | + objectName: "firstTheme" |
1031 | + name: "Ubuntu.Components.Themes.SuruDark" |
1032 | + palette: Palette{ |
1033 | + normal.background: UbuntuColors.red |
1034 | + } |
1035 | + } |
1036 | + } |
1037 | + StyledItem { |
1038 | + theme: ThemeSettings { |
1039 | + objectName: "secondTheme" |
1040 | + name: "Ubuntu.Components.Themes.SuruDark" |
1041 | + } |
1042 | + } |
1043 | + |
1044 | +} |
1045 | + |
1046 | |
1047 | === added file 'tests/unit_x11/tst_subtheming/themes/CustomTheme/Palette.qml' |
1048 | --- tests/unit_x11/tst_subtheming/themes/CustomTheme/Palette.qml 1970-01-01 00:00:00 +0000 |
1049 | +++ tests/unit_x11/tst_subtheming/themes/CustomTheme/Palette.qml 2015-04-16 14:02:59 +0000 |
1050 | @@ -0,0 +1,29 @@ |
1051 | +/* |
1052 | + * Copyright 2015 Canonical Ltd. |
1053 | + * |
1054 | + * This program is free software; you can redistribute it and/or modify |
1055 | + * it under the terms of the GNU Lesser General Public License as published by |
1056 | + * the Free Software Foundation; version 3. |
1057 | + * |
1058 | + * This program is distributed in the hope that it will be useful, |
1059 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1060 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1061 | + * GNU Lesser General Public License for more details. |
1062 | + * |
1063 | + * You should have received a copy of the GNU Lesser General Public License |
1064 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1065 | + */ |
1066 | + |
1067 | +import QtQuick 2.4 |
1068 | +import Ubuntu.Components 1.3 |
1069 | +import Ubuntu.Components.Themes.Ambiance 1.1 as Suru |
1070 | + |
1071 | +Suru.Palette { |
1072 | + normal.selection: "#A21E1C" |
1073 | + selected.selection: "#1C1EA2" |
1074 | + selected.base: "lightblue" |
1075 | + selected.baseText: "pink" |
1076 | + selected.overlay: "#ABCDEF" |
1077 | + selected.overlayText: "#FEDCBA" |
1078 | + selected.fieldText: UbuntuColors.red |
1079 | +} |
1080 | |
1081 | === modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp' |
1082 | --- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-04-16 14:02:58 +0000 |
1083 | +++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-04-16 14:02:59 +0000 |
1084 | @@ -474,6 +474,101 @@ |
1085 | QCOMPARE(UCStyledItemBasePrivate::get(main)->getTheme()->name(), |
1086 | UCStyledItemBasePrivate::get(test)->getTheme()->name()); |
1087 | } |
1088 | + |
1089 | + void test_no_change_in_other_suru_dark() |
1090 | + { |
1091 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("SameNamedPaletteSettings.qml")); |
1092 | + UCTheme *firstTheme = view->findItem<UCTheme*>("firstTheme"); |
1093 | + UCTheme *secondTheme = view->findItem<UCTheme*>("secondTheme"); |
1094 | + QVERIFY(firstTheme->getPaletteColor("normal", "background") != secondTheme->getPaletteColor("normal", "background")); |
1095 | + } |
1096 | + |
1097 | + void test_keep_palette_value_when_theme_changes() |
1098 | + { |
1099 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("ChangePaletteValueWhenParentChanges.qml")); |
1100 | + UCTheme *firstTheme = view->findItem<UCTheme*>("firstTheme"); |
1101 | + |
1102 | + QCOMPARE(firstTheme->getPaletteColor("normal", "background"), QColor("blue")); |
1103 | + // change the theme |
1104 | + view->setGlobalTheme("Ubuntu.Components.Themes.SuruDark"); |
1105 | + QTest::waitForEvents(); |
1106 | + QCOMPARE(firstTheme->getPaletteColor("normal", "background"), QColor("blue")); |
1107 | + } |
1108 | + |
1109 | + void test_change_default_palette_in_children_kept_after_child_deletion() |
1110 | + { |
1111 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("ChangeDefaultPaletteInChildren.qml")); |
1112 | + QQuickItem *loader = view->findItem<QQuickItem*>("loader"); |
1113 | + UCStyledItemBase *main = qobject_cast<UCStyledItemBase*>(view->rootObject()); |
1114 | + UCTheme *mainSet = UCStyledItemBasePrivate::get(main)->getTheme(); |
1115 | + QQuickItem *item = loader->property("item").value<QQuickItem*>(); |
1116 | + QVERIFY(item); |
1117 | + |
1118 | + QCOMPARE(mainSet->getPaletteColor("normal", "background"), QColor("blue")); |
1119 | + // unload component |
1120 | + QSignalSpy itemSpy(item, SIGNAL(destroyed())); |
1121 | + loader->setProperty("sourceComponent", QVariant()); |
1122 | + itemSpy.wait(); |
1123 | + // palette stays! |
1124 | + QCOMPARE(mainSet->getPaletteColor("normal", "background"), QColor("blue")); |
1125 | + } |
1126 | + |
1127 | + void test_reset_palette_to_theme_default() |
1128 | + { |
1129 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("ChangePaletteValueWhenParentChanges.qml")); |
1130 | + UCTheme *firstTheme = view->findItem<UCTheme*>("firstTheme"); |
1131 | + QColor prevColor = firstTheme->getPaletteColor("normal", "background"); |
1132 | + |
1133 | + QVERIFY(prevColor.isValid()); |
1134 | + // reset palette |
1135 | + QSignalSpy spy(firstTheme, SIGNAL(paletteChanged())); |
1136 | + firstTheme->setPalette(NULL); |
1137 | + spy.wait(200); |
1138 | + QVERIFY(firstTheme->getPaletteColor("normal", "background") != prevColor); |
1139 | + } |
1140 | + |
1141 | + void test_multiple_palette_instances() |
1142 | + { |
1143 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("MultiplePaletteInstances.qml")); |
1144 | + UCTheme *theme = view->findItem<UCTheme*>("theme"); |
1145 | + QObject *palette1 = view->findItem<QObject*>("palette1"); |
1146 | + QObject *palette2 = view->findItem<QObject*>("palette2"); |
1147 | + QColor prevColor = theme->getPaletteColor("normal", "background"); |
1148 | + |
1149 | + // set the first palette |
1150 | + QSignalSpy spy(theme, SIGNAL(paletteChanged())); |
1151 | + theme->setPalette(palette1); |
1152 | + spy.wait(200); |
1153 | + QVERIFY(prevColor != theme->getPaletteColor("normal", "background")); |
1154 | + QCOMPARE(theme->getPaletteColor("normal", "background"), QColor("blue")); |
1155 | + |
1156 | + spy.clear(); |
1157 | + theme->setPalette(palette2); |
1158 | + spy.wait(200); |
1159 | + QVERIFY(prevColor != theme->getPaletteColor("normal", "background")); |
1160 | + QCOMPARE(theme->getPaletteColor("normal", "background"), QColor("pink")); |
1161 | + } |
1162 | + |
1163 | + void test_dynamic_palette() |
1164 | + { |
1165 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("DynamicPalette.qml")); |
1166 | + UCTheme *theme = view->findItem<UCTheme*>("theme"); |
1167 | + QQuickItem *loader = view->findItem<QQuickItem*>("paletteLoader"); |
1168 | + |
1169 | + QVERIFY(theme->getPaletteColor("normal", "background") == QColor("blue")); |
1170 | + |
1171 | + QSignalSpy spy(loader, SIGNAL(itemChanged())); |
1172 | + loader->setProperty("sourceComponent", QVariant()); |
1173 | + spy.wait(200); |
1174 | + // unloaded palette by Loader should remove palette configuration |
1175 | + QVERIFY(theme->getPaletteColor("normal", "background") != QColor("blue")); |
1176 | + } |
1177 | + |
1178 | + void test_invalid_palette_object() |
1179 | + { |
1180 | + ThemeTestCase::ignoreWarning("InvalidPalette.qml", 22, 20, "QML QtObject: Not a Palette component."); |
1181 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("InvalidPalette.qml")); |
1182 | + } |
1183 | }; |
1184 | |
1185 | QTEST_MAIN(tst_Subtheming) |
1186 | |
1187 | === modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.pro' |
1188 | --- tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-03-12 20:52:56 +0000 |
1189 | +++ tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-04-16 14:02:59 +0000 |
1190 | @@ -5,9 +5,8 @@ |
1191 | OTHER_FILES += \ |
1192 | TestStyle.qml \ |
1193 | SimpleItem.qml \ |
1194 | - themes/AppTheme/Palette.qml \ |
1195 | - themes/AppTheme/parent_theme \ |
1196 | themes/CustomTheme/TestStyle.qml \ |
1197 | + themes/CustomTheme/Palette.qml \ |
1198 | themes/CustomTheme/parent_theme \ |
1199 | themes/TestModule/TestTheme/TestStyle.qml \ |
1200 | themes/TestModule/TestTheme/qmldir \ |
1201 | @@ -16,5 +15,12 @@ |
1202 | ParentChanges.qml \ |
1203 | TestMain.qml \ |
1204 | TestStyleChange.qml \ |
1205 | - DifferentThemes.qml |
1206 | + DifferentThemes.qml \ |
1207 | + SameNamedPaletteSettings.qml \ |
1208 | + ChangePaletteValueWhenParentChanges.qml \ |
1209 | + ChangeDefaultPaletteInChildren.qml \ |
1210 | + MultiplePaletteInstances.qml \ |
1211 | + DynamicPalette.qml \ |
1212 | + InvalidPalette.qml |
1213 | + |
1214 |
FAILED: Continuous integration, rev:1469 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1617/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 2068 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-amd64- ci/344 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/347 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/347/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-i386- ci/344 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 1820 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2066 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2066/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 19331
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1617/ rebuild
http://