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

Proposed by Zsombor Egri on 2015-05-22
Status: Merged
Approved by: Zsombor Egri on 2015-05-29
Approved revision: 1526
Merged at revision: 1521
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/stylename
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 1494 lines (+409/-171)
58 files modified
components.api (+1/-1)
documentation/ubuntu-theming.qdoc (+13/-7)
modules/Ubuntu/Components/1.1/Button.qml (+1/-1)
modules/Ubuntu/Components/1.3/ActionBar.qml (+1/-1)
modules/Ubuntu/Components/1.3/ActivityIndicator.qml (+1/-1)
modules/Ubuntu/Components/1.3/AppHeader.qml (+1/-2)
modules/Ubuntu/Components/1.3/Button.qml (+1/-1)
modules/Ubuntu/Components/1.3/CheckBox.qml (+1/-1)
modules/Ubuntu/Components/1.3/ComboButton.qml (+1/-1)
modules/Ubuntu/Components/1.3/MainViewBase.qml (+1/-1)
modules/Ubuntu/Components/1.3/OptionSelector.qml (+1/-1)
modules/Ubuntu/Components/1.3/ProgressBar.qml (+1/-1)
modules/Ubuntu/Components/1.3/PullToRefresh.qml (+1/-1)
modules/Ubuntu/Components/1.3/Scrollbar.qml (+1/-1)
modules/Ubuntu/Components/1.3/Slider.qml (+1/-1)
modules/Ubuntu/Components/1.3/Switch.qml (+1/-1)
modules/Ubuntu/Components/1.3/TabBar.qml (+1/-1)
modules/Ubuntu/Components/1.3/TextArea.qml (+1/-1)
modules/Ubuntu/Components/1.3/TextCursor.qml (+1/-1)
modules/Ubuntu/Components/1.3/TextField.qml (+1/-1)
modules/Ubuntu/Components/1.3/TextInputPopover.qml (+1/-1)
modules/Ubuntu/Components/1.3/Toolbar.qml (+1/-1)
modules/Ubuntu/Components/1.3/ToolbarButton.qml (+1/-1)
modules/Ubuntu/Components/ListItems/1.3/ItemSelector.qml (+1/-1)
modules/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml (+1/-1)
modules/Ubuntu/Components/Pickers/1.3/DatePicker.qml (+1/-1)
modules/Ubuntu/Components/Pickers/1.3/Dialer.qml (+1/-1)
modules/Ubuntu/Components/Pickers/1.3/DialerHand.qml (+1/-1)
modules/Ubuntu/Components/Pickers/1.3/Picker.qml (+1/-1)
modules/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml (+1/-1)
modules/Ubuntu/Components/Popups/1.3/Dialog.qml (+1/-1)
modules/Ubuntu/Components/Popups/1.3/Popover.qml (+1/-1)
modules/Ubuntu/Components/Popups/1.3/SheetBase.qml (+1/-1)
modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml (+1/-1)
modules/Ubuntu/Components/plugin/plugin.cpp (+1/-0)
modules/Ubuntu/Components/plugin/uclistitem.cpp (+21/-29)
modules/Ubuntu/Components/plugin/uclistitem_p.h (+1/-2)
modules/Ubuntu/Components/plugin/ucstyleditembase.cpp (+125/-34)
modules/Ubuntu/Components/plugin/ucstyleditembase.h (+4/-1)
modules/Ubuntu/Components/plugin/ucstyleditembase_p.h (+8/-9)
modules/Ubuntu/Components/plugin/uctheme.cpp (+16/-14)
modules/Ubuntu/Components/plugin/uctheme.h (+1/-2)
tests/resources/navigation/tabs.qml (+2/-2)
tests/unit/tst_performance/PaletteConfigurationAllColors.qml (+1/-1)
tests/unit/tst_performance/PaletteConfigurationOneColor.qml (+1/-1)
tests/unit_x11/tst_subtheming/DeprecatedTheme.qml (+1/-1)
tests/unit_x11/tst_subtheming/SimpleItem.qml (+2/-6)
tests/unit_x11/tst_subtheming/StyleKept.qml (+43/-0)
tests/unit_x11/tst_subtheming/StyleOverride.qml (+46/-0)
tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml (+1/-1)
tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml (+1/-1)
tests/unit_x11/tst_subtheming/StyledItemFallback.qml (+1/-1)
tests/unit_x11/tst_subtheming/StyledItemV12.qml (+1/-1)
tests/unit_x11/tst_subtheming/StyledItemV13.qml (+1/-1)
tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml (+1/-0)
tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml (+1/-0)
tests/unit_x11/tst_subtheming/tst_subtheming.cpp (+80/-22)
tests/unit_x11/tst_subtheming/tst_subtheming.pro (+3/-1)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/stylename
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-05-29
Christian Dywan 2015-05-22 Approve on 2015-05-26
Review via email: mp+259928@code.launchpad.net

Commit Message

Remove ThemeSettings.createStyleComponent() and add styleName to StyledItem.

To post a comment you must log in.
Christian Dywan (kalikiana) wrote :

37 - * style: theme.createStyleComponent("ButtonStyle.qml", button)
38 + * styleName: "ButtonStyle"

103 - style: theme.createStyleComponent("ActionBarStyle.qml", bar)
104 + styleName: "ActionBarStyle.qml"

710 + * \qmlproperty string StyledItem::styleName
711 + * The property specifies the component style name. The style name is a document
712 + * in the current theme, and may contain or not the qml file extension. If not
713 + * specified, the extension will be appended during style creation.

Is the optional extension really useful? This branch is already introducing a mix of names with and without .qml in the name. And it immediately makes you wonder if one or the other is wrong. I'd prefer we have one way of doing it.

review: Needs Fixing
Christian Dywan (kalikiana) wrote :

