Merge lp:~zsombi/ubuntu-ui-toolkit/theme_versioning into lp:ubuntu-ui-toolkit/staging
- theme_versioning
- Merge into staging
Status: | Superseded | ||||||||
---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/theme_versioning | ||||||||
Merge into: | lp:ubuntu-ui-toolkit/staging | ||||||||
Prerequisite: | lp:~zsombi/ubuntu-ui-toolkit/listitem_slowdown | ||||||||
Diff against target: |
1885 lines (+402/-431) 55 files modified
components.api (+0/-2) src/Ubuntu/Components/1.2/MainViewBase.qml (+4/-4) src/Ubuntu/Components/1.3/AdaptivePageLayout.qml (+0/-1) src/Ubuntu/Components/1.3/AnimatedItem.qml (+2/-3) src/Ubuntu/Components/1.3/AppHeader.qml (+0/-1) src/Ubuntu/Components/1.3/Button.qml (+0/-1) src/Ubuntu/Components/1.3/CheckBox.qml (+0/-1) src/Ubuntu/Components/1.3/OptionSelector.qml (+0/-1) src/Ubuntu/Components/1.3/PageTreeNode.qml (+0/-2) src/Ubuntu/Components/1.3/ProgressBar.qml (+0/-1) src/Ubuntu/Components/1.3/PullToRefresh.qml (+0/-1) src/Ubuntu/Components/1.3/Scrollbar.qml (+0/-1) src/Ubuntu/Components/1.3/Sections.qml (+0/-1) src/Ubuntu/Components/1.3/Slider.qml (+0/-1) src/Ubuntu/Components/1.3/TabBar.qml (+0/-1) src/Ubuntu/Components/1.3/TextArea.qml (+0/-1) src/Ubuntu/Components/1.3/TextCursor.qml (+0/-1) src/Ubuntu/Components/1.3/TextField.qml (+0/-1) src/Ubuntu/Components/1.3/TextInputPopover.qml (+0/-1) src/Ubuntu/Components/1.3/Toolbar.qml (+0/-1) src/Ubuntu/Components/1.3/ToolbarButton.qml (+0/-1) src/Ubuntu/Components/ListItems/1.3/ItemSelector.qml (+0/-1) src/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml (+0/-1) src/Ubuntu/Components/Pickers/1.3/DatePicker.qml (+0/-1) src/Ubuntu/Components/Pickers/1.3/Dialer.qml (+0/-1) src/Ubuntu/Components/Pickers/1.3/DialerHand.qml (+0/-1) src/Ubuntu/Components/Pickers/1.3/Picker.qml (+0/-1) src/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml (+0/-1) src/Ubuntu/Components/Popups/1.3/Dialog.qml (+0/-1) src/Ubuntu/Components/Popups/1.3/Popover.qml (+0/-1) src/Ubuntu/Components/Popups/1.3/SheetBase.qml (+0/-1) src/Ubuntu/Components/Themes/Ambiance/1.2/OptionSelectorStyle.qml (+1/-0) src/Ubuntu/Components/Themes/Ambiance/1.3/OptionSelectorStyle.qml (+1/-0) src/Ubuntu/Components/plugin/plugin.cpp (+0/-1) src/Ubuntu/Components/plugin/plugin.pri (+4/-2) src/Ubuntu/Components/plugin/ucimportversionchecker_p.cpp (+58/-0) src/Ubuntu/Components/plugin/ucimportversionchecker_p.h (+34/-0) src/Ubuntu/Components/plugin/uclabel.cpp (+1/-8) src/Ubuntu/Components/plugin/uclabel.h (+1/-2) src/Ubuntu/Components/plugin/uclistitem.cpp (+11/-8) src/Ubuntu/Components/plugin/ucstyleditembase.cpp (+22/-32) src/Ubuntu/Components/plugin/ucstyleditembase.h (+8/-4) src/Ubuntu/Components/plugin/ucstyleditembase_p.h (+5/-3) src/Ubuntu/Components/plugin/uctheme.cpp (+34/-49) src/Ubuntu/Components/plugin/uctheme.h (+7/-4) src/Ubuntu/Components/plugin/ucthemingextension.cpp (+122/-135) src/Ubuntu/Components/plugin/ucthemingextension.h (+11/-56) tests/unit_x11/tst_subtheming/OtherVersion.qml (+25/-0) tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml (+0/-24) tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml (+0/-1) tests/unit_x11/tst_subtheming/StyledItemFallback.qml (+0/-24) tests/unit_x11/tst_subtheming/StyledItemV12.qml (+4/-4) tests/unit_x11/tst_subtheming/StyledItemV13.qml (+0/-1) tests/unit_x11/tst_subtheming/tst_subtheming.cpp (+45/-32) tests/unit_x11/tst_subtheming/tst_subtheming.pro (+2/-3) |
||||||||
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/theme_versioning | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cris Dywan | Needs Fixing | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+272563@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-10-20.
Commit message
Provide import version information for StyledItema and remove theme.version obsolete property.
-= DO NOT HAPPROVE IT =-
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1657
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1658
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
- 1659. By Zsombor Egri
-
staging sync
- 1660. By Zsombor Egri
-
fixing crashes and types
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1660
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1661. By Zsombor Egri
-
reverting removed AnimatedItem type
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1661
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1662. By Zsombor Egri
-
staging sync
- 1663. By Zsombor Egri
-
StyledItems load the style based on teh import version and not falling back to the smallest imported version in case imports are mixed
- 1664. By Zsombor Egri
-
staging sync
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1664
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
+ qWarning() << msg;
I only realized now the message is a bit awkward, the suggestions to improve it:
Use qmlInfo so it shows the offending component.
Use a static bool to show it once - it's enough to give you a hint, too many warnings are not useful and potentially a performance issue, as we found with deprecations, so let's make it work the same way.
And the mixing now works like it did before. So you don't get tons of errors, but you do get a clear message. Thanks a lot for this change! Less is more also in this case!
Cris Dywan (kalikiana) wrote : | # |
As https:/
- 1665. By Zsombor Egri
-
new prereq sync
- 1666. By Zsombor Egri
-
use qmlInfo to locate the component where the version mixing is detected
- 1667. By Zsombor Egri
-
removing orphan theme.version from PageHeader.qml
Unmerged revisions
Preview Diff
1 | === modified file 'components.api' |
2 | --- components.api 2015-10-15 14:17:25 +0000 |
3 | +++ components.api 2015-10-20 11:06:17 +0000 |
4 | @@ -1363,7 +1363,6 @@ |
5 | property string name |
6 | property QtObject palette |
7 | readonly property ThemeSettings parentTheme |
8 | - property ushort version |
9 | Ubuntu.Components.ListItems.ThinDivider 1.0 0.1: Rectangle |
10 | Ubuntu.Components.ListItems.ThinDivider 1.3: Rectangle |
11 | Ubuntu.Components.ToolbarButton 1.0 0.1: StyledItem |
12 | @@ -1400,7 +1399,6 @@ |
13 | Ubuntu.Components.UCFontUtils 1.0 0.1: QtObject |
14 | function double sizeToPixels(string size) |
15 | function double modularScale(string size) |
16 | -UCItemAttached: QtObject |
17 | UCListItemDivider: Item |
18 | property color colorFrom |
19 | property color colorTo |
20 | |
21 | === modified file 'src/Ubuntu/Components/1.2/MainViewBase.qml' |
22 | --- src/Ubuntu/Components/1.2/MainViewBase.qml 2015-04-30 08:32:44 +0000 |
23 | +++ src/Ubuntu/Components/1.2/MainViewBase.qml 2015-10-20 11:06:17 +0000 |
24 | @@ -48,12 +48,12 @@ |
25 | |
26 | Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712 |
27 | */ |
28 | - property string theme: (ColorUtils.luminance(backgroundColor) >= 0.85) ? |
29 | + property string themeName: (ColorUtils.luminance(backgroundColor) >= 0.85) ? |
30 | "Ambiance" : "SuruDark" |
31 | - onThemeChanged: { |
32 | + onThemeNameChanged: { |
33 | // only change the theme if the current one is a system one. |
34 | - if (theme !== "" && (Theme.name.search("Ubuntu.Components.Themes") >= 0)) { |
35 | - Theme.name = "Ubuntu.Components.Themes.%1".arg(theme); |
36 | + if (themeName !== "" && (Theme.name.search("Ubuntu.Components.Themes") >= 0)) { |
37 | + Theme.name = "Ubuntu.Components.Themes.%1".arg(themeName); |
38 | } |
39 | } |
40 | } |
41 | |
42 | === modified file 'src/Ubuntu/Components/1.3/AdaptivePageLayout.qml' |
43 | --- src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2015-10-16 11:22:54 +0000 |
44 | +++ src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2015-10-20 11:06:17 +0000 |
45 | @@ -717,7 +717,6 @@ |
46 | height: body.headerHeight |
47 | |
48 | styleName: "PageHeadStyle" |
49 | - theme.version: Ubuntu.toolkitVersion |
50 | objectName: "Header" + column |
51 | |
52 | property real preferredHeight: subHeader.__styleInstance ? |
53 | |
54 | === modified file 'src/Ubuntu/Components/1.3/AnimatedItem.qml' |
55 | --- src/Ubuntu/Components/1.3/AnimatedItem.qml 2015-04-25 08:54:58 +0000 |
56 | +++ src/Ubuntu/Components/1.3/AnimatedItem.qml 2015-10-20 11:06:17 +0000 |
57 | @@ -25,14 +25,13 @@ |
58 | */ |
59 | |
60 | import QtQuick 2.4 |
61 | -import Ubuntu.Components 1.3 as Toolkit |
62 | +import Ubuntu.Components 1.3 |
63 | |
64 | -Toolkit.StyledItem { |
65 | +StyledItem { |
66 | id: root |
67 | /*! |
68 | \deprecated |
69 | Specifies whether the component is on the visible area of the Flickable or not. |
70 | */ |
71 | - theme.version: Toolkit.Ubuntu.toolkitVersion |
72 | property bool onScreen: true |
73 | } |
74 | |
75 | === modified file 'src/Ubuntu/Components/1.3/AppHeader.qml' |
76 | --- src/Ubuntu/Components/1.3/AppHeader.qml 2015-10-01 21:23:04 +0000 |
77 | +++ src/Ubuntu/Components/1.3/AppHeader.qml 2015-10-20 11:06:17 +0000 |
78 | @@ -151,6 +151,5 @@ |
79 | } |
80 | } |
81 | |
82 | - theme.version: Components.Ubuntu.toolkitVersion |
83 | styleName: "PageHeadStyle" |
84 | } |
85 | |
86 | === modified file 'src/Ubuntu/Components/1.3/Button.qml' |
87 | --- src/Ubuntu/Components/1.3/Button.qml 2015-08-20 06:56:44 +0000 |
88 | +++ src/Ubuntu/Components/1.3/Button.qml 2015-10-20 11:06:17 +0000 |
89 | @@ -121,6 +121,5 @@ |
90 | */ |
91 | property string iconPosition: "left" |
92 | |
93 | - theme.version: Ubuntu.toolkitVersion |
94 | styleName: "ButtonStyle" |
95 | } |
96 | |
97 | === modified file 'src/Ubuntu/Components/1.3/CheckBox.qml' |
98 | --- src/Ubuntu/Components/1.3/CheckBox.qml 2015-09-16 16:58:51 +0000 |
99 | +++ src/Ubuntu/Components/1.3/CheckBox.qml 2015-10-20 11:06:17 +0000 |
100 | @@ -49,6 +49,5 @@ |
101 | */ |
102 | onTriggered: checked = !checked |
103 | |
104 | - theme.version: Ubuntu.toolkitVersion |
105 | styleName: "CheckBoxStyle" |
106 | } |
107 | |
108 | === modified file 'src/Ubuntu/Components/1.3/OptionSelector.qml' |
109 | --- src/Ubuntu/Components/1.3/OptionSelector.qml 2015-09-07 10:05:58 +0000 |
110 | +++ src/Ubuntu/Components/1.3/OptionSelector.qml 2015-10-20 11:06:17 +0000 |
111 | @@ -225,7 +225,6 @@ |
112 | right: parent.right |
113 | } |
114 | state: optionSelector.expanded ? "expanded" : "collapsed" |
115 | - theme.version: Toolkit.Ubuntu.toolkitVersion |
116 | styleName: "OptionSelectorStyle" |
117 | states: [ State { |
118 | name: "expanded" |
119 | |
120 | === modified file 'src/Ubuntu/Components/1.3/PageTreeNode.qml' |
121 | --- src/Ubuntu/Components/1.3/PageTreeNode.qml 2015-10-14 19:18:58 +0000 |
122 | +++ src/Ubuntu/Components/1.3/PageTreeNode.qml 2015-10-20 11:06:17 +0000 |
123 | @@ -148,6 +148,4 @@ |
124 | node.parentNode = internal.getParentPageTreeNode(node); |
125 | } |
126 | } |
127 | - |
128 | - theme.version: Toolkit.Ubuntu.toolkitVersion |
129 | } |
130 | |
131 | === modified file 'src/Ubuntu/Components/1.3/ProgressBar.qml' |
132 | --- src/Ubuntu/Components/1.3/ProgressBar.qml 2015-05-21 10:50:35 +0000 |
133 | +++ src/Ubuntu/Components/1.3/ProgressBar.qml 2015-10-20 11:06:17 +0000 |
134 | @@ -70,6 +70,5 @@ |
135 | */ |
136 | property bool showProgressPercentage: true |
137 | |
138 | - theme.version: Ubuntu.toolkitVersion |
139 | styleName: "ProgressBarStyle" |
140 | } |
141 | |
142 | === modified file 'src/Ubuntu/Components/1.3/PullToRefresh.qml' |
143 | --- src/Ubuntu/Components/1.3/PullToRefresh.qml 2015-05-21 10:50:35 +0000 |
144 | +++ src/Ubuntu/Components/1.3/PullToRefresh.qml 2015-10-20 11:06:17 +0000 |
145 | @@ -222,7 +222,6 @@ |
146 | */ |
147 | signal refresh() |
148 | |
149 | - theme.version: Ubuntu.toolkitVersion |
150 | styleName: "PullToRefreshStyle" |
151 | implicitHeight: __styleInstance.implicitHeight |
152 | anchors { |
153 | |
154 | === modified file 'src/Ubuntu/Components/1.3/Scrollbar.qml' |
155 | --- src/Ubuntu/Components/1.3/Scrollbar.qml 2015-05-21 10:50:35 +0000 |
156 | +++ src/Ubuntu/Components/1.3/Scrollbar.qml 2015-10-20 11:06:17 +0000 |
157 | @@ -146,6 +146,5 @@ |
158 | } |
159 | } |
160 | |
161 | - theme.version: Toolkit.Ubuntu.toolkitVersion |
162 | styleName: "ScrollbarStyle" |
163 | } |
164 | |
165 | === modified file 'src/Ubuntu/Components/1.3/Sections.qml' |
166 | --- src/Ubuntu/Components/1.3/Sections.qml 2015-07-14 12:49:58 +0000 |
167 | +++ src/Ubuntu/Components/1.3/Sections.qml 2015-10-20 11:06:17 +0000 |
168 | @@ -29,7 +29,6 @@ |
169 | StyledItem { |
170 | id: sections |
171 | styleName: "SectionsStyle" |
172 | - theme.version: Ubuntu.toolkitVersion |
173 | |
174 | /*! |
175 | List of actions that represent the sections. |
176 | |
177 | === modified file 'src/Ubuntu/Components/1.3/Slider.qml' |
178 | --- src/Ubuntu/Components/1.3/Slider.qml 2015-05-21 10:50:35 +0000 |
179 | +++ src/Ubuntu/Components/1.3/Slider.qml 2015-10-20 11:06:17 +0000 |
180 | @@ -206,6 +206,5 @@ |
181 | onLiveValueChanged: if (isPressed) slider.requestFocus(Qt.MouseFocusReason) |
182 | } |
183 | |
184 | - theme.version: Toolkit.Ubuntu.toolkitVersion |
185 | styleName: "SliderStyle" |
186 | } |
187 | |
188 | === modified file 'src/Ubuntu/Components/1.3/TabBar.qml' |
189 | --- src/Ubuntu/Components/1.3/TabBar.qml 2015-05-21 10:50:35 +0000 |
190 | +++ src/Ubuntu/Components/1.3/TabBar.qml 2015-10-20 11:06:17 +0000 |
191 | @@ -97,7 +97,6 @@ |
192 | |
193 | implicitHeight: units.gu(7.5) |
194 | activeFocusOnPress: true |
195 | - theme.version: Toolkit.Ubuntu.toolkitVersion |
196 | styleName: "TabBarStyle" |
197 | |
198 | QtObject { |
199 | |
200 | === modified file 'src/Ubuntu/Components/1.3/TextArea.qml' |
201 | --- src/Ubuntu/Components/1.3/TextArea.qml 2015-09-07 10:05:58 +0000 |
202 | +++ src/Ubuntu/Components/1.3/TextArea.qml 2015-10-20 11:06:17 +0000 |
203 | @@ -886,6 +886,5 @@ |
204 | } |
205 | } |
206 | |
207 | - theme.version: Ubuntu.Ubuntu.toolkitVersion |
208 | styleName: "TextAreaStyle" |
209 | } |
210 | |
211 | === modified file 'src/Ubuntu/Components/1.3/TextCursor.qml' |
212 | --- src/Ubuntu/Components/1.3/TextCursor.qml 2015-08-11 17:15:59 +0000 |
213 | +++ src/Ubuntu/Components/1.3/TextCursor.qml 2015-10-20 11:06:17 +0000 |
214 | @@ -41,7 +41,6 @@ |
215 | handler.main.cursorDelegate : |
216 | __styleInstance.cursorDelegate |
217 | |
218 | - theme.version: Ubuntu.Ubuntu.toolkitVersion |
219 | styleName: "TextCursorStyle" |
220 | |
221 | objectName: "textCursor" |
222 | |
223 | === modified file 'src/Ubuntu/Components/1.3/TextField.qml' |
224 | --- src/Ubuntu/Components/1.3/TextField.qml 2015-09-07 10:05:58 +0000 |
225 | +++ src/Ubuntu/Components/1.3/TextField.qml 2015-10-20 11:06:17 +0000 |
226 | @@ -1013,6 +1013,5 @@ |
227 | cursorPosition = 0; |
228 | } |
229 | |
230 | - theme.version: Ubuntu.Ubuntu.toolkitVersion |
231 | styleName: "TextFieldStyle" |
232 | } |
233 | |
234 | === modified file 'src/Ubuntu/Components/1.3/TextInputPopover.qml' |
235 | --- src/Ubuntu/Components/1.3/TextInputPopover.qml 2015-09-16 05:28:29 +0000 |
236 | +++ src/Ubuntu/Components/1.3/TextInputPopover.qml 2015-10-20 11:06:17 +0000 |
237 | @@ -86,7 +86,6 @@ |
238 | width: Math.max(units.gu(5), implicitWidth) + units.gu(2) |
239 | height: units.gu(6) |
240 | action: actions[modelData] |
241 | - theme.version: Ubuntu.toolkitVersion |
242 | styleName: "ToolbarButtonStyle" |
243 | } |
244 | } |
245 | |
246 | === modified file 'src/Ubuntu/Components/1.3/Toolbar.qml' |
247 | --- src/Ubuntu/Components/1.3/Toolbar.qml 2015-05-21 10:50:35 +0000 |
248 | +++ src/Ubuntu/Components/1.3/Toolbar.qml 2015-10-20 11:06:17 +0000 |
249 | @@ -135,7 +135,6 @@ |
250 | property bool opened: toolbar.opened |
251 | property bool animating: toolbar.animating |
252 | |
253 | - theme.version: Toolkit.Ubuntu.toolkitVersion |
254 | styleName: "ToolbarStyle" |
255 | } |
256 | |
257 | |
258 | === modified file 'src/Ubuntu/Components/1.3/ToolbarButton.qml' |
259 | --- src/Ubuntu/Components/1.3/ToolbarButton.qml 2015-05-21 10:50:35 +0000 |
260 | +++ src/Ubuntu/Components/1.3/ToolbarButton.qml 2015-10-20 11:06:17 +0000 |
261 | @@ -84,6 +84,5 @@ |
262 | height: parent ? parent.height : undefined |
263 | width: units.gu(5) |
264 | |
265 | - theme.version: Ubuntu.toolkitVersion |
266 | styleName: "ToolbarButtonStyle" |
267 | } |
268 | |
269 | === modified file 'src/Ubuntu/Components/ListItems/1.3/ItemSelector.qml' |
270 | --- src/Ubuntu/Components/ListItems/1.3/ItemSelector.qml 2015-05-22 13:54:38 +0000 |
271 | +++ src/Ubuntu/Components/ListItems/1.3/ItemSelector.qml 2015-10-20 11:06:17 +0000 |
272 | @@ -216,7 +216,6 @@ |
273 | right: parent.right |
274 | } |
275 | state: itemSelector.expanded ? "expanded" : "collapsed" |
276 | - theme.version: Ubuntu.toolkitVersion |
277 | styleName: "ListItemOptionSelectorStyle" |
278 | |
279 | states: [ State { |
280 | |
281 | === modified file 'src/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml' |
282 | --- src/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml 2015-05-22 13:54:38 +0000 |
283 | +++ src/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml 2015-10-20 11:06:17 +0000 |
284 | @@ -25,6 +25,5 @@ |
285 | property bool showSplit: false |
286 | property real splitMargin |
287 | |
288 | - theme.version: Ubuntu.toolkitVersion |
289 | styleName: "ProgressionVisualStyle" |
290 | } |
291 | |
292 | === modified file 'src/Ubuntu/Components/Pickers/1.3/DatePicker.qml' |
293 | --- src/Ubuntu/Components/Pickers/1.3/DatePicker.qml 2015-05-22 13:54:38 +0000 |
294 | +++ src/Ubuntu/Components/Pickers/1.3/DatePicker.qml 2015-10-20 11:06:17 +0000 |
295 | @@ -420,7 +420,6 @@ |
296 | } |
297 | } |
298 | |
299 | - theme.version: Ubuntu.toolkitVersion |
300 | styleName: "DatePickerStyle" |
301 | Binding { |
302 | target: __styleInstance |
303 | |
304 | === modified file 'src/Ubuntu/Components/Pickers/1.3/Dialer.qml' |
305 | --- src/Ubuntu/Components/Pickers/1.3/Dialer.qml 2015-05-22 13:54:38 +0000 |
306 | +++ src/Ubuntu/Components/Pickers/1.3/Dialer.qml 2015-10-20 11:06:17 +0000 |
307 | @@ -145,7 +145,6 @@ |
308 | implicitHeight: size |
309 | activeFocusOnPress: true |
310 | |
311 | - theme.version: Ubuntu.toolkitVersion |
312 | styleName: "DialerStyle" |
313 | |
314 | Item { |
315 | |
316 | === modified file 'src/Ubuntu/Components/Pickers/1.3/DialerHand.qml' |
317 | --- src/Ubuntu/Components/Pickers/1.3/DialerHand.qml 2015-05-22 13:54:38 +0000 |
318 | +++ src/Ubuntu/Components/Pickers/1.3/DialerHand.qml 2015-10-20 11:06:17 +0000 |
319 | @@ -143,7 +143,6 @@ |
320 | width: parent.width |
321 | height: parent.height |
322 | activeFocusOnPress: true |
323 | - theme.version: Ubuntu.toolkitVersion |
324 | styleName: "DialerHandStyle" |
325 | |
326 | /*! \internal */ |
327 | |
328 | === modified file 'src/Ubuntu/Components/Pickers/1.3/Picker.qml' |
329 | --- src/Ubuntu/Components/Pickers/1.3/Picker.qml 2015-09-24 20:05:52 +0000 |
330 | +++ src/Ubuntu/Components/Pickers/1.3/Picker.qml 2015-10-20 11:06:17 +0000 |
331 | @@ -165,7 +165,6 @@ |
332 | |
333 | activeFocusOnPress: true |
334 | |
335 | - theme.version: Ubuntu.toolkitVersion |
336 | styleName: "PickerStyle" |
337 | |
338 | /*! \internal */ |
339 | |
340 | === modified file 'src/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml' |
341 | --- src/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml 2015-09-24 20:05:52 +0000 |
342 | +++ src/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml 2015-10-20 11:06:17 +0000 |
343 | @@ -45,7 +45,6 @@ |
344 | internal.itemList.currentIndex = index; |
345 | } |
346 | |
347 | - theme.version: Ubuntu.toolkitVersion |
348 | styleName: "PickerDelegateStyle" |
349 | |
350 | QtObject { |
351 | |
352 | === modified file 'src/Ubuntu/Components/Popups/1.3/Dialog.qml' |
353 | --- src/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-09-21 14:44:13 +0000 |
354 | +++ src/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-10-20 11:06:17 +0000 |
355 | @@ -213,7 +213,6 @@ |
356 | } |
357 | } |
358 | |
359 | - theme.version: Ubuntu.toolkitVersion |
360 | styleName: "DialogForegroundStyle" |
361 | } |
362 | } |
363 | |
364 | === modified file 'src/Ubuntu/Components/Popups/1.3/Popover.qml' |
365 | --- src/Ubuntu/Components/Popups/1.3/Popover.qml 2015-08-12 19:53:20 +0000 |
366 | +++ src/Ubuntu/Components/Popups/1.3/Popover.qml 2015-10-20 11:06:17 +0000 |
367 | @@ -241,7 +241,6 @@ |
368 | signal showCompleted() |
369 | signal hideCompleted() |
370 | |
371 | - theme.version: Ubuntu.toolkitVersion |
372 | styleName: "PopoverForegroundStyle" |
373 | } |
374 | |
375 | |
376 | === modified file 'src/Ubuntu/Components/Popups/1.3/SheetBase.qml' |
377 | --- src/Ubuntu/Components/Popups/1.3/SheetBase.qml 2015-05-22 13:54:38 +0000 |
378 | +++ src/Ubuntu/Components/Popups/1.3/SheetBase.qml 2015-10-20 11:06:17 +0000 |
379 | @@ -109,7 +109,6 @@ |
380 | } |
381 | } |
382 | |
383 | - theme.version: Ubuntu.toolkitVersion |
384 | styleName: "SheetForegroundStyle" |
385 | } |
386 | } |
387 | |
388 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.2/OptionSelectorStyle.qml' |
389 | --- src/Ubuntu/Components/Themes/Ambiance/1.2/OptionSelectorStyle.qml 2015-04-24 14:52:19 +0000 |
390 | +++ src/Ubuntu/Components/Themes/Ambiance/1.2/OptionSelectorStyle.qml 2015-10-20 11:06:17 +0000 |
391 | @@ -20,6 +20,7 @@ |
392 | |
393 | Item { |
394 | id: ambianceStyle |
395 | + objectName: "OptionSelector12" |
396 | |
397 | property url chevron: Qt.resolvedUrl("../artwork/chevron_down.png") |
398 | property url tick: Qt.resolvedUrl("../artwork/tick.png") |
399 | |
400 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/OptionSelectorStyle.qml' |
401 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/OptionSelectorStyle.qml 2015-07-22 13:14:43 +0000 |
402 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/OptionSelectorStyle.qml 2015-10-20 11:06:17 +0000 |
403 | @@ -20,6 +20,7 @@ |
404 | |
405 | Item { |
406 | id: ambianceStyle |
407 | + objectName: "OptionSelector13" |
408 | |
409 | property url chevron: Qt.resolvedUrl("../artwork/chevron_down.png") |
410 | property url tick: Qt.resolvedUrl("../artwork/tick.png") |
411 | |
412 | === modified file 'src/Ubuntu/Components/plugin/plugin.cpp' |
413 | --- src/Ubuntu/Components/plugin/plugin.cpp 2015-10-01 12:34:29 +0000 |
414 | +++ src/Ubuntu/Components/plugin/plugin.cpp 2015-10-20 11:06:17 +0000 |
415 | @@ -230,7 +230,6 @@ |
416 | qmlRegisterType<UCUbuntuShapeOverlay>(uri, 1, 2, "UbuntuShapeOverlay"); |
417 | |
418 | // register 1.3 API |
419 | - qmlRegisterType<UCItemAttached>(); |
420 | qmlRegisterType<UCListItem, 1>(uri, 1, 3, "ListItem"); |
421 | qmlRegisterType<UCListItemExpansion>(); |
422 | qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings"); |
423 | |
424 | === modified file 'src/Ubuntu/Components/plugin/plugin.pri' |
425 | --- src/Ubuntu/Components/plugin/plugin.pri 2015-10-01 08:47:31 +0000 |
426 | +++ src/Ubuntu/Components/plugin/plugin.pri 2015-10-20 11:06:17 +0000 |
427 | @@ -91,7 +91,8 @@ |
428 | $$PWD/ucheader.h \ |
429 | $$PWD/uclabel.h \ |
430 | $$PWD/uclistitemlayout.h \ |
431 | - $$PWD/privates/threelabelsslot_p.h |
432 | + $$PWD/privates/threelabelsslot_p.h \ |
433 | + $$PWD/ucimportversionchecker_p.h |
434 | |
435 | SOURCES += $$PWD/plugin.cpp \ |
436 | $$PWD/uctheme.cpp \ |
437 | @@ -153,7 +154,8 @@ |
438 | $$PWD/ucheader.cpp \ |
439 | $$PWD/uclabel.cpp \ |
440 | $$PWD/uclistitemlayout.cpp \ |
441 | - $$PWD/privates/threelabelsslot_p.cpp |
442 | + $$PWD/privates/threelabelsslot_p.cpp \ |
443 | + $$PWD/ucimportversionchecker_p.cpp |
444 | |
445 | # adapters |
446 | SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp |
447 | |
448 | === added file 'src/Ubuntu/Components/plugin/ucimportversionchecker_p.cpp' |
449 | --- src/Ubuntu/Components/plugin/ucimportversionchecker_p.cpp 1970-01-01 00:00:00 +0000 |
450 | +++ src/Ubuntu/Components/plugin/ucimportversionchecker_p.cpp 2015-10-20 11:06:17 +0000 |
451 | @@ -0,0 +1,58 @@ |
452 | +/* |
453 | + * Copyright 2015 Canonical Ltd. |
454 | + * |
455 | + * This program is free software; you can redistribute it and/or modify |
456 | + * it under the terms of the GNU Lesser General Public License as published by |
457 | + * the Free Software Foundation; version 3. |
458 | + * |
459 | + * This program is distributed in the hope that it will be useful, |
460 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
461 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
462 | + * GNU Lesser General Public License for more details. |
463 | + * |
464 | + * You should have received a copy of the GNU Lesser General Public License |
465 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
466 | + * |
467 | + * Author: Zsombor Egri <zsombor.egri@canonical.com> |
468 | + */ |
469 | + |
470 | +#include "ucimportversionchecker_p.h" |
471 | +#include "ucnamespace.h" |
472 | + |
473 | +#include <QtQuick> |
474 | +#include <QtQml/private/qqmldata_p.h> |
475 | +#include <QtQml/private/qqmlcontext_p.h> |
476 | +#include <QtQml/private/qqmlpropertycache_p.h> |
477 | +#include <QtQml/private/qqmlmetatype_p.h> |
478 | + |
479 | +/*! |
480 | + * \internal |
481 | + * |
482 | + * The function returns the version the module is imported with based on a QML |
483 | + * component instance. It only checks till reaches 1.2 version. Implementations |
484 | + * must implement the propertyForVersion method and must probvide a property for |
485 | + * each version requested. |
486 | + */ |
487 | +quint16 UCImportVersionChecker::importVersion(QObject *object) |
488 | +{ |
489 | + QQmlData *data = QQmlData::get(object); |
490 | + Q_ASSERT(data); |
491 | + QQmlContextData *cdata = QQmlContextData::get(qmlContext(object)); |
492 | + Q_ASSERT(cdata); |
493 | + QQmlEngine *engine = qmlEngine(object); |
494 | + Q_ASSERT(engine); |
495 | + |
496 | + // start from the highest available version till we reach 1.2 |
497 | + for (quint16 minor = MINOR_VERSION(LATEST_UITK_VERSION); minor > 2; minor--) { |
498 | + quint16 version = BUILD_VERSION(1, minor); |
499 | + const QString property(propertyForVersion(version)); |
500 | + Q_ASSERT(!property.isEmpty()); |
501 | + QQmlPropertyData l; |
502 | + QQmlPropertyData *p = QQmlPropertyCache::property(engine, object, property, cdata, l); |
503 | + if (data->propertyCache->isAllowedInRevision(p)) { |
504 | + return version; |
505 | + } |
506 | + } |
507 | + // if none found, simply fall back to 1.2 |
508 | + return BUILD_VERSION(1, 2); |
509 | +} |
510 | |
511 | === added file 'src/Ubuntu/Components/plugin/ucimportversionchecker_p.h' |
512 | --- src/Ubuntu/Components/plugin/ucimportversionchecker_p.h 1970-01-01 00:00:00 +0000 |
513 | +++ src/Ubuntu/Components/plugin/ucimportversionchecker_p.h 2015-10-20 11:06:17 +0000 |
514 | @@ -0,0 +1,34 @@ |
515 | +/* |
516 | + * Copyright 2015 Canonical Ltd. |
517 | + * |
518 | + * This program is free software; you can redistribute it and/or modify |
519 | + * it under the terms of the GNU Lesser General Public License as published by |
520 | + * the Free Software Foundation; version 3. |
521 | + * |
522 | + * This program is distributed in the hope that it will be useful, |
523 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
524 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
525 | + * GNU Lesser General Public License for more details. |
526 | + * |
527 | + * You should have received a copy of the GNU Lesser General Public License |
528 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
529 | + * |
530 | + * Author: Zsombor Egri <zsombor.egri@canonical.com> |
531 | + */ |
532 | + |
533 | +#ifndef UCIMPORTVERSIONCHECKER_P_H |
534 | +#define UCIMPORTVERSIONCHECKER_P_H |
535 | + |
536 | +#include <QtCore> |
537 | + |
538 | +class UCImportVersionChecker |
539 | +{ |
540 | +public: |
541 | + UCImportVersionChecker() {} |
542 | + |
543 | + virtual QString propertyForVersion(quint16 version) const = 0; |
544 | + |
545 | + virtual quint16 importVersion(QObject *object); |
546 | +}; |
547 | + |
548 | +#endif // UCIMPORTVERSIONCHECKER_P_H |
549 | |
550 | === modified file 'src/Ubuntu/Components/plugin/uclabel.cpp' |
551 | --- src/Ubuntu/Components/plugin/uclabel.cpp 2015-09-28 16:18:19 +0000 |
552 | +++ src/Ubuntu/Components/plugin/uclabel.cpp 2015-10-20 11:06:17 +0000 |
553 | @@ -78,6 +78,7 @@ |
554 | */ |
555 | UCLabel::UCLabel(QQuickItem* parent) |
556 | : QQuickText(parent) |
557 | + , UCThemingExtension(this) |
558 | , m_textSize(Medium) |
559 | , m_flags(0) |
560 | { |
561 | @@ -91,7 +92,6 @@ |
562 | |
563 | void UCLabel::init() |
564 | { |
565 | - initTheming(this); |
566 | postThemeChanged(); |
567 | updatePixelSize(); |
568 | m_defaultFont = font(); |
569 | @@ -103,13 +103,6 @@ |
570 | connect(this, &UCLabel::colorChanged, this, &UCLabel::_q_customColor, Qt::DirectConnection); |
571 | } |
572 | |
573 | -void UCLabel::customEvent(QEvent *event) |
574 | -{ |
575 | - if (UCThemeEvent::isThemeEvent(event)) { |
576 | - handleThemeEvent(static_cast<UCThemeEvent*>(event)); |
577 | - } |
578 | -} |
579 | - |
580 | void UCLabel::postThemeChanged() |
581 | { |
582 | if (m_flags & ColorSet) { |
583 | |
584 | === modified file 'src/Ubuntu/Components/plugin/uclabel.h' |
585 | --- src/Ubuntu/Components/plugin/uclabel.h 2015-10-01 12:34:29 +0000 |
586 | +++ src/Ubuntu/Components/plugin/uclabel.h 2015-10-20 11:06:17 +0000 |
587 | @@ -23,7 +23,7 @@ |
588 | class UCLabel : public QQuickText, public UCThemingExtension |
589 | { |
590 | Q_OBJECT |
591 | - |
592 | + Q_INTERFACES(UCThemingExtension) |
593 | Q_ENUMS(TextSize) |
594 | Q_PROPERTY(TextSize textSize MEMBER m_textSize WRITE setTextSize NOTIFY textSizeChanged FINAL) |
595 | |
596 | @@ -61,7 +61,6 @@ |
597 | protected: |
598 | // from QQuickItem |
599 | void classBegin(); |
600 | - void customEvent(QEvent *event); |
601 | |
602 | // from UCItemExtension |
603 | void preThemeChanged(){} |
604 | |
605 | === modified file 'src/Ubuntu/Components/plugin/uclistitem.cpp' |
606 | --- src/Ubuntu/Components/plugin/uclistitem.cpp 2015-10-12 14:32:17 +0000 |
607 | +++ src/Ubuntu/Components/plugin/uclistitem.cpp 2015-10-20 11:06:17 +0000 |
608 | @@ -61,7 +61,7 @@ |
609 | QColor colorFrom; |
610 | QColor colorTo; |
611 | QGradientStops gradient; |
612 | - UCListItemPrivate *listItem; |
613 | + UCListItem *listItem; |
614 | }; |
615 | |
616 | UCListItemDivider::UCListItemDivider(UCListItem *parent) |
617 | @@ -77,14 +77,16 @@ |
618 | { |
619 | Q_D(UCListItemDivider); |
620 | QQml_setParent_noEvent(this, listItem); |
621 | - d->listItem = UCListItemPrivate::get(listItem); |
622 | + d->listItem = listItem; |
623 | setParentItem(listItem); |
624 | // anchor to left/right/bottom of the ListItem |
625 | QQuickAnchors *anchors = d->anchors(); |
626 | - anchors->setLeft(d->listItem->left()); |
627 | - anchors->setRight(d->listItem->right()); |
628 | - anchors->setBottom(d->listItem->bottom()); |
629 | + UCListItemPrivate *pListItem = UCListItemPrivate::get(listItem); |
630 | + anchors->setLeft(pListItem->left()); |
631 | + anchors->setRight(pListItem->right()); |
632 | + anchors->setBottom(pListItem->bottom()); |
633 | // connect visible change so we relayout contentItem |
634 | + // FIXME: do this with itemChange!!! |
635 | connect(this, SIGNAL(visibleChanged()), listItem, SLOT(_q_relayout())); |
636 | } |
637 | |
638 | @@ -132,7 +134,8 @@ |
639 | dividerNode = d->sceneGraphContext()->createRectangleNode(); |
640 | } |
641 | |
642 | - bool lastItem = d->listItem->countOwner ? (d->listItem->index() == (d->listItem->countOwner->property("count").toInt() - 1)): false; |
643 | + UCListItemPrivate *pListItem = UCListItemPrivate::get(d->listItem); |
644 | + bool lastItem = pListItem->countOwner ? (pListItem->index() == (pListItem->countOwner->property("count").toInt() - 1)): false; |
645 | if (!lastItem && (d->gradient.size() > 0) && ((d->colorFrom.alphaF() >= (1.0f / 255.0f)) || (d->colorTo.alphaF() >= (1.0f / 255.0f)))) { |
646 | dividerNode->setRect(boundingRect()); |
647 | dividerNode->setGradientStops(d->gradient); |
648 | @@ -1174,7 +1177,7 @@ |
649 | { |
650 | Q_Q(UCListItem); |
651 | // themes 1.2 and below should not have context menu support, so leave |
652 | - quint16 version(getTheme()->version()); |
653 | + quint16 version(importVersion(q)); |
654 | if (version <= BUILD_VERSION(1, 2)) { |
655 | return; |
656 | } |
657 | @@ -1643,7 +1646,7 @@ |
658 | { |
659 | Q_D(UCListItem); |
660 | d->customColor = false; |
661 | - d->highlightColor = d->getTheme()->getPaletteColor("selected", "background"); |
662 | + d->highlightColor = getTheme()->getPaletteColor("selected", "background"); |
663 | update(); |
664 | Q_EMIT highlightColorChanged(); |
665 | } |
666 | |
667 | === modified file 'src/Ubuntu/Components/plugin/ucstyleditembase.cpp' |
668 | --- src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-10-06 07:16:37 +0000 |
669 | +++ src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-10-20 11:06:17 +0000 |
670 | @@ -28,7 +28,7 @@ |
671 | UCStyledItemBasePrivate::UCStyledItemBasePrivate() |
672 | : styleComponent(Q_NULLPTR) |
673 | , styleItem(Q_NULLPTR) |
674 | - , styleVersion(LATEST_UITK_VERSION) |
675 | + , styleVersion(0) |
676 | , activeFocusOnPress(false) |
677 | , wasStyleLoaded(false) |
678 | { |
679 | @@ -108,6 +108,7 @@ |
680 | */ |
681 | UCStyledItemBase::UCStyledItemBase(QQuickItem *parent) |
682 | : QQuickItem(*(new UCStyledItemBasePrivate), parent) |
683 | + , UCThemingExtension(this) |
684 | { |
685 | Q_D(UCStyledItemBase); |
686 | d->init(); |
687 | @@ -115,6 +116,7 @@ |
688 | |
689 | UCStyledItemBase::UCStyledItemBase(UCStyledItemBasePrivate &dd, QQuickItem *parent) |
690 | : QQuickItem(dd, parent) |
691 | + , UCThemingExtension(this) |
692 | { |
693 | Q_D(UCStyledItemBase); |
694 | d->init(); |
695 | @@ -308,7 +310,7 @@ |
696 | // either styleComponent or styleName is valid |
697 | QQmlComponent *component = styleComponent; |
698 | if (!component) { |
699 | - component = getTheme()->createStyleComponent(styleDocument + ".qml", q, styleVersion); |
700 | + component = q->getTheme()->createStyleComponent(styleDocument + ".qml", q, styleVersion); |
701 | } |
702 | if (!component) { |
703 | return false; |
704 | @@ -442,41 +444,38 @@ |
705 | * if any, or to the system default theme. |
706 | */ |
707 | |
708 | -void UCStyledItemBasePrivate::preThemeChanged() |
709 | +void UCStyledItemBase::preThemeChanged() |
710 | { |
711 | - wasStyleLoaded = (styleItem != Q_NULLPTR); |
712 | - preStyleChanged(); |
713 | + Q_D(UCStyledItemBase); |
714 | + d->wasStyleLoaded = (d->styleItem != Q_NULLPTR); |
715 | + d->preStyleChanged(); |
716 | } |
717 | -void UCStyledItemBasePrivate::postThemeChanged() |
718 | +void UCStyledItemBase::postThemeChanged() |
719 | { |
720 | - Q_EMIT q_func()->themeChanged(); |
721 | - if (!wasStyleLoaded) { |
722 | + Q_EMIT themeChanged(); |
723 | + Q_D(UCStyledItemBase); |
724 | + if (!d->wasStyleLoaded) { |
725 | return; |
726 | } |
727 | - postStyleChanged(); |
728 | - loadStyleItem(); |
729 | + d->postStyleChanged(); |
730 | + d->loadStyleItem(); |
731 | } |
732 | |
733 | -void UCStyledItemBase::classBegin() |
734 | +QString UCStyledItemBasePrivate::propertyForVersion(quint16 version) const |
735 | { |
736 | - QQuickItem::classBegin(); |
737 | - d_func()->initTheming(this); |
738 | + switch (MINOR_VERSION(version)) { |
739 | + case 3: return QStringLiteral("theme"); |
740 | + default: return QString(); |
741 | + } |
742 | } |
743 | |
744 | void UCStyledItemBase::componentComplete() |
745 | { |
746 | QQuickItem::componentComplete(); |
747 | Q_D(UCStyledItemBase); |
748 | - |
749 | - QQmlData *data = QQmlData::get(this); |
750 | - QQmlContextData *cdata = QQmlContextData::get(qmlContext(this)); |
751 | - QQmlPropertyData l; |
752 | - QQmlPropertyData *pdata = QQmlPropertyCache::property(qmlEngine(this), this, QStringLiteral("theme"), cdata, l); |
753 | - // FIXME MainView internal styler uses theme property, meaning imports13 will be true, |
754 | - // therefore we must check the type of the property as well in case anyone else overrides it |
755 | - d->styleVersion = data->propertyCache->isAllowedInRevision(pdata) && (property("theme").type() != QVariant::String) |
756 | - ? BUILD_VERSION(1, 3) |
757 | - : BUILD_VERSION(1, 2); |
758 | + // make sure the theme version is up to date |
759 | + d->styleVersion = d->importVersion(this); |
760 | + UCTheme::checkMixedVersionImports(d->styleVersion); |
761 | // no animation at this time |
762 | // prepare style context if not been done yet |
763 | d->postStyleChanged(); |
764 | @@ -509,13 +508,4 @@ |
765 | return QQuickItem::childMouseEventFilter(child, event); |
766 | } |
767 | |
768 | -// catch UCThemeEvent |
769 | -void UCStyledItemBase::customEvent(QEvent *event) |
770 | -{ |
771 | - Q_D(UCStyledItemBase); |
772 | - if (UCThemeEvent::isThemeEvent(event)) { |
773 | - d->handleThemeEvent(static_cast<UCThemeEvent*>(event)); |
774 | - } |
775 | -} |
776 | - |
777 | #include "moc_ucstyleditembase.cpp" |
778 | |
779 | === modified file 'src/Ubuntu/Components/plugin/ucstyleditembase.h' |
780 | --- src/Ubuntu/Components/plugin/ucstyleditembase.h 2015-09-14 11:26:44 +0000 |
781 | +++ src/Ubuntu/Components/plugin/ucstyleditembase.h 2015-10-20 11:06:17 +0000 |
782 | @@ -20,20 +20,22 @@ |
783 | #define UCSTYLEDITEMBASE_H |
784 | |
785 | #include <QtQuick/QQuickItem> |
786 | +#include "ucthemingextension.h" |
787 | |
788 | class UCStyledItemBasePrivate; |
789 | class UCTheme; |
790 | class UCStyleHints; |
791 | -class UCStyledItemBase : public QQuickItem |
792 | +class UCStyledItemBase : public QQuickItem, public UCThemingExtension |
793 | { |
794 | Q_OBJECT |
795 | + Q_INTERFACES(UCThemingExtension) |
796 | Q_PROPERTY(bool activeFocusOnPress |
797 | READ activefocusOnPress WRITE setActiveFocusOnPress |
798 | NOTIFY activeFocusOnPressChanged REVISION 1) |
799 | Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQmlComponent *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL DESIGNABLE false) |
800 | Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQuickItem *__styleInstance READ styleInstance NOTIFY styleInstanceChanged FINAL DESIGNABLE false) |
801 | Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged FINAL REVISION 2) |
802 | - Q_PRIVATE_PROPERTY(d_func(), UCTheme *theme READ getTheme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL REVISION 2) |
803 | + Q_PROPERTY(UCTheme *theme READ getTheme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL REVISION 2) |
804 | public: |
805 | explicit UCStyledItemBase(QQuickItem *parent = 0); |
806 | |
807 | @@ -53,11 +55,13 @@ |
808 | protected: |
809 | UCStyledItemBase(UCStyledItemBasePrivate &, QQuickItem *parent); |
810 | |
811 | - void classBegin(); |
812 | + // from UCThemingExtension interface |
813 | + virtual void preThemeChanged(); |
814 | + virtual void postThemeChanged(); |
815 | + |
816 | void componentComplete(); |
817 | void mousePressEvent(QMouseEvent *event); |
818 | bool childMouseEventFilter(QQuickItem *child, QEvent *event); |
819 | - void customEvent(QEvent *event); |
820 | |
821 | private: |
822 | Q_DECLARE_PRIVATE(UCStyledItemBase) |
823 | |
824 | === modified file 'src/Ubuntu/Components/plugin/ucstyleditembase_p.h' |
825 | --- src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-10-06 07:16:37 +0000 |
826 | +++ src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-10-20 11:06:17 +0000 |
827 | @@ -22,11 +22,13 @@ |
828 | #include <QtQuick/private/qquickitem_p.h> |
829 | #include "ucstyleditembase.h" |
830 | #include "ucthemingextension.h" |
831 | +#include "ucimportversionchecker_p.h" |
832 | |
833 | class QQuickMouseArea; |
834 | class UCStyledItemBase; |
835 | -class UCStyledItemBasePrivate : public QQuickItemPrivate, public UCThemingExtension |
836 | +class UCStyledItemBasePrivate : public QQuickItemPrivate, public UCImportVersionChecker |
837 | { |
838 | + Q_INTERFACES(UCThemingExtension) |
839 | Q_DECLARE_PUBLIC(UCStyledItemBase) |
840 | public: |
841 | |
842 | @@ -55,8 +57,8 @@ |
843 | virtual void postStyleChanged() {} |
844 | virtual bool loadStyleItem(bool animated = true); |
845 | |
846 | - virtual void preThemeChanged(); |
847 | - virtual void postThemeChanged(); |
848 | + // from UCImportVersionChecker |
849 | + virtual QString propertyForVersion(quint16 version) const; |
850 | |
851 | public: |
852 | |
853 | |
854 | === modified file 'src/Ubuntu/Components/plugin/uctheme.cpp' |
855 | --- src/Ubuntu/Components/plugin/uctheme.cpp 2015-09-21 13:29:17 +0000 |
856 | +++ src/Ubuntu/Components/plugin/uctheme.cpp 2015-10-20 11:06:17 +0000 |
857 | @@ -44,6 +44,8 @@ |
858 | #include <QtQml/private/qqmlbinding_p.h> |
859 | #undef foreach |
860 | |
861 | + |
862 | +quint16 UCTheme::previousVersion = 0; |
863 | /*! |
864 | * \qmltype ThemeSettings |
865 | * \instantiates UCTheme |
866 | @@ -345,7 +347,6 @@ |
867 | : QObject(parent) |
868 | , m_palette(UCTheme::defaultTheme().m_palette) |
869 | , m_engine(UCTheme::defaultTheme().m_engine) |
870 | - , m_version(UCTheme::defaultTheme().m_version) |
871 | , m_defaultStyle(false) |
872 | { |
873 | init(); |
874 | @@ -355,7 +356,6 @@ |
875 | : QObject(parent) |
876 | , m_palette(NULL) |
877 | , m_engine(NULL) |
878 | - , m_version(LATEST_UITK_VERSION) |
879 | , m_defaultStyle(defaultStyle) |
880 | { |
881 | init(); |
882 | @@ -460,6 +460,7 @@ |
883 | } |
884 | loadPalette(); |
885 | Q_EMIT nameChanged(); |
886 | + updateThemedItems(); |
887 | } |
888 | void UCTheme::resetName() |
889 | { |
890 | @@ -625,52 +626,39 @@ |
891 | |
892 | void UCTheme::attachItem(QQuickItem *item, bool attach) |
893 | { |
894 | - UCItemAttached *theming = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(item, false)); |
895 | - if (!theming) { |
896 | - return; |
897 | - } |
898 | if (attach) { |
899 | - connect(this, SIGNAL(nameChanged()), theming, SLOT(reloadTheme()), Qt::DirectConnection); |
900 | - connect(this, SIGNAL(versionChanged()), theming, SLOT(reloadTheme()), Qt::DirectConnection); |
901 | + m_attachedItems.append(item); |
902 | } else { |
903 | - disconnect(this, SIGNAL(nameChanged()), theming, SLOT(reloadTheme())); |
904 | - disconnect(this, SIGNAL(versionChanged()), theming, SLOT(reloadTheme())); |
905 | - } |
906 | -} |
907 | - |
908 | -/*! |
909 | - * \qmlproperty uint16 ThemeSettings::version |
910 | - * \since Ubuntu.Components 1.3 |
911 | - * The property specifies the version of the toolkit the component is declared. |
912 | - * This equivalent with the toolkit version the component document imports. Themes, |
913 | - * starting of version 1.3, should follow the same versioning as the toolkit does. |
914 | - * If a component's style is not found under the given version, styling will try |
915 | - * to locate the style with a lower minor version until it finds a match. |
916 | - * |
917 | - * The current version of an imported toolkit module is reported by the |
918 | - * \l Ubuntu::toolkitVersion property. If a document imports Ubuntu.Components 1.2, |
919 | - * the components will load the system or application themes associated to that |
920 | - * version, and \l Ubuntu::toolkitVersion will report that version. If the document |
921 | - * imports 1.3 version, the components will load 1.3 themes. Setting this property |
922 | - * will initiate a full theme reload. |
923 | - * |
924 | - * Usually developers do not need to set this property on toolkit components as |
925 | - * those already set the version. However themes provided by applications should |
926 | - * take care of versioning the styles and on how to do theming. |
927 | - * |
928 | - * \sa Ubuntu::toolkitVersion, Ubuntu::version, {Themes} |
929 | + m_attachedItems.removeOne(item); |
930 | + } |
931 | +} |
932 | + |
933 | +void UCTheme::updateThemedItems() |
934 | +{ |
935 | + for (int i = 0; i < m_attachedItems.count(); i++) { |
936 | + UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(m_attachedItems[i]); |
937 | + if (extension) { |
938 | + extension->itemThemeReloaded(this); |
939 | + } |
940 | + } |
941 | +} |
942 | + |
943 | +/* |
944 | + * Updates the version used by the toolkit/application |
945 | */ |
946 | -quint16 UCTheme::version() |
947 | -{ |
948 | - return m_version; |
949 | -} |
950 | -void UCTheme::setVersion(quint16 version) |
951 | -{ |
952 | - if (m_version == version) { |
953 | - return; |
954 | +void UCTheme::checkMixedVersionImports(quint16 version) |
955 | +{ |
956 | + if (version != previousVersion && previousVersion) { |
957 | + // the first change is due to the first import detection, any further changes would mean there are |
958 | + // multiple version imports |
959 | + QString msg = QStringLiteral("Mixing of Ubuntu.Components module versions %1.%2 and %3.%4 detected!") |
960 | + .arg(MAJOR_VERSION(version)) |
961 | + .arg(MINOR_VERSION(version)) |
962 | + .arg(MAJOR_VERSION(previousVersion)) |
963 | + .arg(MINOR_VERSION(previousVersion)); |
964 | + qWarning() << msg; |
965 | } |
966 | - m_version = version; |
967 | - Q_EMIT versionChanged(); |
968 | + previousVersion = version; |
969 | } |
970 | |
971 | /* |
972 | @@ -680,10 +668,7 @@ |
973 | QQmlComponent* UCTheme::createStyleComponent(const QString& styleName, QObject* parent, quint16 version) |
974 | { |
975 | QQmlComponent *component = NULL; |
976 | - |
977 | - if (!version) { |
978 | - version = m_version; |
979 | - } |
980 | + Q_ASSERT(version); |
981 | |
982 | if (parent != NULL) { |
983 | QQmlEngine* engine = qmlEngine(parent); |
984 | @@ -732,7 +717,7 @@ |
985 | m_palette = 0; |
986 | } |
987 | // theme may not have palette defined |
988 | - QUrl paletteUrl = styleUrl("Palette.qml", m_version); |
989 | + QUrl paletteUrl = styleUrl("Palette.qml", previousVersion ? previousVersion : LATEST_UITK_VERSION); |
990 | if (paletteUrl.isValid()) { |
991 | m_palette = QuickUtils::instance().createQmlObject(paletteUrl, m_engine); |
992 | if (m_palette) { |
993 | |
994 | === modified file 'src/Ubuntu/Components/plugin/uctheme.h' |
995 | --- src/Ubuntu/Components/plugin/uctheme.h 2015-09-21 07:21:36 +0000 |
996 | +++ src/Ubuntu/Components/plugin/uctheme.h 2015-10-20 11:06:17 +0000 |
997 | @@ -28,6 +28,8 @@ |
998 | #include <QtQml/QQmlParserStatus> |
999 | #include <QtQml/QQmlProperty> |
1000 | |
1001 | +#include <QtQml/private/qpodvector_p.h> |
1002 | + |
1003 | #include "ucdefaulttheme.h" |
1004 | |
1005 | class UCStyledItemBase; |
1006 | @@ -40,8 +42,9 @@ |
1007 | Q_PROPERTY(UCTheme *parentTheme READ parentTheme NOTIFY parentThemeChanged FINAL) |
1008 | Q_PROPERTY(QString name READ name WRITE setName RESET resetName NOTIFY nameChanged FINAL) |
1009 | Q_PROPERTY(QObject* palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL) |
1010 | - Q_PROPERTY(quint16 version READ version WRITE setVersion NOTIFY versionChanged FINAL) |
1011 | public: |
1012 | + |
1013 | + static quint16 previousVersion; |
1014 | struct ThemeRecord { |
1015 | ThemeRecord() : |
1016 | shared(false), deprecated(false) |
1017 | @@ -75,8 +78,7 @@ |
1018 | void resetName(); |
1019 | QObject* palette(); |
1020 | void setPalette(QObject *config); |
1021 | - quint16 version(); |
1022 | - void setVersion(quint16 version); |
1023 | + static void checkMixedVersionImports(quint16 version); |
1024 | |
1025 | // internal, used by the deprecated Theme.createStyledComponent() |
1026 | QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version = 0); |
1027 | @@ -110,6 +112,7 @@ |
1028 | void updateThemePaths(); |
1029 | QUrl styleUrl(const QString& styleName, quint16 version, bool *isFallback = NULL); |
1030 | void loadPalette(bool notify = true); |
1031 | + void updateThemedItems(); |
1032 | |
1033 | class PaletteConfig |
1034 | { |
1035 | @@ -161,8 +164,8 @@ |
1036 | QPointer<QObject> m_palette; // the palette might be from the default style if the theme doesn't define palette |
1037 | QList<ThemeRecord> m_themePaths; |
1038 | UCDefaultTheme m_defaultTheme; |
1039 | + QPODVector<QQuickItem*, 4> m_attachedItems; |
1040 | QQmlEngine *m_engine; |
1041 | - quint16 m_version; |
1042 | bool m_defaultStyle:1; |
1043 | bool m_completed:1; |
1044 | |
1045 | |
1046 | === modified file 'src/Ubuntu/Components/plugin/ucthemingextension.cpp' |
1047 | --- src/Ubuntu/Components/plugin/ucthemingextension.cpp 2015-09-21 14:24:05 +0000 |
1048 | +++ src/Ubuntu/Components/plugin/ucthemingextension.cpp 2015-10-20 11:06:17 +0000 |
1049 | @@ -23,103 +23,85 @@ |
1050 | #include <QtGui/QGuiApplication> |
1051 | |
1052 | /* |
1053 | - * The UCThemingExtension class provides theme handling on Items extending an existing |
1054 | + * The UCThemingExtension interface provides theme handling on Items extending an existing |
1055 | * QQuickItem derivate class. Items subject fo theming should derive from this class |
1056 | - * and implement the virtual methods, as well as add the following two methods: |
1057 | - * 1) classBegin(item) should be called from the QQuickItem::classBegin() method |
1058 | - * 2) handleThemeEvent() should be called from QQuickItem::customEvent() method |
1059 | + * and implement the pure virtual methods. |
1060 | * The item can expose the theme property and use the getters defined by the |
1061 | * class. |
1062 | - * Iin case the item exposes the theme property, it can use the getters from the |
1063 | + * In case the item exposes the theme property, it can use the getters from the |
1064 | * extension and declare the themeChanged signal. |
1065 | */ |
1066 | |
1067 | -static int themeUpdatedId = QEvent::registerEventType(); |
1068 | -static int themeReloadedId = QEvent::registerEventType(); |
1069 | - |
1070 | -UCThemeEvent::UCThemeEvent(UCTheme *reloadedTheme) |
1071 | - : QEvent((QEvent::Type)themeReloadedId) |
1072 | - , m_oldTheme(Q_NULLPTR) |
1073 | - , m_newTheme(reloadedTheme) |
1074 | -{ |
1075 | - setAccepted(false); |
1076 | -} |
1077 | - |
1078 | -UCThemeEvent::UCThemeEvent(UCTheme *oldTheme, UCTheme *newTheme) |
1079 | - : QEvent((QEvent::Type)themeUpdatedId) |
1080 | - , m_oldTheme(oldTheme) |
1081 | - , m_newTheme(newTheme) |
1082 | -{ |
1083 | - setAccepted(false); |
1084 | -} |
1085 | - |
1086 | -UCThemeEvent::UCThemeEvent(const UCThemeEvent &other) |
1087 | - : QEvent(other.type()) |
1088 | - , m_oldTheme(other.m_oldTheme) |
1089 | - , m_newTheme(other.m_newTheme) |
1090 | -{ |
1091 | - setAccepted(false); |
1092 | -} |
1093 | - |
1094 | -bool UCThemeEvent::isThemeEvent(const QEvent *event) |
1095 | -{ |
1096 | - return ((int)event->type() == themeUpdatedId) || ((int)event->type() == themeReloadedId); |
1097 | -} |
1098 | - |
1099 | -void UCThemingExtension::forwardEvent(QQuickItem *item, UCThemeEvent *event) |
1100 | -{ |
1101 | - Q_FOREACH(QQuickItem *child, item->childItems()) { |
1102 | - QGuiApplication::sendEvent(child, event); |
1103 | - // StyledItem will handle the broadcast itself depending on whether the theme change was appropriate or not |
1104 | - // and will complete the ascendantStyled/theme itself |
1105 | - if (child->childItems().size() > 0 && !UCItemAttached::isThemed(child)) { |
1106 | - forwardEvent(child, event); |
1107 | - } |
1108 | - } |
1109 | -} |
1110 | - |
1111 | -void UCThemingExtension::broadcastThemeChange(QQuickItem *item, UCTheme *oldTheme, UCTheme *newTheme) |
1112 | -{ |
1113 | - UCThemeEvent event(oldTheme, newTheme); |
1114 | - forwardEvent(item, &event); |
1115 | -} |
1116 | - |
1117 | -void UCThemingExtension::broadcastThemeReloaded(QQuickItem *item, UCTheme *theme) |
1118 | -{ |
1119 | - UCThemeEvent event(theme); |
1120 | - forwardEvent(item, &event); |
1121 | +void notifyThemeChange(QQuickItem *item, UCTheme *oldTheme, UCTheme *newTheme) |
1122 | +{ |
1123 | + Q_FOREACH(QQuickItem *child, item->childItems()) { |
1124 | + UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(child); |
1125 | + if (extension) { |
1126 | + extension->itemThemeChanged(oldTheme, newTheme); |
1127 | + } |
1128 | + // StyledItem will handle the broadcast itself depending on whether the theme change was appropriate or not |
1129 | + // and will complete the ascendantStyled/theme itself |
1130 | + if (!extension) { |
1131 | + notifyThemeChange(child, oldTheme, newTheme); |
1132 | + } |
1133 | + } |
1134 | +} |
1135 | + |
1136 | +void notifyThemeReloaded(QQuickItem *item, UCTheme *theme) |
1137 | +{ |
1138 | + Q_FOREACH(QQuickItem *child, item->childItems()) { |
1139 | + UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(child); |
1140 | + if (extension) { |
1141 | + extension->itemThemeReloaded(theme); |
1142 | + } |
1143 | + // StyledItem will handle the broadcast itself depending on whether the theme change was appropriate or not |
1144 | + // and will complete the ascendantStyled/theme itself |
1145 | + if (!extension) { |
1146 | + notifyThemeReloaded(child, theme); |
1147 | + } |
1148 | + } |
1149 | } |
1150 | |
1151 | /************************************************************************* |
1152 | * Attached to every Item in the system |
1153 | */ |
1154 | -UCItemAttached::UCItemAttached(QObject *owner) |
1155 | - : QObject(owner) |
1156 | - , m_item(static_cast<QQuickItem*>(owner)) |
1157 | +static uint xdata = QObject::registerUserData(); |
1158 | +class UCItemAttached : public QObjectUserData, public QQuickItemChangeListener |
1159 | +{ |
1160 | +public: |
1161 | + explicit UCItemAttached(QQuickItem *owner = 0); |
1162 | + ~UCItemAttached(); |
1163 | + |
1164 | + QQuickItem *m_item; |
1165 | + QQuickItem *m_prevParent; |
1166 | + |
1167 | + void itemParentChanged(QQuickItem *item, QQuickItem *newParent); |
1168 | + |
1169 | +private: |
1170 | + |
1171 | + friend class UCThemingExtension; |
1172 | +}; |
1173 | + |
1174 | +UCItemAttached::UCItemAttached(QQuickItem *owner) |
1175 | + : m_item(owner) |
1176 | , m_prevParent(Q_NULLPTR) |
1177 | - , m_extension(Q_NULLPTR) |
1178 | { |
1179 | - // get parent item changes |
1180 | - connect(m_item, &QQuickItem::parentChanged, this, &UCItemAttached::handleParentChanged); |
1181 | + QQuickItemPrivate::get(m_item)->addItemChangeListener(this, QQuickItemPrivate::Parent); |
1182 | } |
1183 | |
1184 | UCItemAttached::~UCItemAttached() |
1185 | { |
1186 | -} |
1187 | - |
1188 | -UCItemAttached *UCItemAttached::qmlAttachedProperties(QObject *owner) |
1189 | -{ |
1190 | - return new UCItemAttached(owner); |
1191 | -} |
1192 | - |
1193 | -bool UCItemAttached::isThemed(QQuickItem *item) |
1194 | -{ |
1195 | - UCItemAttached *attached = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(item, false)); |
1196 | - return attached && (attached->m_extension != Q_NULLPTR); |
1197 | + QQuickItemPrivate::get(m_item)->removeItemChangeListener(this, QQuickItemPrivate::Parent); |
1198 | +} |
1199 | + |
1200 | +bool UCThemingExtension::isThemed(QQuickItem *item) |
1201 | +{ |
1202 | + UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(item); |
1203 | + return extension != Q_NULLPTR; |
1204 | } |
1205 | |
1206 | // handle parent changes |
1207 | -void UCItemAttached::handleParentChanged(QQuickItem *newParent) |
1208 | +void UCItemAttached::itemParentChanged(QQuickItem *, QQuickItem *newParent) |
1209 | { |
1210 | if (newParent == m_prevParent || QQuickItemPrivate::get(m_item)->wasDeleted) { |
1211 | return; |
1212 | @@ -128,41 +110,43 @@ |
1213 | // make sure we have these handlers attached to each intermediate item |
1214 | QQuickItem *oldThemedAscendant = UCThemingExtension::ascendantThemed(m_prevParent); |
1215 | QQuickItem *newThemedAscendant = UCThemingExtension::ascendantThemed(newParent); |
1216 | - UCTheme *oldTheme = oldThemedAscendant ? oldThemedAscendant->property("theme").value<UCTheme*>() : &UCTheme::defaultTheme(); |
1217 | - UCTheme *newTheme = newThemedAscendant ? newThemedAscendant->property("theme").value<UCTheme*>() : &UCTheme::defaultTheme(); |
1218 | + UCThemingExtension *oldExtension = qobject_cast<UCThemingExtension*>(oldThemedAscendant); |
1219 | + UCThemingExtension *newExtension = qobject_cast<UCThemingExtension*>(newThemedAscendant); |
1220 | + UCTheme *oldTheme = oldExtension ? oldExtension->getTheme() : &UCTheme::defaultTheme(); |
1221 | + UCTheme *newTheme = newExtension ? newExtension->getTheme() : &UCTheme::defaultTheme(); |
1222 | |
1223 | if (oldTheme != newTheme) { |
1224 | + UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(m_item); |
1225 | // send the event to m_item first |
1226 | - UCThemeEvent event(oldTheme, newTheme); |
1227 | - if (m_extension) { |
1228 | + if (extension) { |
1229 | // only items with extensions should get this event |
1230 | - m_extension->handleThemeEvent(&event); |
1231 | + extension->itemThemeChanged(oldTheme, newTheme); |
1232 | } |
1233 | // then broadcast to children, but only if the item is not a styled one |
1234 | - if (!m_extension) { |
1235 | - UCThemingExtension::forwardEvent(m_item, &event); |
1236 | + if (!extension) { |
1237 | + notifyThemeChange(m_item, oldTheme, newTheme); |
1238 | } |
1239 | } |
1240 | m_prevParent = newParent; |
1241 | } |
1242 | |
1243 | -void UCItemAttached::reloadTheme() |
1244 | -{ |
1245 | - Q_ASSERT(m_extension); |
1246 | - m_extension->preThemeChanged(); |
1247 | - m_extension->postThemeChanged(); |
1248 | - UCThemingExtension::broadcastThemeReloaded(m_item, static_cast<UCTheme*>(sender())); |
1249 | -} |
1250 | - |
1251 | /************************************************************************* |
1252 | * |
1253 | */ |
1254 | -UCThemingExtension::UCThemingExtension() |
1255 | - : themedItem(Q_NULLPTR) |
1256 | - , attachedThemer(Q_NULLPTR) |
1257 | - , theme(&UCTheme::defaultTheme()) |
1258 | +UCThemingExtension::UCThemingExtension(QQuickItem *extendedItem) |
1259 | + : theme(&UCTheme::defaultTheme()) |
1260 | + , themedItem(extendedItem) |
1261 | , themeType(Inherited) |
1262 | { |
1263 | + theme->attachItem(themedItem, true); |
1264 | + themedItem->setUserData(xdata, new UCItemAttached(themedItem)); |
1265 | +} |
1266 | + |
1267 | +UCThemingExtension::~UCThemingExtension() |
1268 | +{ |
1269 | + if (theme) { |
1270 | + theme->attachItem(themedItem, false); |
1271 | + } |
1272 | } |
1273 | |
1274 | // set the parent of the theme if the themeType is Custom |
1275 | @@ -172,47 +156,50 @@ |
1276 | return; |
1277 | } |
1278 | QQuickItem *upperThemed = ascendantThemed(QQuickItemPrivate::get(themedItem)->parentItem); |
1279 | - UCItemAttached *attached = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(upperThemed)); |
1280 | - UCTheme *parentTheme = (attached && attached->m_extension) ? attached->m_extension->getTheme() : &UCTheme::defaultTheme(); |
1281 | + UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(upperThemed); |
1282 | + UCTheme *parentTheme = extension ? extension->getTheme() : &UCTheme::defaultTheme(); |
1283 | if (parentTheme != theme) { |
1284 | theme->setParentTheme(parentTheme); |
1285 | } |
1286 | } |
1287 | |
1288 | -void UCThemingExtension::initTheming(QQuickItem *item) |
1289 | +void UCThemingExtension::itemThemeChanged(UCTheme*, UCTheme *newTheme) |
1290 | { |
1291 | - themedItem = item; |
1292 | - attachedThemer = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(themedItem)); |
1293 | - Q_ASSERT(attachedThemer); |
1294 | - attachedThemer->m_extension = this; |
1295 | - theme->attachItem(item, true); |
1296 | + switch (themeType) { |
1297 | + case Inherited: { |
1298 | + setTheme(newTheme, Inherited); |
1299 | + return; |
1300 | + } |
1301 | + case Custom: { |
1302 | + // set the theme's parent |
1303 | + theme->setParentTheme(newTheme); |
1304 | + return; |
1305 | + } |
1306 | + default: break; |
1307 | + } |
1308 | } |
1309 | |
1310 | -void UCThemingExtension::handleThemeEvent(UCThemeEvent *event) |
1311 | +void UCThemingExtension::itemThemeReloaded(UCTheme *theme) |
1312 | { |
1313 | - if ((int)event->type() == themeUpdatedId) { |
1314 | - switch (themeType) { |
1315 | - case Inherited: { |
1316 | - setTheme(event->newTheme(), Inherited); |
1317 | - return; |
1318 | - } |
1319 | - case Custom: { |
1320 | - // set the theme's parent |
1321 | - theme->setParentTheme(event->newTheme()); |
1322 | - return; |
1323 | - } |
1324 | - default: break; |
1325 | - } |
1326 | - } else if ((int)event->type() == themeReloadedId) { |
1327 | - // no need to handle Inherited case, those items are all attached to the theme changes |
1328 | - switch (themeType) { |
1329 | - case Custom: { |
1330 | + switch (themeType) { |
1331 | + case Inherited: { |
1332 | + preThemeChanged(); |
1333 | + postThemeChanged(); |
1334 | + return; |
1335 | + } |
1336 | + case Custom: { |
1337 | + if (theme == this->theme) { |
1338 | + preThemeChanged(); |
1339 | + postThemeChanged(); |
1340 | + // forward to children |
1341 | + notifyThemeReloaded(themedItem, theme); |
1342 | + } else { |
1343 | // emit theme's parentThemeChanged() |
1344 | - Q_EMIT theme->parentThemeChanged(); |
1345 | - return; |
1346 | - } |
1347 | - default: break; |
1348 | - } |
1349 | + Q_EMIT this->theme->parentThemeChanged(); |
1350 | + } |
1351 | + return; |
1352 | + } |
1353 | + default: break; |
1354 | } |
1355 | } |
1356 | |
1357 | @@ -250,26 +237,26 @@ |
1358 | postThemeChanged(); |
1359 | |
1360 | // broadcast to the children |
1361 | - broadcastThemeChange(themedItem, oldTheme, theme); |
1362 | + notifyThemeChange(themedItem, oldTheme, theme); |
1363 | } |
1364 | |
1365 | void UCThemingExtension::resetTheme() |
1366 | { |
1367 | QQuickItem *upperThemed = ascendantThemed(QQuickItemPrivate::get(themedItem)->parentItem); |
1368 | - UCItemAttached *attached = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(upperThemed)); |
1369 | - UCTheme *theme = (attached && attached->m_extension) ? attached->m_extension->getTheme() : &UCTheme::defaultTheme(); |
1370 | + UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(upperThemed); |
1371 | + UCTheme *theme = extension ? extension->getTheme() : &UCTheme::defaultTheme(); |
1372 | setTheme(theme, Inherited); |
1373 | } |
1374 | |
1375 | // returns the closest themed ascendant |
1376 | QQuickItem *UCThemingExtension::ascendantThemed(QQuickItem *item) |
1377 | { |
1378 | - while (item && !UCItemAttached::isThemed(item)) { |
1379 | - // make sure it also has the theming attached |
1380 | - qmlAttachedPropertiesObject<UCItemAttached>(item); |
1381 | + while (item && !isThemed(item)) { |
1382 | + // if the item has no xdata set, means we haven't been here yet |
1383 | + if (!item->userData(xdata)) { |
1384 | + item->setUserData(xdata, new UCItemAttached(item)); |
1385 | + } |
1386 | item = item->parentItem(); |
1387 | } |
1388 | return item; |
1389 | } |
1390 | - |
1391 | -#include "moc_ucthemingextension.cpp" |
1392 | |
1393 | === modified file 'src/Ubuntu/Components/plugin/ucthemingextension.h' |
1394 | --- src/Ubuntu/Components/plugin/ucthemingextension.h 2015-09-21 14:24:05 +0000 |
1395 | +++ src/Ubuntu/Components/plugin/ucthemingextension.h 2015-10-20 11:06:17 +0000 |
1396 | @@ -24,54 +24,10 @@ |
1397 | #include <QtCore/QPointer> |
1398 | #include <QtQml> |
1399 | |
1400 | +#include <QtQuick/private/qquickitem_p.h> |
1401 | + |
1402 | class QQuickItem; |
1403 | -class UCStyledItemBase; |
1404 | class UCTheme; |
1405 | -class UCThemingExtension; |
1406 | -class UCItemAttached : public QObject |
1407 | -{ |
1408 | - Q_OBJECT |
1409 | -public: |
1410 | - explicit UCItemAttached(QObject *owner = 0); |
1411 | - ~UCItemAttached(); |
1412 | - static bool isThemed(QQuickItem *item); |
1413 | - static UCItemAttached *qmlAttachedProperties(QObject *owner); |
1414 | - |
1415 | - QQuickItem *m_item; |
1416 | - QQuickItem *m_prevParent; |
1417 | - UCThemingExtension *m_extension; |
1418 | - |
1419 | -private: |
1420 | - Q_SLOT void handleParentChanged(QQuickItem *newParent); |
1421 | - Q_SLOT void reloadTheme(); |
1422 | - |
1423 | - friend class UCThemingExtension; |
1424 | -}; |
1425 | -QML_DECLARE_TYPEINFO(UCItemAttached, QML_HAS_ATTACHED_PROPERTIES) |
1426 | - |
1427 | -class UCThemeEvent : public QEvent |
1428 | -{ |
1429 | -public: // statics |
1430 | - static bool isThemeEvent(const QEvent *event); |
1431 | - |
1432 | -public: |
1433 | - explicit UCThemeEvent(UCTheme *reloadedTheme); |
1434 | - UCThemeEvent(UCTheme *oldTheme, UCTheme *newTheme); |
1435 | - UCThemeEvent(const UCThemeEvent &other); |
1436 | - |
1437 | - UCTheme *oldTheme() const |
1438 | - { |
1439 | - return m_oldTheme; |
1440 | - } |
1441 | - UCTheme *newTheme() const |
1442 | - { |
1443 | - return m_newTheme; |
1444 | - } |
1445 | -private: |
1446 | - UCTheme *m_oldTheme; |
1447 | - UCTheme *m_newTheme; |
1448 | -}; |
1449 | - |
1450 | class UCThemingExtension |
1451 | { |
1452 | public: |
1453 | @@ -80,31 +36,30 @@ |
1454 | Custom |
1455 | }; |
1456 | |
1457 | - explicit UCThemingExtension(); |
1458 | + explicit UCThemingExtension(QQuickItem *extendedItem); |
1459 | + virtual ~UCThemingExtension(); |
1460 | |
1461 | virtual void preThemeChanged() = 0; |
1462 | virtual void postThemeChanged() = 0; |
1463 | - |
1464 | - virtual void initTheming(QQuickItem *item); |
1465 | - virtual void handleThemeEvent(UCThemeEvent *event); |
1466 | + virtual void itemThemeChanged(UCTheme *, UCTheme*); |
1467 | + virtual void itemThemeReloaded(UCTheme *); |
1468 | |
1469 | UCTheme *getTheme() const; |
1470 | void setTheme(UCTheme *newTheme, ThemeType type = Custom); |
1471 | void resetTheme(); |
1472 | |
1473 | + static bool isThemed(QQuickItem *item); |
1474 | static QQuickItem *ascendantThemed(QQuickItem *item); |
1475 | |
1476 | - static void forwardEvent(QQuickItem *item, UCThemeEvent *event); |
1477 | - static void broadcastThemeChange(QQuickItem *item, UCTheme *oldTheme, UCTheme *newTheme); |
1478 | - static void broadcastThemeReloaded(QQuickItem *item, UCTheme *theme); |
1479 | - |
1480 | protected: |
1481 | + QPointer<UCTheme> theme; |
1482 | QQuickItem *themedItem; |
1483 | - UCItemAttached *attachedThemer; |
1484 | - QPointer<UCTheme> theme; |
1485 | ThemeType themeType; |
1486 | |
1487 | void setParentTheme(); |
1488 | }; |
1489 | |
1490 | +#define UCThemingExtension_iid "org.qt-project.Qt.UCThemingExtension" |
1491 | +Q_DECLARE_INTERFACE(UCThemingExtension, UCThemingExtension_iid) |
1492 | + |
1493 | #endif // UCITEMEXTENSION_H |
1494 | |
1495 | === added file 'tests/unit_x11/tst_subtheming/OtherVersion.qml' |
1496 | --- tests/unit_x11/tst_subtheming/OtherVersion.qml 1970-01-01 00:00:00 +0000 |
1497 | +++ tests/unit_x11/tst_subtheming/OtherVersion.qml 2015-10-20 11:06:17 +0000 |
1498 | @@ -0,0 +1,25 @@ |
1499 | +/* |
1500 | + * Copyright 2015 Canonical Ltd. |
1501 | + * |
1502 | + * This program is free software; you can redistribute it and/or modify |
1503 | + * it under the terms of the GNU Lesser General Public License as published by |
1504 | + * the Free Software Foundation; version 3. |
1505 | + * |
1506 | + * This program is distributed in the hope that it will be useful, |
1507 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1508 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1509 | + * GNU Lesser General Public License for more details. |
1510 | + * |
1511 | + * You should have received a copy of the GNU Lesser General Public License |
1512 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1513 | + */ |
1514 | +import QtQuick 2.4 |
1515 | +import Ubuntu.Components 1.3 |
1516 | + |
1517 | +StyledItem { |
1518 | + width: units.gu(40) |
1519 | + height: units.gu(40) |
1520 | + theme.name: "Ubuntu.Components.Themes.Ambiance" |
1521 | + styleName: "OptionSelectorStyle" |
1522 | + StyledItemV12 { objectName: "otherStyled" } |
1523 | +} |
1524 | |
1525 | === removed file 'tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml' |
1526 | --- tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml 2015-05-26 15:05:46 +0000 |
1527 | +++ tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml 1970-01-01 00:00:00 +0000 |
1528 | @@ -1,24 +0,0 @@ |
1529 | -/* |
1530 | - * Copyright 2015 Canonical Ltd. |
1531 | - * |
1532 | - * This program is free software; you can redistribute it and/or modify |
1533 | - * it under the terms of the GNU Lesser General Public License as published by |
1534 | - * the Free Software Foundation; version 3. |
1535 | - * |
1536 | - * This program is distributed in the hope that it will be useful, |
1537 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1538 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1539 | - * GNU Lesser General Public License for more details. |
1540 | - * |
1541 | - * You should have received a copy of the GNU Lesser General Public License |
1542 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1543 | - */ |
1544 | -import QtQuick 2.4 |
1545 | -import Ubuntu.Components 1.3 |
1546 | - |
1547 | -StyledItem { |
1548 | - id: item |
1549 | - theme.name: "themes.CustomTheme" |
1550 | - theme.version: Ubuntu.version(1, 0) |
1551 | - styleName: "TestStyle" |
1552 | -} |
1553 | |
1554 | === modified file 'tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml' |
1555 | --- tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml 2015-05-26 15:05:46 +0000 |
1556 | +++ tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml 2015-10-20 11:06:17 +0000 |
1557 | @@ -19,6 +19,5 @@ |
1558 | StyledItem { |
1559 | id: item |
1560 | theme.name: "themes.CustomTheme" |
1561 | - theme.version: Ubuntu.toolkitVersion |
1562 | styleName: "TestStyle" |
1563 | } |
1564 | |
1565 | === removed file 'tests/unit_x11/tst_subtheming/StyledItemFallback.qml' |
1566 | --- tests/unit_x11/tst_subtheming/StyledItemFallback.qml 2015-05-26 15:05:46 +0000 |
1567 | +++ tests/unit_x11/tst_subtheming/StyledItemFallback.qml 1970-01-01 00:00:00 +0000 |
1568 | @@ -1,24 +0,0 @@ |
1569 | -/* |
1570 | - * Copyright 2015 Canonical Ltd. |
1571 | - * |
1572 | - * This program is free software; you can redistribute it and/or modify |
1573 | - * it under the terms of the GNU Lesser General Public License as published by |
1574 | - * the Free Software Foundation; version 3. |
1575 | - * |
1576 | - * This program is distributed in the hope that it will be useful, |
1577 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1578 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1579 | - * GNU Lesser General Public License for more details. |
1580 | - * |
1581 | - * You should have received a copy of the GNU Lesser General Public License |
1582 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1583 | - */ |
1584 | -import QtQuick 2.4 |
1585 | -import Ubuntu.Components 1.3 |
1586 | - |
1587 | -StyledItem { |
1588 | - id: item |
1589 | - theme.name: "TestModule.TestTheme" |
1590 | - theme.version: Ubuntu.version(1, 0) |
1591 | - styleName: "TestStyle" |
1592 | -} |
1593 | |
1594 | === modified file 'tests/unit_x11/tst_subtheming/StyledItemV12.qml' |
1595 | --- tests/unit_x11/tst_subtheming/StyledItemV12.qml 2015-05-26 15:05:46 +0000 |
1596 | +++ tests/unit_x11/tst_subtheming/StyledItemV12.qml 2015-10-20 11:06:17 +0000 |
1597 | @@ -14,11 +14,11 @@ |
1598 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1599 | */ |
1600 | import QtQuick 2.4 |
1601 | -import Ubuntu.Components 1.3 |
1602 | +import Ubuntu.Components 1.2 |
1603 | |
1604 | StyledItem { |
1605 | id: item |
1606 | - theme.name: "themes.CustomTheme" |
1607 | - theme.version: Ubuntu.version(1, 2) |
1608 | - styleName: "TestStyle" |
1609 | + width: units.gu(20) |
1610 | + height: units.gu(20) |
1611 | + style: Theme.createStyleComponent("OptionSelectorStyle.qml", item) |
1612 | } |
1613 | |
1614 | === modified file 'tests/unit_x11/tst_subtheming/StyledItemV13.qml' |
1615 | --- tests/unit_x11/tst_subtheming/StyledItemV13.qml 2015-05-26 15:05:46 +0000 |
1616 | +++ tests/unit_x11/tst_subtheming/StyledItemV13.qml 2015-10-20 11:06:17 +0000 |
1617 | @@ -19,6 +19,5 @@ |
1618 | StyledItem { |
1619 | id: item |
1620 | theme.name: "themes.CustomTheme" |
1621 | - theme.version: Ubuntu.toolkitVersion |
1622 | styleName: "TestStyle" |
1623 | } |
1624 | |
1625 | === modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp' |
1626 | --- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-10-06 07:16:37 +0000 |
1627 | +++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-10-20 11:06:17 +0000 |
1628 | @@ -55,6 +55,7 @@ |
1629 | UCTheme *rootTheme = globalTheme(); |
1630 | QVERIFY(rootTheme); |
1631 | rootTheme->setName(theme); |
1632 | + |
1633 | } |
1634 | |
1635 | void setTheme(const QString &theme, QQuickItem *watchedItem) |
1636 | @@ -88,12 +89,14 @@ |
1637 | m_xdgDataPath = QLatin1String(getenv("XDG_DATA_DIRS")); |
1638 | m_themesPath = QLatin1String(getenv("UBUNTU_UI_TOOLKIT_THEMES_PATH")); |
1639 | qputenv("SUPPRESS_DEPRECATED_NOTE", "yes"); |
1640 | + qputenv("QT_MESSAGE_PATTERN", ""); |
1641 | } |
1642 | |
1643 | void cleanup() |
1644 | { |
1645 | qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", m_themesPath.toLatin1()); |
1646 | qputenv("XDG_DATA_DIRS", m_xdgDataPath.toLocal8Bit()); |
1647 | + UCTheme::previousVersion = 0; |
1648 | } |
1649 | |
1650 | void test_default_theme() |
1651 | @@ -282,11 +285,11 @@ |
1652 | UCStyledItemBase *mainItem = qobject_cast<UCStyledItemBase*>(view->rootObject()); |
1653 | |
1654 | QSignalSpy parentChangeSpy(testSet, SIGNAL(parentThemeChanged())); |
1655 | - UCStyledItemBasePrivate::get(testItem)->setTheme(testSet); |
1656 | + testItem->setTheme(testSet); |
1657 | parentChangeSpy.wait(200); |
1658 | QCOMPARE(parentChangeSpy.count(), 1); |
1659 | // test if the parent is correct |
1660 | - QCOMPARE(testSet->parentTheme(), UCStyledItemBasePrivate::get(mainItem)->getTheme()); |
1661 | + QCOMPARE(testSet->parentTheme(), mainItem->getTheme()); |
1662 | } |
1663 | |
1664 | void test_parent_set_reset_triggers_parent_change() |
1665 | @@ -299,11 +302,11 @@ |
1666 | |
1667 | // reset mainItem's theme should trigger parentChanged on testSet |
1668 | QSignalSpy parentChangeSpy(testSet, SIGNAL(parentThemeChanged())); |
1669 | - UCStyledItemBasePrivate::get(mainItem)->resetTheme(); |
1670 | + mainItem->resetTheme(); |
1671 | parentChangeSpy.wait(200); |
1672 | QCOMPARE(parentChangeSpy.count(), 1); |
1673 | - QCOMPARE(UCStyledItemBasePrivate::get(mainItem)->getTheme(), &UCTheme::defaultTheme()); |
1674 | - QCOMPARE(testSet->parentTheme(), UCStyledItemBasePrivate::get(mainItem)->getTheme()); |
1675 | + QCOMPARE(mainItem->getTheme(), &UCTheme::defaultTheme()); |
1676 | + QCOMPARE(testSet->parentTheme(), mainItem->getTheme()); |
1677 | } |
1678 | |
1679 | void test_parent_set_namechange_triggers_parent_change() |
1680 | @@ -315,11 +318,11 @@ |
1681 | // change mainItem.theme.name should trigger parentChanged on testSet |
1682 | QSignalSpy parentChangeSpy(testSet, SIGNAL(parentThemeChanged())); |
1683 | QSignalSpy themeChangeSpy(mainItem, SIGNAL(themeChanged())); |
1684 | - UCStyledItemBasePrivate::get(mainItem)->getTheme()->setName("Ubuntu.Components.Themes.SuruDark"); |
1685 | + mainItem->getTheme()->setName("Ubuntu.Components.Themes.SuruDark"); |
1686 | UbuntuTestCase::waitForSignal(&themeChangeSpy); |
1687 | parentChangeSpy.wait(200); |
1688 | QCOMPARE(parentChangeSpy.count(), 1); |
1689 | - QCOMPARE(testSet->parentTheme(), UCStyledItemBasePrivate::get(mainItem)->getTheme()); |
1690 | + QCOMPARE(testSet->parentTheme(), mainItem->getTheme()); |
1691 | } |
1692 | |
1693 | |
1694 | @@ -333,10 +336,10 @@ |
1695 | // verify theme changes |
1696 | UCStyledItemBase *styled = qobject_cast<UCStyledItemBase*>(view->rootObject()); |
1697 | QVERIFY(styled); |
1698 | - QCOMPARE(UCStyledItemBasePrivate::get(styled)->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark")); |
1699 | + QCOMPARE(styled->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark")); |
1700 | // a deeper item's style name |
1701 | styled = view->findItem<UCStyledItemBase*>("secondLevelStyled"); |
1702 | - QCOMPARE(UCStyledItemBasePrivate::get(styled)->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark")); |
1703 | + QCOMPARE(styled->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark")); |
1704 | } |
1705 | |
1706 | // changing StyledItem.theme.name for different items within a tree where |
1707 | @@ -355,7 +358,7 @@ |
1708 | // change theme name (theme) |
1709 | UCStyledItemBase *styled = view->findItem<UCStyledItemBase*>(itemName); |
1710 | QSignalSpy themeChangeSpy(styled, SIGNAL(themeChanged())); |
1711 | - UCStyledItemBasePrivate::get(styled)->getTheme()->setName("Ubuntu.Components.Themes.SuruDark"); |
1712 | + styled->getTheme()->setName("Ubuntu.Components.Themes.SuruDark"); |
1713 | UbuntuTestCase::waitForSignal(&themeChangeSpy); |
1714 | UCTheme *theme = view->globalTheme(); |
1715 | QCOMPARE(theme->name(), QString("Ubuntu.Components.Themes.SuruDark")); |
1716 | @@ -401,11 +404,11 @@ |
1717 | view->findItem<UCStyledItemBase*>(applyOnItem); |
1718 | QVERIFY(styledItem); |
1719 | // the theme is declared, but should not be set yet!!! |
1720 | - QVERIFY2(UCStyledItemBasePrivate::get(styledItem)->getTheme() != theme, "ThemeSettings should not be set yet!"); |
1721 | + QVERIFY2(styledItem->getTheme() != theme, "ThemeSettings should not be set yet!"); |
1722 | theme->setName(themeName); |
1723 | // set the style on the item |
1724 | QSignalSpy themeChangeSpy(styledItem, SIGNAL(themeChanged())); |
1725 | - UCStyledItemBasePrivate::get(styledItem)->setTheme(theme); |
1726 | + styledItem->setTheme(theme); |
1727 | UbuntuTestCase::waitForSignal(&themeChangeSpy); |
1728 | // test on the items |
1729 | for (int i = 0; i < testItems.count(); i++) { |
1730 | @@ -413,8 +416,8 @@ |
1731 | QString themeName = expectedStyleNames[i]; |
1732 | bool success = sameTheme[i]; |
1733 | styledItem = view->findItem<UCStyledItemBase*>(itemName); |
1734 | - QCOMPARE(UCStyledItemBasePrivate::get(styledItem)->getTheme() == theme, success); |
1735 | - QCOMPARE(UCStyledItemBasePrivate::get(styledItem)->getTheme()->name(), themeName); |
1736 | + QCOMPARE(styledItem->getTheme() == theme, success); |
1737 | + QCOMPARE(styledItem->getTheme()->name(), themeName); |
1738 | } |
1739 | } |
1740 | |
1741 | @@ -451,15 +454,15 @@ |
1742 | |
1743 | QScopedPointer<ThemeTestCase> view(new ThemeTestCase("TestStyleChange.qml")); |
1744 | UCStyledItemBase *testItem = view->findItem<UCStyledItemBase*>(testStyledItem); |
1745 | - QCOMPARE(UCStyledItemBasePrivate::get(testItem)->getTheme()->name(), testStyledItemThemes[0]); |
1746 | + QCOMPARE(testItem->getTheme()->name(), testStyledItemThemes[0]); |
1747 | |
1748 | UCTheme *theme = view->findItem<UCTheme*>("Theme"); |
1749 | theme->setName("Ubuntu.Components.Themes.SuruDark"); |
1750 | UCStyledItemBase *suruItem = view->findItem<UCStyledItemBase*>(suruStyledItem); |
1751 | QSignalSpy themeChangeSpy(suruItem, SIGNAL(themeChanged())); |
1752 | - UCStyledItemBasePrivate::get(suruItem)->setTheme(theme); |
1753 | + suruItem->setTheme(theme); |
1754 | UbuntuTestCase::waitForSignal(&themeChangeSpy); |
1755 | - QCOMPARE(UCStyledItemBasePrivate::get(testItem)->getTheme()->name(), testStyledItemThemes[1]); |
1756 | + QCOMPARE(testItem->getTheme()->name(), testStyledItemThemes[1]); |
1757 | |
1758 | // get items and reparent |
1759 | QQuickItem *sourceItem = view->findItem<QQuickItem*>(sourceItemName); |
1760 | @@ -470,7 +473,7 @@ |
1761 | QSignalSpy themeSpy(testItem, SIGNAL(themeChanged())); |
1762 | sourceItem->setParentItem(newParentItem); |
1763 | themeSpy.wait(200); |
1764 | - QCOMPARE(UCStyledItemBasePrivate::get(testItem)->getTheme()->name(), testStyledItemThemes[2]); |
1765 | + QCOMPARE(testItem->getTheme()->name(), testStyledItemThemes[2]); |
1766 | QCOMPARE(themeSpy.count(), 1); |
1767 | } |
1768 | |
1769 | @@ -480,8 +483,8 @@ |
1770 | UCStyledItemBase *main = qobject_cast<UCStyledItemBase*>(view->rootObject()); |
1771 | QVERIFY(main); |
1772 | UCStyledItemBase *test = view->findItem<UCStyledItemBase*>("firstLevelStyled"); |
1773 | - QCOMPARE(UCStyledItemBasePrivate::get(main)->getTheme()->name(), |
1774 | - UCStyledItemBasePrivate::get(test)->getTheme()->name()); |
1775 | + QCOMPARE(main->getTheme()->name(), |
1776 | + test->getTheme()->name()); |
1777 | } |
1778 | |
1779 | void test_no_change_in_other_suru_dark() |
1780 | @@ -510,7 +513,7 @@ |
1781 | QScopedPointer<ThemeTestCase> view(new ThemeTestCase("ChangeDefaultPaletteInChildren.qml")); |
1782 | QQuickItem *loader = view->findItem<QQuickItem*>("loader"); |
1783 | UCStyledItemBase *main = qobject_cast<UCStyledItemBase*>(view->rootObject()); |
1784 | - UCTheme *mainSet = UCStyledItemBasePrivate::get(main)->getTheme(); |
1785 | + UCTheme *mainSet = main->getTheme(); |
1786 | QQuickItem *item = loader->property("item").value<QQuickItem*>(); |
1787 | QVERIFY(item); |
1788 | |
1789 | @@ -590,20 +593,20 @@ |
1790 | UCStyledItemBase *movableItem = view->findItem<UCStyledItemBase*>("movable"); |
1791 | |
1792 | // verify movableItem's theme |
1793 | - QCOMPARE(UCStyledItemBasePrivate::get(root)->getTheme(), UCStyledItemBasePrivate::get(movableItem)->getTheme()); |
1794 | + QCOMPARE(root->getTheme(), movableItem->getTheme()); |
1795 | |
1796 | // set the theme for root |
1797 | QSignalSpy themeChangeSpy(root, SIGNAL(themeChanged())); |
1798 | - UCStyledItemBasePrivate::get(root)->setTheme(suruTheme); |
1799 | + root->setTheme(suruTheme); |
1800 | UbuntuTestCase::waitForSignal(&themeChangeSpy); |
1801 | - QCOMPARE(UCStyledItemBasePrivate::get(root)->getTheme(), UCStyledItemBasePrivate::get(movableItem)->getTheme()); |
1802 | + QCOMPARE(root->getTheme(), movableItem->getTheme()); |
1803 | |
1804 | // set the parent item of the test item to 0 |
1805 | QSignalSpy spy(movableItem, SIGNAL(themeChanged())); |
1806 | movableItem->setParentItem(Q_NULLPTR); |
1807 | spy.wait(500); |
1808 | QCOMPARE(spy.count(), 1); |
1809 | - QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme(), &UCTheme::defaultTheme()); |
1810 | + QCOMPARE(movableItem->getTheme(), &UCTheme::defaultTheme()); |
1811 | } |
1812 | |
1813 | void test_reparented_styleditem_special_case() |
1814 | @@ -617,19 +620,19 @@ |
1815 | UCStyledItemBase *movableItem = view->findItem<UCStyledItemBase*>("movable"); |
1816 | |
1817 | // check the themes |
1818 | - QCOMPARE(UCStyledItemBasePrivate::get(root)->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance")); |
1819 | - QCOMPARE(UCStyledItemBasePrivate::get(customThemedItem)->getTheme()->name(), QString("CustomTheme")); |
1820 | - QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance")); |
1821 | + QCOMPARE(root->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance")); |
1822 | + QCOMPARE(customThemedItem->getTheme()->name(), QString("CustomTheme")); |
1823 | + QCOMPARE(movableItem->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance")); |
1824 | |
1825 | // move the movableItem under customThemedItem |
1826 | movableItem->setParentItem(customThemedItem); |
1827 | - QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme()->name(), QString("CustomTheme")); |
1828 | + QCOMPARE(movableItem->getTheme()->name(), QString("CustomTheme")); |
1829 | |
1830 | // set a new theme for the root, and make sure our theme stays the same |
1831 | QSignalSpy themeChangeSpy(root, SIGNAL(themeChanged())); |
1832 | - UCStyledItemBasePrivate::get(root)->setTheme(suruTheme); |
1833 | + root->setTheme(suruTheme); |
1834 | UbuntuTestCase::waitForSignal(&themeChangeSpy); |
1835 | - QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme()->name(), QString("CustomTheme")); |
1836 | + QCOMPARE(movableItem->getTheme()->name(), QString("CustomTheme")); |
1837 | } |
1838 | |
1839 | void test_theme_versions_data() |
1840 | @@ -661,6 +664,16 @@ |
1841 | ThemeTestCase::ignoreWarning(document, 19, 1, "QML StyledItem: Warning: Style TestStyle.qml not found in theme Ubuntu.Components.Themes.Ambiance"); |
1842 | } |
1843 | |
1844 | + void test_mixed_versions() { |
1845 | + QTest::ignoreMessage(QtWarningMsg, "\"Mixing of Ubuntu.Components module versions 1.3 and 1.2 detected!\""); |
1846 | + QScopedPointer<ThemeTestCase> view(new ThemeTestCase("OtherVersion.qml")); |
1847 | + QTest::waitForEvents(); |
1848 | + UCStyledItemBase *newStyled = static_cast<UCStyledItemBase*>(view->rootObject()); |
1849 | + UCStyledItemBase *otherStyled = view->findItem<UCStyledItemBase*>("otherStyled"); |
1850 | + QCOMPARE(UCStyledItemBasePrivate::get(newStyled)->styleInstance()->objectName(), QString("OptionSelector13")); |
1851 | + QCOMPARE(UCStyledItemBasePrivate::get(otherStyled)->styleInstance()->objectName(), QString("OptionSelector12")); |
1852 | + } |
1853 | + |
1854 | void test_deprecated_theme() |
1855 | { |
1856 | qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", ""); |
1857 | @@ -710,7 +723,7 @@ |
1858 | { |
1859 | QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml")); |
1860 | UCStyledItemBase *button = view->findItem<UCStyledItemBase*>("TestButton"); |
1861 | - UCTheme *theme = UCStyledItemBasePrivate::get(button)->getTheme(); |
1862 | + UCTheme *theme = button->getTheme(); |
1863 | QVERIFY(theme); |
1864 | |
1865 | QVERIFY(button->findChild<QQuickItem*>("TestStyle")); |
1866 | |
1867 | === modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.pro' |
1868 | --- tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-06-02 12:37:41 +0000 |
1869 | +++ tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-10-20 11:06:17 +0000 |
1870 | @@ -28,8 +28,6 @@ |
1871 | themes/CustomTheme/1.3/TestStyle.qml \ |
1872 | StyledItemV12.qml \ |
1873 | StyledItemV13.qml \ |
1874 | - StyledItemFallback.qml \ |
1875 | - StyledItemAppThemeFallback.qml \ |
1876 | DeprecatedTheme.qml \ |
1877 | StyledItemAppThemeVersioned.qml \ |
1878 | StyleOverride.qml \ |
1879 | @@ -43,6 +41,7 @@ |
1880 | MoreStyleHints.qml \ |
1881 | GroupPropertyBindingHints.qml \ |
1882 | OverrideStyleHints.qml \ |
1883 | - HintedButton.qml |
1884 | + HintedButton.qml \ |
1885 | + OtherVersion.qml |
1886 | |
1887 |
Smart approach, didn't see that one coming!
My gut feeling is that removing "version" now (as opposed to making it a no-op) might come as a surprise to some, since it has been there since May. Although our policy has no timeframe attached. If Tim is fine affirming this I won't let me paranoia stand in the way.