Merge lp:~zsombi/ubuntu-ui-toolkit/fixStyleVersionLoaded into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 1895
Merged at revision: 1892
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/fixStyleVersionLoaded
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 197 lines (+105/-29)
6 files modified
src/Ubuntu/Components/plugin/uctheme.cpp (+30/-25)
tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.2/TestStyle.qml (+21/-0)
tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.3/Palette.qml (+29/-0)
tests/unit_x11/tst_subtheming/themes/DerivedTheme/parent_theme (+1/-0)
tests/unit_x11/tst_subtheming/tst_subtheming.cpp (+19/-0)
tests/unit_x11/tst_subtheming/tst_subtheming.pro (+5/-4)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/fixStyleVersionLoaded
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Tim Peeters Approve
Review via email: mp+288937@code.launchpad.net

Commit message

Pick up the right style.

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

Good. Only one comment about the name of the test below.

review: Needs Fixing
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

thanks

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

armhf builds seem broken in several MRs.

Let's try again.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

(and again, pbuilder now recreated during the night)

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/uctheme.cpp'
2--- src/Ubuntu/Components/plugin/uctheme.cpp 2016-03-07 15:51:52 +0000
3+++ src/Ubuntu/Components/plugin/uctheme.cpp 2016-03-14 18:20:09 +0000
4@@ -587,25 +587,30 @@
5 if (isFallback) {
6 (*isFallback) = false;
7 }
8- Q_FOREACH (const ThemeRecord &themePath, m_themePaths) {
9- QUrl styleUrl;
10- /*
11- * There are two cases where we have to deal with non-versioned styles: application
12- * themes made for the previous theming and deprecated themes. For shared themes,
13- * we have to check the fallback case.
14- */
15- quint16 styleVersion = version;
16- if (themePath.deprecated) {
17- styleVersion = 0;
18- }
19- if (themePath.shared && (version < BUILD_VERSION(1, 2))) {
20- styleVersion = LATEST_UITK_VERSION;
21- }
22-
23- // loop through the versions to see if we have one matching
24- // we stop at version 1.2 as we do not have support for earlier themes anymore.
25- for (int minor = MINOR_VERSION(styleVersion); minor >= 2; minor--) {
26- QString versionedName = QStringLiteral("%1.%2/%3").arg(MAJOR_VERSION(styleVersion)).arg(minor).arg(styleName);
27+
28+ // loop through the versions first, so we will look after the style in all
29+ // the parents, then fall back to the older version
30+ quint16 major = MAJOR_VERSION(version);
31+ // loop through the versions to see if we have one matching
32+ // we stop at version 1.2 as we do not have support for earlier themes anymore.
33+ for (int minor = MINOR_VERSION(version); minor >= 2; minor--) {
34+ // check with each path of the theme
35+ Q_FOREACH (const ThemeRecord &themePath, m_themePaths) {
36+ QUrl styleUrl;
37+ /*
38+ * There are two cases where we have to deal with non-versioned styles: application
39+ * themes made for the previous theming and deprecated themes. For shared themes,
40+ * we have to check the fallback case.
41+ */
42+ quint16 styleVersion = BUILD_VERSION(major, minor);
43+ if (themePath.deprecated) {
44+ styleVersion = 0;
45+ }
46+ if (themePath.shared && (minor < 2)) {
47+ styleVersion = LATEST_UITK_VERSION;
48+ }
49+
50+ QString versionedName = QStringLiteral("%1.%2/%3").arg(major).arg(minor).arg(styleName);
51 styleUrl = themePath.path.resolved(versionedName);
52 if (styleUrl.isValid() && QFile::exists(styleUrl.toLocalFile())) {
53 // set fallback warning if the theme is shared
54@@ -614,13 +619,13 @@
55 }
56 return styleUrl;
57 }
58- }
59
60- // if we don't get any style, get the non-versioned ones for non-shared and deprecated styles
61- if (!themePath.shared || themePath.deprecated) {
62- styleUrl = themePath.path.resolved(styleName);
63- if (styleUrl.isValid() && QFile::exists(styleUrl.toLocalFile())) {
64- return styleUrl;
65+ // if we don't get any style, get the non-versioned ones for non-shared and deprecated styles
66+ if (!themePath.shared || themePath.deprecated) {
67+ styleUrl = themePath.path.resolved(styleName);
68+ if (styleUrl.isValid() && QFile::exists(styleUrl.toLocalFile())) {
69+ return styleUrl;
70+ }
71 }
72 }
73 }
74
75=== added directory 'tests/unit_x11/tst_subtheming/themes/DerivedTheme'
76=== added directory 'tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.2'
77=== added file 'tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.2/TestStyle.qml'
78--- tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.2/TestStyle.qml 1970-01-01 00:00:00 +0000
79+++ tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.2/TestStyle.qml 2016-03-14 18:20:09 +0000
80@@ -0,0 +1,21 @@
81+/*
82+ * Copyright 2016 Canonical Ltd.
83+ *
84+ * This program is free software; you can redistribute it and/or modify
85+ * it under the terms of the GNU Lesser General Public License as published by
86+ * the Free Software Foundation; version 3.
87+ *
88+ * This program is distributed in the hope that it will be useful,
89+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
90+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91+ * GNU Lesser General Public License for more details.
92+ *
93+ * You should have received a copy of the GNU Lesser General Public License
94+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
95+ */
96+
97+import QtQuick 2.0
98+
99+Item {
100+ objectName: "TestStyle"
101+}
102
103=== added directory 'tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.3'
104=== added file 'tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.3/Palette.qml'
105--- tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.3/Palette.qml 1970-01-01 00:00:00 +0000
106+++ tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.3/Palette.qml 2016-03-14 18:20:09 +0000
107@@ -0,0 +1,29 @@
108+/*
109+ * Copyright 2016 Canonical Ltd.
110+ *
111+ * This program is free software; you can redistribute it and/or modify
112+ * it under the terms of the GNU Lesser General Public License as published by
113+ * the Free Software Foundation; version 3.
114+ *
115+ * This program is distributed in the hope that it will be useful,
116+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
117+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
118+ * GNU Lesser General Public License for more details.
119+ *
120+ * You should have received a copy of the GNU Lesser General Public License
121+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
122+ */
123+
124+import QtQuick 2.4
125+import Ubuntu.Components 1.3
126+import Ubuntu.Components.Themes.Ambiance 1.3 as Suru
127+
128+Suru.Palette {
129+ normal.selection: UbuntuColors.orange
130+ selected.selection: UbuntuColors.lightGrey
131+ selected.base: "lightblue"
132+ selected.baseText: "pink"
133+ selected.overlay: "#ABCDEF"
134+ selected.overlayText: "#FEDCBA"
135+ selected.fieldText: UbuntuColors.red
136+}
137
138=== added file 'tests/unit_x11/tst_subtheming/themes/DerivedTheme/parent_theme'
139--- tests/unit_x11/tst_subtheming/themes/DerivedTheme/parent_theme 1970-01-01 00:00:00 +0000
140+++ tests/unit_x11/tst_subtheming/themes/DerivedTheme/parent_theme 2016-03-14 18:20:09 +0000
141@@ -0,0 +1,1 @@
142+TestTheme
143
144=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp'
145--- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2016-01-30 10:51:22 +0000
146+++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2016-03-14 18:20:09 +0000
147@@ -20,7 +20,11 @@
148 #include <QtQml/QQmlEngine>
149 #include <QtQml/QQmlContext>
150 #include <QtQml/QQmlComponent>
151+#define private public
152+#define protected public
153 #include "uctheme.h"
154+#undef protected
155+#undef private
156 #include "quickutils.h"
157 #include "uctestcase.h"
158 #include "ucstyleditembase_p.h"
159@@ -898,6 +902,21 @@
160 QTest::mouseRelease(view.data(), Qt::LeftButton, 0, pressPt.toPoint());
161 QCOMPARE(pressedColor, colorPressed);
162 }
163+
164+ void test_derived_theme_fallback_should_use_proper_style_bug1555797() {
165+ qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
166+ qputenv("XDG_DATA_DIRS", "./themes:./themes/TestModule");
167+
168+ QQmlEngine engine;
169+ UbuntuComponentsPlugin::initializeContextProperties(&engine);
170+ QScopedPointer<UCTheme> theme(new UCTheme);
171+ theme->setName("DerivedTheme");
172+
173+ // get the style URL
174+ bool fallback = false;
175+ QUrl style = theme->styleUrl("TestStyle.qml", BUILD_VERSION(1, 3), &fallback);
176+ QVERIFY(style.toString().endsWith("TestTheme/1.3/TestStyle.qml"));
177+ }
178 };
179
180 QTEST_MAIN(tst_Subtheming)
181
182=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.pro'
183--- tests/unit_x11/tst_subtheming/tst_subtheming.pro 2016-01-08 09:31:30 +0000
184+++ tests/unit_x11/tst_subtheming/tst_subtheming.pro 2016-03-14 18:20:09 +0000
185@@ -42,9 +42,10 @@
186 GroupPropertyBindingHints.qml \
187 OverrideStyleHints.qml \
188 HintedButton.qml \
189- OtherVersion.qml
190-
191-DISTFILES += \
192- DefaultTheme.qml
193+ OtherVersion.qml \
194+ DefaultTheme.qml \
195+ themes/DerivedTheme/parent_theme \
196+ themes/DerivedTheme/1.2/TestStyle.qml \
197+ themes/DerivedTheme/1.3/Palette.qml
198
199

Subscribers

People subscribed via source and target branches