Very nice. Thanks!

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-05-22 11:18:01 +0000
3+++ components.api 2015-05-26 15:05:58 +0000
4@@ -876,6 +876,7 @@
5 function bool requestFocus(Qt.FocusReason reason)
6 function bool requestFocus()
7 property Component style
8+ property string styleName
9 property ThemeSettings theme
10 Ubuntu.Components.ListItems.Subtitled 1.0 0.1: Base
11 property string subText
12@@ -1198,7 +1199,6 @@
13 Ubuntu.PerformanceMetrics.TextureFromImage 1.0 0.1: Item
14 property QImage image
15 Ubuntu.Components.ThemeSettings 1.3: QtObject
16- function QQmlComponent* createStyleComponent(string styleName, QtObject parent)
17 property string name
18 property QtObject palette
19 readonly property ThemeSettings parentTheme
20
21=== modified file 'documentation/ubuntu-theming.qdoc'
22--- documentation/ubuntu-theming.qdoc 2015-05-04 10:58:14 +0000
23+++ documentation/ubuntu-theming.qdoc 2015-05-26 15:05:58 +0000
24@@ -78,7 +78,7 @@
25 * \section2 Naming conventions
26 * With few exception, each toolkit component is having StyledItem as its base
27 * component. The component is aimed to be the base component for all styled
28- * elements in the toolkit. Modules providing additional components to UI Toolkit
29+ * elements in the toolkit. Modules providing additional components to UI Toolkit
30 * can also use this component as base, especially if they want to provide styling
31 * capabilities.
32 *
33@@ -93,7 +93,7 @@
34 * AbstractButton {
35 * id: button
36 * // [...]
37- * style: theme.createStyleComponent("ButtonStyle.qml", button)
38+ * styleName: "ButtonStyle"
39 * }
40 * \endqml
41 * Developers can override the style in two ways, depending on how they want to style
42@@ -127,7 +127,7 @@
43 * A typical example of such a style API is the PullToRefresh component's style:
44 * \snippet Styles/1.2/PullToRefreshStyle.qml 0
45 * The default style implementation can be found under Ubuntu.Components.Themes.Ambiance
46- * theme \l {http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/trunk/view/head:/modules/Ubuntu/Components/Themes/Ambiance/PullToRefreshStyle.qml}
47+ * theme \l {http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/trunk/view/head:/modules/Ubuntu/Components/Themes/Ambiance/1.3/PullToRefreshStyle.qml}
48 * {PullToRefreshStyle.qml}.
49 *
50 * Beside these, component styles may provide default values for colors, fonts, widths,
51@@ -141,15 +141,17 @@
52 *
53 * \section3 Override with a different style from the theme
54 * Returning back to the ways to override a component's style, overriding by using a different
55- * style from the theme can simply be done by calling the theme's \l{Theme::createStyleComponent}
56- * {createStyleComponent()} function with the alternative style document name as follows:
57+ * style from the theme can simply be done by assigning the document name to the \l {StyledItem::styleName}
58+ * {StyledItem.styleName} property as follows:
59 * \qml
60 * Button {
61 * id: button
62- * style: theme.createStyleComponent("SquaryButtonStyle.qml", button)
63+ * styleName: "SquaryButtonStyle"
64 * }
65 * \endqml
66- * \note This assumes that the \c SquaryButtonStyle.qml document is present in the theme.
67+ * \note The document extension doesn't have to be specified, the style creation will automatically
68+ * append the .qml extension to it. This kind of style override assumes that the \c SquaryButtonStyle.qml
69+ * document is present in the theme.
70 * This type of component styling makes sure the style will always have theme specific implementation
71 * or coloring, however it also requires the style document to be present in all the themes
72 * used by the application.
73@@ -178,6 +180,10 @@
74 * }
75 * }
76 * \endqml
77+ * \note Specifying a component for the \l {StyledItem::style}{StyledItem.style} has precedence
78+ * over the \l {StyledItem::styleName}{StyledItem::styleName}. When both set, the stlke specified
79+ * \c style property will be used. When this property is set to undefined or null, the style specified
80+ * in \c styleName will be used. Obviously, when both properties are invalid, no style will be used.
81 */
82
83 /*!
84
85=== modified file 'modules/Ubuntu/Components/1.1/Button.qml'
86--- modules/Ubuntu/Components/1.1/Button.qml 2015-04-24 12:00:23 +0000
87+++ modules/Ubuntu/Components/1.1/Button.qml 2015-05-26 15:05:58 +0000
88@@ -122,5 +122,5 @@
89 property string iconPosition: "left"
90
91 theme.version: Ubuntu.toolkitVersion
92- style: theme.createStyleComponent("ButtonStyle.qml", button)
93+ style: Theme.createStyleComponent("ButtonStyle.qml", button)
94 }
95
96=== modified file 'modules/Ubuntu/Components/1.3/ActionBar.qml'
97--- modules/Ubuntu/Components/1.3/ActionBar.qml 2015-05-14 20:33:48 +0000
98+++ modules/Ubuntu/Components/1.3/ActionBar.qml 2015-05-26 15:05:58 +0000
99@@ -50,7 +50,7 @@
100 */
101 StyledItem {
102 id: bar
103- style: theme.createStyleComponent("ActionBarStyle.qml", bar)
104+ styleName: "ActionBarStyle"
105
106 /*!
107 The actions to display in the bar.
108
109=== modified file 'modules/Ubuntu/Components/1.3/ActivityIndicator.qml'
110--- modules/Ubuntu/Components/1.3/ActivityIndicator.qml 2015-04-25 08:54:58 +0000
111+++ modules/Ubuntu/Components/1.3/ActivityIndicator.qml 2015-05-26 15:05:58 +0000
112@@ -55,5 +55,5 @@
113 implicitWidth: units.gu(3)
114 implicitHeight: units.gu(3)
115
116- style: theme.createStyleComponent("ActivityIndicatorStyle.qml", indicator)
117+ styleName: "ActivityIndicatorStyle"
118 }
119
120=== modified file 'modules/Ubuntu/Components/1.3/AppHeader.qml'
121--- modules/Ubuntu/Components/1.3/AppHeader.qml 2015-04-30 08:32:44 +0000
122+++ modules/Ubuntu/Components/1.3/AppHeader.qml 2015-05-26 15:05:58 +0000
123@@ -343,6 +343,5 @@
124 }
125
126 theme.version: Components.Ubuntu.toolkitVersion
127- style: header.useDeprecatedToolbar ? theme.createStyleComponent("HeaderStyle.qml", header) :
128- theme.createStyleComponent("PageHeadStyle.qml", header)
129+ styleName: header.useDeprecatedToolbar ? "HeaderStyle" : "PageHeadStyle"
130 }
131
132=== modified file 'modules/Ubuntu/Components/1.3/Button.qml'
133--- modules/Ubuntu/Components/1.3/Button.qml 2015-04-25 08:54:58 +0000
134+++ modules/Ubuntu/Components/1.3/Button.qml 2015-05-26 15:05:58 +0000
135@@ -122,5 +122,5 @@
136 property string iconPosition: "left"
137
138 theme.version: Ubuntu.toolkitVersion
139- style: theme.createStyleComponent("ButtonStyle.qml", button)
140+ styleName: "ButtonStyle"
141 }
142
143=== modified file 'modules/Ubuntu/Components/1.3/CheckBox.qml'
144--- modules/Ubuntu/Components/1.3/CheckBox.qml 2015-04-25 08:54:58 +0000
145+++ modules/Ubuntu/Components/1.3/CheckBox.qml 2015-05-26 15:05:58 +0000
146@@ -50,5 +50,5 @@
147 onTriggered: checked = !checked
148
149 theme.version: Ubuntu.toolkitVersion
150- style: theme.createStyleComponent("CheckBoxStyle.qml", checkBox)
151+ styleName: "CheckBoxStyle"
152 }
153
154=== modified file 'modules/Ubuntu/Components/1.3/ComboButton.qml'
155--- modules/Ubuntu/Components/1.3/ComboButton.qml 2015-04-29 08:55:31 +0000
156+++ modules/Ubuntu/Components/1.3/ComboButton.qml 2015-05-26 15:05:58 +0000
157@@ -247,7 +247,7 @@
158 property color dropdownColor: __styleInstance ? __styleInstance.defaultDropdownColor : color
159
160
161- style: theme.createStyleComponent("ComboButtonStyle.qml", combo)
162+ styleName: "ComboButtonStyle"
163
164 Component.onCompleted: {
165 // update mouse area to report clicks only on the main button area
166
167=== modified file 'modules/Ubuntu/Components/1.3/MainViewBase.qml'
168--- modules/Ubuntu/Components/1.3/MainViewBase.qml 2015-04-25 08:54:58 +0000
169+++ modules/Ubuntu/Components/1.3/MainViewBase.qml 2015-05-26 15:05:58 +0000
170@@ -36,7 +36,7 @@
171 id: background
172 anchors.fill: parent
173 // theme is inherited from PageTreeNode, no need to update versioning
174- style: theme.createStyleComponent("MainViewStyle.qml", background)
175+ styleName: "MainViewStyle"
176
177 property color headerColor: backgroundColor
178 property color backgroundColor: theme.palette.normal.background
179
180=== modified file 'modules/Ubuntu/Components/1.3/OptionSelector.qml'
181--- modules/Ubuntu/Components/1.3/OptionSelector.qml 2015-04-29 07:21:29 +0000
182+++ modules/Ubuntu/Components/1.3/OptionSelector.qml 2015-05-26 15:05:58 +0000
183@@ -226,7 +226,7 @@
184 }
185 state: optionSelector.expanded ? "expanded" : "collapsed"
186 theme.version: Toolkit.Ubuntu.toolkitVersion
187- style: theme.createStyleComponent("OptionSelectorStyle.qml", listContainer)
188+ styleName: "OptionSelectorStyle"
189 states: [ State {
190 name: "expanded"
191 when: listContainer.currentlyExpanded
192
193=== modified file 'modules/Ubuntu/Components/1.3/ProgressBar.qml'
194--- modules/Ubuntu/Components/1.3/ProgressBar.qml 2015-05-04 10:58:14 +0000
195+++ modules/Ubuntu/Components/1.3/ProgressBar.qml 2015-05-26 15:05:58 +0000
196@@ -71,5 +71,5 @@
197 property bool showProgressPercentage: true
198
199 theme.version: Ubuntu.toolkitVersion
200- style: theme.createStyleComponent("ProgressBarStyle.qml", progressBar)
201+ styleName: "ProgressBarStyle"
202 }
203
204=== modified file 'modules/Ubuntu/Components/1.3/PullToRefresh.qml'
205--- modules/Ubuntu/Components/1.3/PullToRefresh.qml 2015-04-29 07:21:29 +0000
206+++ modules/Ubuntu/Components/1.3/PullToRefresh.qml 2015-05-26 15:05:58 +0000
207@@ -223,7 +223,7 @@
208 signal refresh()
209
210 theme.version: Ubuntu.toolkitVersion
211- style: theme.createStyleComponent("PullToRefreshStyle.qml", control)
212+ styleName: "PullToRefreshStyle"
213 implicitHeight: __styleInstance.implicitHeight
214 anchors {
215 left: target.left
216
217=== modified file 'modules/Ubuntu/Components/1.3/Scrollbar.qml'
218--- modules/Ubuntu/Components/1.3/Scrollbar.qml 2015-04-25 08:54:58 +0000
219+++ modules/Ubuntu/Components/1.3/Scrollbar.qml 2015-05-26 15:05:58 +0000
220@@ -147,5 +147,5 @@
221 }
222
223 theme.version: Toolkit.Ubuntu.toolkitVersion
224- style: theme.createStyleComponent("ScrollbarStyle.qml", scrollbar)
225+ styleName: "ScrollbarStyle"
226 }
227
228=== modified file 'modules/Ubuntu/Components/1.3/Slider.qml'
229--- modules/Ubuntu/Components/1.3/Slider.qml 2015-05-12 20:15:43 +0000
230+++ modules/Ubuntu/Components/1.3/Slider.qml 2015-05-26 15:05:58 +0000
231@@ -207,5 +207,5 @@
232 }
233
234 theme.version: Toolkit.Ubuntu.toolkitVersion
235- style: theme.createStyleComponent("SliderStyle.qml", slider)
236+ styleName: "SliderStyle"
237 }
238
239=== modified file 'modules/Ubuntu/Components/1.3/Switch.qml'
240--- modules/Ubuntu/Components/1.3/Switch.qml 2015-04-25 08:54:58 +0000
241+++ modules/Ubuntu/Components/1.3/Switch.qml 2015-05-26 15:05:58 +0000
242@@ -40,5 +40,5 @@
243 */
244 CheckBox {
245 id: switchItem
246- style: theme.createStyleComponent("SwitchStyle.qml", switchItem)
247+ styleName: "SwitchStyle"
248 }
249
250=== modified file 'modules/Ubuntu/Components/1.3/TabBar.qml'
251--- modules/Ubuntu/Components/1.3/TabBar.qml 2015-04-25 08:54:58 +0000
252+++ modules/Ubuntu/Components/1.3/TabBar.qml 2015-05-26 15:05:58 +0000
253@@ -98,7 +98,7 @@
254 implicitHeight: units.gu(7.5)
255 activeFocusOnPress: true
256 theme.version: Toolkit.Ubuntu.toolkitVersion
257- style: theme.createStyleComponent("TabBarStyle.qml", tabBar)
258+ styleName: "TabBarStyle"
259
260 QtObject {
261 id: internal
262
263=== modified file 'modules/Ubuntu/Components/1.3/TextArea.qml'
264--- modules/Ubuntu/Components/1.3/TextArea.qml 2015-05-21 09:58:30 +0000
265+++ modules/Ubuntu/Components/1.3/TextArea.qml 2015-05-26 15:05:58 +0000
266@@ -892,5 +892,5 @@
267 }
268
269 theme.version: Ubuntu.Ubuntu.toolkitVersion
270- style: theme.createStyleComponent("TextAreaStyle.qml", control)
271+ styleName: "TextAreaStyle"
272 }
273
274=== modified file 'modules/Ubuntu/Components/1.3/TextCursor.qml'
275--- modules/Ubuntu/Components/1.3/TextCursor.qml 2015-05-15 10:35:06 +0000
276+++ modules/Ubuntu/Components/1.3/TextCursor.qml 2015-05-26 15:05:58 +0000
277@@ -42,7 +42,7 @@
278 __styleInstance.cursorDelegate
279
280 theme.version: Ubuntu.Ubuntu.toolkitVersion
281- style: theme.createStyleComponent("TextCursorStyle.qml", cursorItem);
282+ styleName: "TextCursorStyle"
283
284 objectName: "textCursor"
285 //Caret instance from the style.
286
287=== modified file 'modules/Ubuntu/Components/1.3/TextField.qml'
288--- modules/Ubuntu/Components/1.3/TextField.qml 2015-05-21 09:58:30 +0000
289+++ modules/Ubuntu/Components/1.3/TextField.qml 2015-05-26 15:05:58 +0000
290@@ -1020,5 +1020,5 @@
291 }
292
293 theme.version: Ubuntu.Ubuntu.toolkitVersion
294- style: theme.createStyleComponent("TextFieldStyle.qml", control)
295+ styleName: "TextFieldStyle"
296 }
297
298=== modified file 'modules/Ubuntu/Components/1.3/TextInputPopover.qml'
299--- modules/Ubuntu/Components/1.3/TextInputPopover.qml 2015-05-20 06:31:45 +0000
300+++ modules/Ubuntu/Components/1.3/TextInputPopover.qml 2015-05-26 15:05:58 +0000
301@@ -98,7 +98,7 @@
302 height: units.gu(6)
303 action: actions[modelData]
304 theme.version: Ubuntu.toolkitVersion
305- style: theme.createStyleComponent("ToolbarButtonStyle.qml", button)
306+ styleName: "ToolbarButtonStyle"
307 }
308 }
309 }
310
311=== modified file 'modules/Ubuntu/Components/1.3/Toolbar.qml'
312--- modules/Ubuntu/Components/1.3/Toolbar.qml 2015-04-25 08:54:58 +0000
313+++ modules/Ubuntu/Components/1.3/Toolbar.qml 2015-05-26 15:05:58 +0000
314@@ -136,7 +136,7 @@
315 property bool animating: toolbar.animating
316
317 theme.version: Toolkit.Ubuntu.toolkitVersion
318- style: theme.createStyleComponent("ToolbarStyle.qml", background)
319+ styleName: "ToolbarStyle"
320 }
321
322 Item {
323
324=== modified file 'modules/Ubuntu/Components/1.3/ToolbarButton.qml'
325--- modules/Ubuntu/Components/1.3/ToolbarButton.qml 2015-04-25 08:54:58 +0000
326+++ modules/Ubuntu/Components/1.3/ToolbarButton.qml 2015-05-26 15:05:58 +0000
327@@ -85,5 +85,5 @@
328 width: units.gu(5)
329
330 theme.version: Ubuntu.toolkitVersion
331- style: theme.createStyleComponent("ToolbarButtonStyle.qml", toolbarButton)
332+ styleName: "ToolbarButtonStyle"
333 }
334
335=== modified file 'modules/Ubuntu/Components/ListItems/1.3/ItemSelector.qml'
336--- modules/Ubuntu/Components/ListItems/1.3/ItemSelector.qml 2015-04-29 07:21:29 +0000
337+++ modules/Ubuntu/Components/ListItems/1.3/ItemSelector.qml 2015-05-26 15:05:58 +0000
338@@ -217,7 +217,7 @@
339 }
340 state: itemSelector.expanded ? "expanded" : "collapsed"
341 theme.version: Ubuntu.toolkitVersion
342- style: theme.createStyleComponent("ListItemOptionSelectorStyle.qml", listContainer)
343+ styleName: "ListItemOptionSelectorStyle"
344
345 states: [ State {
346 name: "expanded"
347
348=== modified file 'modules/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml'
349--- modules/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml 2015-04-29 07:21:29 +0000
350+++ modules/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml 2015-05-26 15:05:58 +0000
351@@ -26,5 +26,5 @@
352 property real splitMargin
353
354 theme.version: Ubuntu.toolkitVersion
355- style: theme.createStyleComponent("ProgressionVisualStyle.qml", progressionVisual)
356+ styleName: "ProgressionVisualStyle"
357 }
358
359=== modified file 'modules/Ubuntu/Components/Pickers/1.3/DatePicker.qml'
360--- modules/Ubuntu/Components/Pickers/1.3/DatePicker.qml 2015-04-29 07:44:05 +0000
361+++ modules/Ubuntu/Components/Pickers/1.3/DatePicker.qml 2015-05-26 15:05:58 +0000
362@@ -421,7 +421,7 @@
363 }
364
365 theme.version: Ubuntu.toolkitVersion
366- style: theme.createStyleComponent("DatePickerStyle.qml", datePicker)
367+ styleName: "DatePickerStyle"
368 Binding {
369 target: __styleInstance
370 property: "view"
371
372=== modified file 'modules/Ubuntu/Components/Pickers/1.3/Dialer.qml'
373--- modules/Ubuntu/Components/Pickers/1.3/Dialer.qml 2015-04-29 07:44:05 +0000
374+++ modules/Ubuntu/Components/Pickers/1.3/Dialer.qml 2015-05-26 15:05:58 +0000
375@@ -146,7 +146,7 @@
376 activeFocusOnPress: true
377
378 theme.version: Ubuntu.toolkitVersion
379- style: theme.createStyleComponent("DialerStyle.qml", dialer)
380+ styleName: "DialerStyle"
381
382 Item {
383 id: internal
384
385=== modified file 'modules/Ubuntu/Components/Pickers/1.3/DialerHand.qml'
386--- modules/Ubuntu/Components/Pickers/1.3/DialerHand.qml 2015-04-29 07:44:05 +0000
387+++ modules/Ubuntu/Components/Pickers/1.3/DialerHand.qml 2015-05-26 15:05:58 +0000
388@@ -144,7 +144,7 @@
389 height: parent.height
390 activeFocusOnPress: true
391 theme.version: Ubuntu.toolkitVersion
392- style: theme.createStyleComponent("DialerHandStyle.qml", dialerHand)
393+ styleName: "DialerHandStyle"
394
395 /*! \internal */
396 onParentChanged: {
397
398=== modified file 'modules/Ubuntu/Components/Pickers/1.3/Picker.qml'
399--- modules/Ubuntu/Components/Pickers/1.3/Picker.qml 2015-04-29 07:44:05 +0000
400+++ modules/Ubuntu/Components/Pickers/1.3/Picker.qml 2015-05-26 15:05:58 +0000
401@@ -160,7 +160,7 @@
402 activeFocusOnPress: true
403
404 theme.version: Ubuntu.toolkitVersion
405- style: theme.createStyleComponent("PickerStyle.qml", picker)
406+ styleName: "PickerStyle"
407
408 /*! \internal */
409 property int __clickedIndex: -1
410
411=== modified file 'modules/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml'
412--- modules/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml 2015-04-29 07:44:05 +0000
413+++ modules/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml 2015-05-26 15:05:58 +0000
414@@ -48,7 +48,7 @@
415 }
416
417 theme.version: Ubuntu.toolkitVersion
418- style: theme.createStyleComponent("PickerDelegateStyle.qml", pickerDelegate)
419+ styleName: "PickerDelegateStyle"
420
421 QtObject {
422 id: internal
423
424=== modified file 'modules/Ubuntu/Components/Popups/1.3/Dialog.qml'
425--- modules/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-04-29 08:55:31 +0000
426+++ modules/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-05-26 15:05:58 +0000
427@@ -214,6 +214,6 @@
428 }
429
430 theme.version: Ubuntu.toolkitVersion
431- style: theme.createStyleComponent("DialogForegroundStyle.qml", foreground)
432+ styleName: "DialogForegroundStyle"
433 }
434 }
435
436=== modified file 'modules/Ubuntu/Components/Popups/1.3/Popover.qml'
437--- modules/Ubuntu/Components/Popups/1.3/Popover.qml 2015-04-29 08:55:31 +0000
438+++ modules/Ubuntu/Components/Popups/1.3/Popover.qml 2015-05-26 15:05:58 +0000
439@@ -238,7 +238,7 @@
440 signal hideCompleted()
441
442 theme.version: Ubuntu.toolkitVersion
443- style: theme.createStyleComponent("PopoverForegroundStyle.qml", foreground)
444+ styleName: "PopoverForegroundStyle"
445 }
446
447 QtObject {
448
449=== modified file 'modules/Ubuntu/Components/Popups/1.3/SheetBase.qml'
450--- modules/Ubuntu/Components/Popups/1.3/SheetBase.qml 2015-04-29 08:55:31 +0000
451+++ modules/Ubuntu/Components/Popups/1.3/SheetBase.qml 2015-05-26 15:05:58 +0000
452@@ -110,6 +110,6 @@
453 }
454
455 theme.version: Ubuntu.toolkitVersion
456- style: theme.createStyleComponent("SheetForegroundStyle.qml", sheet)
457+ styleName: "SheetForegroundStyle"
458 }
459 }
460
461=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml'
462--- modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml 2015-05-11 14:43:39 +0000
463+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml 2015-05-26 15:05:58 +0000
464@@ -106,7 +106,7 @@
465 // backgroundColor is used in the new HeadDividerStyle
466 property color backgroundColor: styledItem.dividerColor
467
468- style: theme.createStyleComponent("HeadDividerStyle.qml", divider)
469+ styleName: "HeadDividerStyle"
470
471 property PageHeadSections sections: styledItem.config.sections
472
473
474=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
475--- modules/Ubuntu/Components/plugin/plugin.cpp 2015-04-27 07:06:30 +0000
476+++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-05-26 15:05:58 +0000
477@@ -210,6 +210,7 @@
478 qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings");
479 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
480 qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13);
481+ qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
482 }
483
484 void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
485
486=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
487--- modules/Ubuntu/Components/plugin/uclistitem.cpp 2015-04-14 08:31:20 +0000
488+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2015-05-26 15:05:58 +0000
489@@ -185,7 +185,6 @@
490 , suppressClick(false)
491 , ready(false)
492 , customColor(false)
493- , customStyle(false)
494 , xAxisMoveThresholdGU(DEFAULT_SWIPE_THRESHOLD_GU)
495 , color(Qt::transparent)
496 , highlightColor(Qt::transparent)
497@@ -196,7 +195,6 @@
498 , trailingActions(0)
499 , mainAction(0)
500 {
501- styleLoadingMethod = DelayTillExplicitRequested;
502 }
503 UCListItemPrivate::~UCListItemPrivate()
504 {
505@@ -229,6 +227,7 @@
506 // watch grid unit size change and set implicit size
507 QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), q, SLOT(_q_updateSize()));
508 _q_updateSize();
509+ setStyleName("ListItemStyle");
510 }
511
512 void UCListItemPrivate::_q_themeChanged()
513@@ -260,12 +259,6 @@
514 Q_Q(UCListItem);
515 // update divider colors
516 divider->paletteChanged();
517- // if not using custom style, reload style component from theme
518- if (!customStyle && componentComplete) {
519- // use style setter but reset custom style flag
520- setStyle(getTheme()->createStyleComponent("ListItemStyle.qml", q));
521- customStyle = false;
522- }
523
524 // update colors, panels
525 if (!customColor) {
526@@ -315,44 +308,35 @@
527 Q_EMIT q->dragModeChanged();
528 }
529
530-/*!
531- * \qmlproperty Component ListItem::style
532- * Holds the style of the component defining the components visualizing the leading/
533- * trailing actions, selection and dragging mode handlers as well as different
534- * animations. The component does not assume any visuals present in the style,
535- * and will load its content only when requested.
536- * \sa ListItemStyle
537- */
538 void UCListItemPrivate::preStyleChanged()
539 {
540 snapOut();
541 UCStyledItemBasePrivate::preStyleChanged();
542- // delete style if it was non-custom style
543- if (!customStyle && styleComponent) {
544- styleComponent->deleteLater();
545- styleComponent = 0;
546- }
547- customStyle = true;
548 }
549
550 // creates the style item, with altered default value of the animatePanels style property
551 // the property is turned on after the panel initialization.
552-void UCListItemPrivate::loadStyleItem(bool animated)
553+bool UCListItemPrivate::loadStyleItem(bool animated)
554 {
555- if (!styleComponent) {
556- // try to create the style if possible
557- postThemeChanged();
558- }
559- UCStyledItemBasePrivate::loadStyleItem(animated);
560+ // the style should be loaded only if one of the condition is satisfied
561+ if (!swiped && !selectMode() && !dragMode()) {
562+ return false;
563+ }
564+
565+ if (!UCStyledItemBasePrivate::loadStyleItem(animated)) {
566+ return false;
567+ }
568+
569 UCListItemStyle *myStyle = qobject_cast<UCListItemStyle*>(styleItem);
570 if (!myStyle) {
571 // the style is not derived from ListItemStyle, clean
572 preStyleChanged();
573- return;
574+ return false;
575 }
576 // bring the panels foreground
577 styleItem->setZ(0);
578 listItemStyle()->setAnimatePanels(true);
579+ return true;
580 }
581
582 // called when units size changes
583@@ -885,6 +869,13 @@
584 * \endqml
585 *
586 * \sa ViewItems::dragMode, ViewItems::dragUpdated
587+ *
588+ * \section2 Note on styling
589+ * ListItem's styling differs from the other component sstyling, as ListItem loads
590+ * the style only when either of the leadin/trailing panels are swiped, or when the
591+ * item enters in select- or drag mode. The component does not assume any visuals
592+ * to be present in the style.
593+ * \sa ListItemStyle
594 */
595
596 /*!
597@@ -1134,6 +1125,7 @@
598 d->parentAttached->disableInteractive(this, true);
599 }
600 d->setSwiped(true);
601+ d->loadStyleItem();
602 }
603 }
604
605
606=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
607--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2015-04-14 08:31:20 +0000
608+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2015-05-26 15:05:58 +0000
609@@ -74,7 +74,6 @@
610 bool suppressClick:1;
611 bool ready:1;
612 bool customColor:1;
613- bool customStyle:1;
614 qreal xAxisMoveThresholdGU;
615 QBasicTimer pressAndHoldTimer;
616 QPointF lastPos;
617@@ -98,7 +97,7 @@
618 bool contentMoving() const;
619 void setContentMoving(bool moved);
620 virtual void preStyleChanged();
621- virtual void loadStyleItem(bool animated = true);
622+ virtual bool loadStyleItem(bool animated = true);
623 bool dragging();
624 bool dragMode();
625 void setDragMode(bool draggable);
626
627=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase.cpp'
628--- modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-04-21 13:21:17 +0000
629+++ modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-05-26 15:05:58 +0000
630@@ -24,7 +24,6 @@
631
632 UCStyledItemBasePrivate::UCStyledItemBasePrivate()
633 : activeFocusOnPress(false)
634- , styleLoadingMethod(Immediate)
635 , styleComponent(0)
636 , styleItemContext(0)
637 , styleItem(0)
638@@ -41,8 +40,10 @@
639 {
640 Q_Q(UCStyledItemBase);
641 q->setFlag(QQuickItem::ItemIsFocusScope);
642- QObject::connect(&UCTheme::defaultTheme(), &UCTheme::nameChanged,
643- q, &UCStyledItemBase::themeChanged);
644+ QObject::connect(&UCTheme::defaultTheme(), SIGNAL(nameChanged()),
645+ q, SLOT(_q_reloadStyle()));
646+ QObject::connect(&UCTheme::defaultTheme(), SIGNAL(versionChanged()),
647+ q, SLOT(_q_reloadStyle()));
648 }
649
650
651@@ -90,12 +91,17 @@
652 * \qml
653 * StyledItem {
654 * id: myItem
655- * style: theme.createStyleComponent("MyItemStyle.qml", myItem)
656+ * styleName: "MyItemStyle"
657 * }
658 * \endqml
659 *
660- * The Component set on \l style is instantiated and placed below everything else
661- * that the Item contains.
662+ * The style set on \l styleName is instantiated and placed below everything else
663+ * that the Item contains. When the style is defined in this way, the style is taken
664+ * from the current theme the StyledItem is themed with. Another way tpo set the
665+ * style of a component is to set the \l style property. This property expects a
666+ * component and it has precedence over the \l styleName, meaning that when both
667+ * \l styleName and \l style are set, the style will be created from the \l style
668+ * componment.
669 *
670 * A reference to the Item being styled is accessible from the style and named
671 * 'styledItem'.
672@@ -201,7 +207,26 @@
673
674 /*!
675 * \qmlproperty Component StyledItem::style
676- * Component instantiated immediately and placed below everything else.
677+ * Style component instantiated immediately and placed below everything else.
678+ * Has precedence over the \l styleName. When both set, the style will be
679+ * created from the component given as property value, and can be reset to the
680+ * theme style when set to null or reset (set to undefined).
681+ * \qml
682+ * Button {
683+ * text: "Press to reset"
684+ * style: Rectangle {
685+ * color: "tan"
686+ * Label {
687+ * anchors {
688+ * fill: parent
689+ * margins: units.gu(1)
690+ * }
691+ * text: styledItem.text
692+ * }
693+ * }
694+ * onClicked: style = undefined
695+ * }
696+ * \endqml
697 */
698 QQmlComponent *UCStyledItemBasePrivate::style() const
699 {
700@@ -218,6 +243,42 @@
701 postStyleChanged();
702 loadStyleItem();
703 }
704+void UCStyledItemBasePrivate::resetStyle()
705+{
706+ setStyle(Q_NULLPTR);
707+}
708+
709+/*!
710+ * \qmlproperty string StyledItem::styleName
711+ * The property specifies the component style name. The style name is a document
712+ * in the current theme, and should not contain the qml file extension. If specified
713+ * an error will be shown.
714+ * \qml
715+ * StyledItem {
716+ * id: myItem
717+ * styleName: "MyItemStyle"
718+ * }
719+ * \endqml
720+ * \note \l style property has precedence over styleName.
721+ */
722+QString UCStyledItemBasePrivate::styleName() const
723+{
724+ return styleDocument;
725+}
726+void UCStyledItemBasePrivate::setStyleName(const QString &name)
727+{
728+ if (name == styleDocument) {
729+ return;
730+ }
731+ QString prevName = styleDocument;
732+ styleDocument = name;
733+ if (prevName != styleDocument && !styleComponent) {
734+ preStyleChanged();
735+ postStyleChanged();
736+ }
737+ Q_EMIT q_func()->styleNameChanged();
738+ loadStyleItem();
739+}
740
741 // performs pre-style change actions, removes style item size change
742 // connections and destroys the style component
743@@ -236,36 +297,37 @@
744 }
745 }
746
747-// performs post-style change actions, creates the context object the
748-// style item will be created in
749-void UCStyledItemBasePrivate::postStyleChanged()
750+// loads the style animated or not, depending on the loading time
751+// returns true on successful style loading
752+bool UCStyledItemBasePrivate::loadStyleItem(bool animated)
753 {
754- if (!styleComponent || styleItemContext) {
755- return;
756+ if (styleItem || (!styleComponent && styleDocument.isEmpty()) || !componentComplete) {
757+ // the style loading is delayed
758+ return false;
759 }
760 Q_Q(UCStyledItemBase);
761+ // either styleComponent or styleName is valid
762+ QQmlComponent *component = styleComponent;
763+ if (!component) {
764+ component = getTheme()->createStyleComponent(styleDocument + ".qml", q);
765+ }
766+ if (!component) {
767+ return false;
768+ }
769+ // create context
770 // use creation context as parent to create the context we load the style item with
771- QQmlContext *creationContext = styleComponent->creationContext();
772+ QQmlContext *creationContext = component->creationContext();
773 if (!creationContext) {
774 creationContext = qmlContext(q);
775 }
776 styleItemContext = new QQmlContext(creationContext);
777 styleItemContext->setContextObject(q);
778 styleItemContext->setContextProperty("styledItem", q);
779-}
780-
781-// loads the style animated or not, depending on the loading time
782-void UCStyledItemBasePrivate::loadStyleItem(bool animated)
783-{
784- if (styleItem || !styleComponent || !styleItemContext || (styleLoadingMethod != Immediate && !componentComplete)) {
785- // the style loading is delayed
786- return;
787- }
788- Q_Q(UCStyledItemBase);
789 styleItemContext->setContextProperty("animated", animated);
790- QObject *object = styleComponent->beginCreate(styleItemContext);
791+ QObject *object = component->beginCreate(styleItemContext);
792 if (!object) {
793- return;
794+ delete styleItemContext;
795+ return false;
796 }
797 // link context to the style item to delete them together
798 QQml_setParent_noEvent(styleItemContext, object);
799@@ -281,7 +343,11 @@
800 } else {
801 delete object;
802 }
803- styleComponent->completeCreate();
804+ component->completeCreate();
805+ // delete temporary component
806+ if (!styleComponent) {
807+ delete component;
808+ }
809
810 // make sure we reset the animated property to true
811 if (!animated) {
812@@ -292,6 +358,7 @@
813 _q_styleResized();
814 connectStyleSizeChanges(true);
815 Q_EMIT q->styleInstanceChanged();
816+ return true;
817 }
818
819 /*!
820@@ -339,6 +406,19 @@
821 }
822 }
823
824+// reloads style component due to theme, theme.name or theme.version change
825+void UCStyledItemBasePrivate::_q_reloadStyle()
826+{
827+ if (styleComponent) {
828+ return;
829+ }
830+ Q_Q(UCStyledItemBase);
831+ preStyleChanged();
832+ postStyleChanged();
833+ loadStyleItem();
834+ Q_EMIT q->themeChanged();
835+}
836+
837 // handle implicit size changes implied by the style components
838 void UCStyledItemBasePrivate::_q_styleResized()
839 {
840@@ -395,8 +475,10 @@
841 theme :
842 (!parentStyledItem ? &UCTheme::defaultTheme() : NULL);
843 if (connectedSet) {
844- QObject::disconnect(connectedSet, &UCTheme::nameChanged,
845- q, &UCStyledItemBase::themeChanged);
846+ QObject::disconnect(connectedSet, SIGNAL(nameChanged()),
847+ q, SLOT(_q_reloadStyle()));
848+ QObject::disconnect(connectedSet, SIGNAL(versionChanged()),
849+ q, SLOT(_q_reloadStyle()));
850 }
851
852 UCTheme *prevSet = theme;
853@@ -419,8 +501,10 @@
854 theme :
855 (!parentStyledItem ? &UCTheme::defaultTheme() : NULL);
856 if (connectedSet) {
857- QObject::connect(connectedSet, &UCTheme::nameChanged,
858- q, &UCStyledItemBase::themeChanged);
859+ QObject::connect(connectedSet, SIGNAL(nameChanged()),
860+ q, SLOT(_q_reloadStyle()));
861+ QObject::connect(connectedSet, SIGNAL(versionChanged()),
862+ q, SLOT(_q_reloadStyle()));
863 }
864 // detach previous set and attach the new one
865 if (prevSet) {
866@@ -437,6 +521,13 @@
867 postThemeChanged();
868
869 Q_EMIT q->themeChanged();
870+
871+ // perform style reload
872+ if (!styleComponent) {
873+ preStyleChanged();
874+ postStyleChanged();
875+ loadStyleItem();
876+ }
877 }
878 void UCStyledItemBasePrivate::resetTheme()
879 {
880@@ -542,10 +633,10 @@
881 {
882 QQuickItem::componentComplete();
883 Q_D(UCStyledItemBase);
884- if (d->styleLoadingMethod == UCStyledItemBasePrivate::DelayTillCompleted) {
885- // the delayed completion disables animations
886- d->loadStyleItem(false);
887- }
888+ // no animation at this time
889+ // prepare style context if not been done yet
890+ d->postStyleChanged();
891+ d->loadStyleItem(false);
892 }
893
894 // grab pressed state and focus if it can be
895
896=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase.h'
897--- modules/Ubuntu/Components/plugin/ucstyleditembase.h 2015-04-13 13:42:03 +0000
898+++ modules/Ubuntu/Components/plugin/ucstyleditembase.h 2015-05-26 15:05:58 +0000
899@@ -29,8 +29,9 @@
900 Q_PROPERTY(bool activeFocusOnPress
901 READ activefocusOnPress WRITE setActiveFocusOnPress
902 NOTIFY activeFocusOnPressChanged REVISION 1)
903- Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQmlComponent *style READ style WRITE setStyle NOTIFY styleChanged FINAL DESIGNABLE false)
904+ Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQmlComponent *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL DESIGNABLE false)
905 Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQuickItem *__styleInstance READ styleInstance NOTIFY styleInstanceChanged FINAL DESIGNABLE false)
906+ Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged FINAL REVISION 2)
907 Q_PRIVATE_PROPERTY(d_func(), UCTheme *theme READ getTheme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL REVISION 2)
908 public:
909 explicit UCStyledItemBase(QQuickItem *parent = 0);
910@@ -46,6 +47,7 @@
911 void styleInstanceChanged();
912 Q_REVISION(1) void activeFocusOnPressChanged();
913 Q_REVISION(2) void themeChanged();
914+ Q_REVISION(2) void styleNameChanged();
915
916 protected:
917 UCStyledItemBase(UCStyledItemBasePrivate &, QQuickItem *parent);
918@@ -60,6 +62,7 @@
919 Q_PRIVATE_SLOT(d_func(), void _q_styleResized())
920 Q_PRIVATE_SLOT(d_func(), void _q_ascendantChanged(QQuickItem*))
921 Q_PRIVATE_SLOT(d_func(), void _q_parentStyleChanged())
922+ Q_PRIVATE_SLOT(d_func(), void _q_reloadStyle())
923 };
924
925 #endif // UCSTYLEDITEMBASE_H
926
927=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase_p.h'
928--- modules/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-04-14 07:46:04 +0000
929+++ modules/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-05-26 15:05:58 +0000
930@@ -29,16 +29,11 @@
931 Q_DECLARE_PUBLIC(UCStyledItemBase)
932 public:
933
934- enum StyleLoadingMethod {
935- Immediate,
936- DelayTillCompleted,
937- DelayTillExplicitRequested
938- };
939-
940 static UCStyledItemBasePrivate *get(UCStyledItemBase *item) {
941 return item->d_func();
942 }
943
944+ void _q_reloadStyle();
945 void _q_styleResized();
946 void _q_ascendantChanged(QQuickItem *ascendant);
947 void _q_parentStyleChanged();
948@@ -52,11 +47,15 @@
949
950 QQmlComponent *style() const;
951 void setStyle(QQmlComponent *style);
952+ void resetStyle();
953 QQuickItem *styleInstance();
954
955+ QString styleName() const;
956+ void setStyleName(const QString &name);
957+
958 virtual void preStyleChanged();
959- virtual void postStyleChanged();
960- virtual void loadStyleItem(bool animated = true);
961+ virtual void postStyleChanged() {}
962+ virtual bool loadStyleItem(bool animated = true);
963
964 UCTheme *getTheme() const;
965 void setTheme(UCTheme *theme);
966@@ -67,7 +66,7 @@
967
968 public:
969 bool activeFocusOnPress:1;
970- StyleLoadingMethod styleLoadingMethod;
971+ QString styleDocument;
972 QQmlComponent *styleComponent;
973 QPointer<QQmlContext> styleItemContext;
974 QQuickItem *styleItem;
975
976=== modified file 'modules/Ubuntu/Components/plugin/uctheme.cpp'
977--- modules/Ubuntu/Components/plugin/uctheme.cpp 2015-05-02 09:20:35 +0000
978+++ modules/Ubuntu/Components/plugin/uctheme.cpp 2015-05-26 15:05:58 +0000
979@@ -121,15 +121,18 @@
980 * }
981 * \endqml
982 *
983- * The \l createStyleComponent function can be used to create the style for a
984- * component. The following example will create the style with the inherited
985- * theme.
986+ * The style can be set on a StyledItem either using \l StyledItem::styleName or
987+ * \l StyledItem::style properties. When set through \l StyledItem::styleName,
988+ * the component will load the style from the current theme set, and must be a
989+ * QML document. The \l StyledItem::style property is a Component which can be
990+ * declared local, or loaded with a Loader or created using Qt.createComponent()
991+ * function.
992+ * The following example will create the style with the inherited theme.
993 * \qml
994 * import QtQuick 2.4
995 * import Ubuntu.Components 1.3
996 * StyledItem {
997- * id: myItem
998- * style: theme.createStyleComponent("MyItemStyle.qml", myItem)
999+ * styleName: "MyItemStyle"
1000 * }
1001 * \endqml
1002 * All styled toolkit components such as \l Button, \l CheckBox, \l Switch, etc.
1003@@ -642,24 +645,20 @@
1004 }
1005 m_version = version;
1006 Q_EMIT versionChanged();
1007- // emit also nameChanged() so we reload the theme/style
1008- Q_EMIT nameChanged();
1009 }
1010
1011-/*!
1012- * \qmlmethod Component ThemeSettings::createStyleComponent(string styleName, object parent)
1013+/*
1014 * Returns an instance of the style component named \a styleName and parented
1015 * to \a parent.
1016 */
1017-QQmlComponent* UCTheme::createStyleComponent(const QString& styleName, QObject* parent)
1018-{
1019- return createStyleComponent(styleName, parent, m_version);
1020-}
1021-
1022 QQmlComponent* UCTheme::createStyleComponent(const QString& styleName, QObject* parent, quint16 version)
1023 {
1024 QQmlComponent *component = NULL;
1025
1026+ if (!version) {
1027+ version = m_version;
1028+ }
1029+
1030 if (parent != NULL) {
1031 QQmlEngine* engine = qmlEngine(parent);
1032 if (engine != m_engine && !m_engine) {
1033@@ -681,6 +680,9 @@
1034 qmlInfo(parent) << component->errorString();
1035 delete component;
1036 component = NULL;
1037+ } else {
1038+ // set context for the component
1039+ QQmlEngine::setContextForObject(component, qmlContext(parent));
1040 }
1041 } else {
1042 qmlInfo(parent) <<
1043
1044=== modified file 'modules/Ubuntu/Components/plugin/uctheme.h'
1045--- modules/Ubuntu/Components/plugin/uctheme.h 2015-05-02 08:49:38 +0000
1046+++ modules/Ubuntu/Components/plugin/uctheme.h 2015-05-26 15:05:58 +0000
1047@@ -76,8 +76,7 @@
1048 void setVersion(quint16 version);
1049
1050 // internal, used by the deprecated Theme.createStyledComponent()
1051- QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version);
1052- Q_INVOKABLE QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent);
1053+ QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version = 0);
1054 static void registerToContext(QQmlContext* context);
1055
1056 // helper functions
1057
1058=== modified file 'tests/resources/navigation/tabs.qml'
1059--- tests/resources/navigation/tabs.qml 2015-04-24 10:45:31 +0000
1060+++ tests/resources/navigation/tabs.qml 2015-05-26 15:05:58 +0000
1061@@ -15,8 +15,8 @@
1062 */
1063
1064 import QtQuick 2.0
1065-import Ubuntu.Components 1.2
1066-import Ubuntu.Components.ListItems 1.0 as ListItem
1067+import Ubuntu.Components 1.3
1068+import Ubuntu.Components.ListItems 1.3 as ListItem
1069
1070 MainView {
1071 width: 800
1072
1073=== modified file 'tests/unit/tst_performance/PaletteConfigurationAllColors.qml'
1074--- tests/unit/tst_performance/PaletteConfigurationAllColors.qml 2015-03-19 11:21:42 +0000
1075+++ tests/unit/tst_performance/PaletteConfigurationAllColors.qml 2015-05-26 15:05:58 +0000
1076@@ -16,7 +16,7 @@
1077
1078 import QtQuick 2.4
1079 import Ubuntu.Components 1.3
1080-import Ubuntu.Components.Themes 1.0
1081+import Ubuntu.Components.Themes 1.3
1082
1083 StyledItem {
1084 width: 100
1085
1086=== modified file 'tests/unit/tst_performance/PaletteConfigurationOneColor.qml'
1087--- tests/unit/tst_performance/PaletteConfigurationOneColor.qml 2015-03-19 11:21:42 +0000
1088+++ tests/unit/tst_performance/PaletteConfigurationOneColor.qml 2015-05-26 15:05:58 +0000
1089@@ -16,7 +16,7 @@
1090
1091 import QtQuick 2.4
1092 import Ubuntu.Components 1.3
1093-import Ubuntu.Components.Themes 1.0
1094+import Ubuntu.Components.Themes 1.3
1095
1096 StyledItem {
1097 width: 100
1098
1099=== modified file 'tests/unit_x11/tst_subtheming/DeprecatedTheme.qml'
1100--- tests/unit_x11/tst_subtheming/DeprecatedTheme.qml 2015-05-01 11:32:48 +0000
1101+++ tests/unit_x11/tst_subtheming/DeprecatedTheme.qml 2015-05-26 15:05:58 +0000
1102@@ -21,5 +21,5 @@
1103 width: units.gu(40)
1104 height: units.gu(40)
1105 theme.name: "Ubuntu.Components.Themes.SuruGradient"
1106- style: theme.createStyleComponent("OptionSelectorStyle.qml", item)
1107+ styleName: "OptionSelectorStyle"
1108 }
1109
1110=== modified file 'tests/unit_x11/tst_subtheming/SimpleItem.qml'
1111--- tests/unit_x11/tst_subtheming/SimpleItem.qml 2015-03-12 20:11:38 +0000
1112+++ tests/unit_x11/tst_subtheming/SimpleItem.qml 2015-05-26 15:05:58 +0000
1113@@ -17,13 +17,9 @@
1114 import QtQuick 2.4
1115 import Ubuntu.Components 1.3
1116
1117-Item {
1118+StyledItem {
1119 id: item
1120- property ThemeSettings theme: ThemeSettings {}
1121- property Component style
1122-
1123- property string styleDocument
1124- onStyleDocumentChanged: style = theme.createStyleComponent(styleDocument, item)
1125+ theme: ThemeSettings {}
1126
1127 property string themeName
1128 onThemeNameChanged: theme.name = themeName;
1129
1130=== added file 'tests/unit_x11/tst_subtheming/StyleKept.qml'
1131--- tests/unit_x11/tst_subtheming/StyleKept.qml 1970-01-01 00:00:00 +0000
1132+++ tests/unit_x11/tst_subtheming/StyleKept.qml 2015-05-26 15:05:58 +0000
1133@@ -0,0 +1,43 @@
1134+/*
1135+ * Copyright 2015 Canonical Ltd.
1136+ *
1137+ * This program is free software; you can redistribute it and/or modify
1138+ * it under the terms of the GNU Lesser General Public License as published by
1139+ * the Free Software Foundation; version 3.
1140+ *
1141+ * This program is distributed in the hope that it will be useful,
1142+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1143+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1144+ * GNU Lesser General Public License for more details.
1145+ *
1146+ * You should have received a copy of the GNU Lesser General Public License
1147+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1148+ */
1149+import QtQuick 2.4
1150+import Ubuntu.Components 1.3
1151+
1152+Item {
1153+ width: units.gu(40)
1154+ height: units.gu(40)
1155+
1156+ Button {
1157+ objectName: "TestButton"
1158+ text: "PressMe..."
1159+ style: Rectangle {
1160+ objectName: "TestStyle"
1161+ // FIXME: move these properties to the Style API
1162+ property color defaultColor: "blue"
1163+ property Gradient defaultGradient
1164+ property font defaultFont
1165+
1166+ anchors.fill: styledItem
1167+ color: defaultColor
1168+ Label {
1169+ anchors.fill: parent
1170+ horizontalAlignment: Text.AlignHCenter
1171+ verticalAlignment: Text.AlignVCenter
1172+ text: styledItem.text
1173+ }
1174+ }
1175+ }
1176+}
1177
1178=== added file 'tests/unit_x11/tst_subtheming/StyleOverride.qml'
1179--- tests/unit_x11/tst_subtheming/StyleOverride.qml 1970-01-01 00:00:00 +0000
1180+++ tests/unit_x11/tst_subtheming/StyleOverride.qml 2015-05-26 15:05:58 +0000
1181@@ -0,0 +1,46 @@
1182+/*
1183+ * Copyright 2015 Canonical Ltd.
1184+ *
1185+ * This program is free software; you can redistribute it and/or modify
1186+ * it under the terms of the GNU Lesser General Public License as published by
1187+ * the Free Software Foundation; version 3.
1188+ *
1189+ * This program is distributed in the hope that it will be useful,
1190+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1191+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1192+ * GNU Lesser General Public License for more details.
1193+ *
1194+ * You should have received a copy of the GNU Lesser General Public License
1195+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1196+ */
1197+import QtQuick 2.4
1198+import Ubuntu.Components 1.3
1199+
1200+Item {
1201+ width: units.gu(40)
1202+ height: units.gu(40)
1203+
1204+ Button {
1205+ objectName: "TestButton"
1206+ text: "PressMe..."
1207+ }
1208+
1209+ property Component customStyle: Component {
1210+ Rectangle {
1211+ objectName: "TestStyle"
1212+ // FIXME: move these properties to the Style API
1213+ property color defaultColor: "blue"
1214+ property Gradient defaultGradient
1215+ property font defaultFont
1216+
1217+ anchors.fill: styledItem
1218+ color: defaultColor
1219+ Label {
1220+ anchors.fill: parent
1221+ horizontalAlignment: Text.AlignHCenter
1222+ verticalAlignment: Text.AlignVCenter
1223+ text: styledItem.text
1224+ }
1225+ }
1226+ }
1227+}
1228
1229=== modified file 'tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml'
1230--- tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml 2015-04-27 16:25:09 +0000
1231+++ tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml 2015-05-26 15:05:58 +0000
1232@@ -20,5 +20,5 @@
1233 id: item
1234 theme.name: "themes.CustomTheme"
1235 theme.version: Ubuntu.version(1, 0)
1236- style: theme.createStyleComponent("TestStyle.qml", item)
1237+ styleName: "TestStyle"
1238 }
1239
1240=== modified file 'tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml'
1241--- tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml 2015-05-02 09:20:35 +0000
1242+++ tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml 2015-05-26 15:05:58 +0000
1243@@ -20,5 +20,5 @@
1244 id: item
1245 theme.name: "themes.CustomTheme"
1246 theme.version: Ubuntu.toolkitVersion
1247- style: theme.createStyleComponent("TestStyle.qml", item)
1248+ styleName: "TestStyle"
1249 }
1250
1251=== modified file 'tests/unit_x11/tst_subtheming/StyledItemFallback.qml'
1252--- tests/unit_x11/tst_subtheming/StyledItemFallback.qml 2015-04-27 14:46:31 +0000
1253+++ tests/unit_x11/tst_subtheming/StyledItemFallback.qml 2015-05-26 15:05:58 +0000
1254@@ -20,5 +20,5 @@
1255 id: item
1256 theme.name: "TestModule.TestTheme"
1257 theme.version: Ubuntu.version(1, 0)
1258- style: theme.createStyleComponent("TestStyle.qml", item)
1259+ styleName: "TestStyle"
1260 }
1261
1262=== modified file 'tests/unit_x11/tst_subtheming/StyledItemV12.qml'
1263--- tests/unit_x11/tst_subtheming/StyledItemV12.qml 2015-04-27 12:46:28 +0000
1264+++ tests/unit_x11/tst_subtheming/StyledItemV12.qml 2015-05-26 15:05:58 +0000
1265@@ -20,5 +20,5 @@
1266 id: item
1267 theme.name: "themes.CustomTheme"
1268 theme.version: Ubuntu.version(1, 2)
1269- style: theme.createStyleComponent("TestStyle.qml", item)
1270+ styleName: "TestStyle"
1271 }
1272
1273=== modified file 'tests/unit_x11/tst_subtheming/StyledItemV13.qml'
1274--- tests/unit_x11/tst_subtheming/StyledItemV13.qml 2015-04-27 12:46:28 +0000
1275+++ tests/unit_x11/tst_subtheming/StyledItemV13.qml 2015-05-26 15:05:58 +0000
1276@@ -20,5 +20,5 @@
1277 id: item
1278 theme.name: "themes.CustomTheme"
1279 theme.version: Ubuntu.toolkitVersion
1280- style: theme.createStyleComponent("TestStyle.qml", item)
1281+ styleName: "TestStyle"
1282 }
1283
1284=== modified file 'tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml'
1285--- tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml 2015-04-27 12:46:28 +0000
1286+++ tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml 2015-05-26 15:05:58 +0000
1287@@ -17,4 +17,5 @@
1288 import QtQuick 2.0
1289
1290 Item {
1291+ objectName: "TestStyle"
1292 }
1293
1294=== modified file 'tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml'
1295--- tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml 2015-04-25 06:35:16 +0000
1296+++ tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml 2015-05-26 15:05:58 +0000
1297@@ -17,5 +17,6 @@
1298 import QtQuick 2.0
1299
1300 Item {
1301+ objectName: "TestStyle"
1302 property string newProperty: "version1.3"
1303 }
1304
1305=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp'
1306--- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-05-02 09:20:35 +0000
1307+++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-05-26 15:05:58 +0000
1308@@ -21,6 +21,7 @@
1309 #include <QtQml/QQmlContext>
1310 #include <QtQml/QQmlComponent>
1311 #include "uctheme.h"
1312+#include "quickutils.h"
1313 #include "uctestcase.h"
1314 #include "ucstyleditembase_p.h"
1315 #include "ucnamespace.h"
1316@@ -62,12 +63,6 @@
1317 QTest::waitForEvents();
1318 }
1319
1320- void setStyle(const QString &style)
1321- {
1322- rootObject()->setProperty("styleDocument", style);
1323- QTest::waitForEvents();
1324- }
1325-
1326 UCTheme *theme()
1327 {
1328 return rootObject()->property("theme").value<UCTheme*>();
1329@@ -134,25 +129,27 @@
1330 QTest::addColumn<QString>("styleName");
1331 QTest::addColumn<QString>("parentName");
1332 QTest::addColumn<bool>("success");
1333- QTest::newRow("Existing style") << "TestStyle.qml" << "SimpleItem.qml" << true;
1334- QTest::newRow("Non existing style") << "NotExistingTestStyle.qml" << "SimpleItem.qml" << false;
1335+ QTest::addColumn<QString>("warning");
1336+ QTest::newRow("Existing style") << "TestStyle" << "SimpleItem.qml" << true << QString();
1337+ QTest::newRow("Non existing style") << "NotExistingTestStyle" << "SimpleItem.qml" << false << "QML SimpleItem: Warning: Style NotExistingTestStyle.qml not found in theme TestModule.TestTheme";
1338 }
1339 void test_create_style_component()
1340 {
1341 QFETCH(QString, styleName);
1342 QFETCH(QString, parentName);
1343 QFETCH(bool, success);
1344+ QFETCH(QString, warning);
1345
1346- if (styleName == "NotExistingTestStyle.qml") {
1347- ThemeTestCase::ignoreWarning(parentName, 20, 1, "QML SimpleItem: Warning: Style NotExistingTestStyle.qml not found in theme TestModule.TestTheme");
1348+ if (!warning.isEmpty()) {
1349+ ThemeTestCase::ignoreWarning(parentName, 20, 1, warning);
1350 }
1351 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "./themes");
1352
1353 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(parentName));
1354 view->setTheme("TestModule.TestTheme");
1355- view->setStyle(styleName);
1356- QQmlComponent *style = view->rootObject()->property("style").value<QQmlComponent*>();
1357- QCOMPARE(style != NULL, success);
1358+ view->rootObject()->setProperty("styleName", styleName);
1359+ QQuickItem *testStyle = view->rootObject()->findChild<QQuickItem*>("TestStyle");
1360+ QCOMPARE(testStyle != NULL, success);
1361 }
1362
1363 void test_relative_theme_paths_environment_variables_data()
1364@@ -166,23 +163,23 @@
1365
1366 QTest::newRow("One toolkit theme path")
1367 << "./themes" << ""
1368- << "TestModule.TestTheme" << "TestStyle.qml"
1369+ << "TestModule.TestTheme" << "TestStyle"
1370 << "" << true;
1371 QTest::newRow("Two toolkit theme paths")
1372 << "./themes:./themes/TestModule" << ""
1373- << "CustomTheme" << "TestStyle.qml"
1374+ << "CustomTheme" << "TestStyle"
1375 << "" << true;
1376 QTest::newRow("One XDG path")
1377 << "" << "./themes"
1378- << "TestModule.TestTheme" << "TestStyle.qml"
1379+ << "TestModule.TestTheme" << "TestStyle"
1380 << "" << true;
1381 QTest::newRow("Two XDG paths")
1382 << "" << "./themes:./themes/TestModule"
1383- << "CustomTheme" << "TestStyle.qml"
1384+ << "CustomTheme" << "TestStyle"
1385 << "" << true;
1386 QTest::newRow("No variables")
1387 << "" << ""
1388- << QString() << "TestStyle.qml"
1389+ << QString() << "TestStyle"
1390 << "QML SimpleItem: Warning: Style TestStyle.qml not found in theme Ubuntu.Components.Themes.Ambiance" << false;
1391 }
1392
1393@@ -206,9 +203,9 @@
1394 if (!theme.isEmpty()) {
1395 view->setTheme(theme);
1396 }
1397- view->setStyle(style);
1398- QQmlComponent *styleComponent = view->rootObject()->property("style").value<QQmlComponent*>();
1399- QCOMPARE(styleComponent != NULL, success);
1400+ view->rootObject()->setProperty("styleName", style);
1401+ QQuickItem *styleItem = view->rootObject()->findChild<QQuickItem*>("TestStyle");
1402+ QCOMPARE(styleItem != NULL, success);
1403 }
1404
1405 void test_import_path()
1406@@ -662,7 +659,7 @@
1407 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
1408 qputenv("XDG_DATA_DIRS", "./themes:./themes/TestModule");
1409 if (!warning.isEmpty()) {
1410- ThemeTestCase::ignoreWarning(document, row, column, warning, 2);
1411+ ThemeTestCase::ignoreWarning(document, row, column, warning);
1412 }
1413 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(document));
1414 UCStyledItemBase *styledItem = qobject_cast<UCStyledItemBase*>(view->rootObject());
1415@@ -683,6 +680,67 @@
1416 // which will cause a warning; therefore we mark the warning to be ignored
1417 ThemeTestCase::ignoreWarning("DeprecatedTheme.qml", 19, 1, "QML StyledItem: Theme 'Ubuntu.Components.Themes.Ambiance' has no 'OptionSelectorStyle.qml' style for version 1.0, fall back to version 1.3.");
1418 }
1419+
1420+ void test_style_change_has_precedence()
1421+ {
1422+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleOverride.qml"));
1423+ QQmlComponent *style = view->rootObject()->property("customStyle").value<QQmlComponent*>();
1424+ QQuickItem *button = view->findItem<QQuickItem*>("TestButton");
1425+
1426+ button->setProperty("style", QVariant::fromValue(style));
1427+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1428+ }
1429+
1430+ void test_style_kept_when_stylename_changes_data()
1431+ {
1432+ QTest::addColumn<QString>("styleName");
1433+
1434+ QTest::newRow("Empty style name") << QString();
1435+ QTest::newRow("Any style name") << "Bumblebee";
1436+ }
1437+ void test_style_kept_when_stylename_changes()
1438+ {
1439+ QFETCH(QString, styleName);
1440+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml"));
1441+ QQuickItem *button = view->findItem<QQuickItem*>("TestButton");
1442+
1443+ button->setProperty("styleName", styleName);
1444+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1445+ }
1446+
1447+ void test_style_kept_when_theme_changes()
1448+ {
1449+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml"));
1450+ QQuickItem *button = view->findItem<QQuickItem*>("TestButton");
1451+ UCTheme *theme = button->property("theme").value<UCTheme*>();
1452+ QVERIFY(theme);
1453+
1454+ theme->setName("Ubuntu.Components.Themes.SuruDark");
1455+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1456+ }
1457+
1458+ void test_style_reset_to_theme_style()
1459+ {
1460+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml"));
1461+ UCStyledItemBase *button = view->findItem<UCStyledItemBase*>("TestButton");
1462+ UCTheme *theme = UCStyledItemBasePrivate::get(button)->getTheme();
1463+ QVERIFY(theme);
1464+
1465+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1466+ // reset style property, which should reset style to the theme style
1467+ UCStyledItemBasePrivate::get(button)->resetStyle();
1468+ QQuickItem *styleItem = UCStyledItemBasePrivate::get(button)->styleInstance();
1469+ QCOMPARE(QuickUtils::className(styleItem), QString("ButtonStyle"));
1470+ }
1471+
1472+ void test_stylename_extension_failure()
1473+ {
1474+ ThemeTestCase::ignoreWarning("DeprecatedTheme.qml", 19, 1, "QML StyledItem: Warning: Style OptionSelectorStyle.qml.qml not found in theme Ubuntu.Components.Themes.SuruGradient");
1475+ // add also for Ambiance, as ThemeTestCase destructor resets the theme, which will cause style warning for the default theme
1476+ ThemeTestCase::ignoreWarning("DeprecatedTheme.qml", 19, 1, "QML StyledItem: Warning: Style OptionSelectorStyle.qml.qml not found in theme Ubuntu.Components.Themes.Ambiance");
1477+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("DeprecatedTheme.qml"));
1478+ view->rootObject()->setProperty("styleName", "OptionSelectorStyle.qml");
1479+ }
1480 };
1481
1482 QTEST_MAIN(tst_Subtheming)
1483
1484=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.pro'
1485--- tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-05-02 09:20:35 +0000
1486+++ tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-05-26 15:05:58 +0000
1487@@ -31,6 +31,8 @@
1488 StyledItemFallback.qml \
1489 StyledItemAppThemeFallback.qml \
1490 DeprecatedTheme.qml \
1491- StyledItemAppThemeVersioned.qml
1492+ StyledItemAppThemeVersioned.qml \
1493+ StyleOverride.qml \
1494+ StyleKept.qml
1495
1496

Subscribers

People subscribed via source and target branches