Merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1305190-ubuntu-app-launch into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1305190-ubuntu-app-launch
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 1815 lines (+536/-212)
67 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.2/Caption.qml (+9/-3)
modules/Ubuntu/Components/ListItems/1.3/Caption.qml (+9/-3)
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/ActionBarStyle.qml (+6/-4)
modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml (+80/-0)
modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml (+1/-0)
modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml (+1/-1)
modules/Ubuntu/Components/plugin/plugin.cpp (+1/-0)
modules/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp (+9/-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/autopilot/ubuntuuitoolkit/tests/__init__.py (+4/-29)
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_components/tst_actionbar.qml (+1/-1)
tests/unit_x11/tst_components/tst_header_presets.qml (+8/-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:~canonical-platform-qa/ubuntu-ui-toolkit/fix1305190-ubuntu-app-launch
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+260698@code.launchpad.net

This proposal has been superseded by a proposal from 2015-06-01.

Commit message

Use UbuntuUIToolkitWithFakeAppRunningTestCase as the base class for all the toolkit autopilot tests.

Description of the change

NOT READY TO REVIEW, just checking a weird issue here.

To post a comment you must log in.
1524. By Leo Arias

Moved the pointing device to the base class.

1525. By Leo Arias

Moved the launch qml file to the gallery tests.

1526. By Leo Arias

Use always the toolkit test launcher.

1527. By Leo Arias

Simplified the gallery tests by launching the installed ones with upstart.

1528. By Leo Arias

Removed the unused methods.

1529. By Leo Arias

Merged with prerequisite.

1530. By Leo Arias

Fixed the test source path.

Unmerged revisions

1530. By Leo Arias

Fixed the test source path.

1529. By Leo Arias

Merged with prerequisite.

1528. By Leo Arias

Removed the unused methods.

1527. By Leo Arias

Simplified the gallery tests by launching the installed ones with upstart.

1526. By Leo Arias

Use always the toolkit test launcher.

1525. By Leo Arias

Moved the launch qml file to the gallery tests.

1524. By Leo Arias

Moved the pointing device to the base class.

1523. By Leo Arias

Use UbuntuUIToolkitWithFakeAppRunningTestCase as the base class for all the toolkit autopilot tests.

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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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-06-01 10:41:20 +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.2/Caption.qml'
336--- modules/Ubuntu/Components/ListItems/1.2/Caption.qml 2015-04-30 08:32:44 +0000
337+++ modules/Ubuntu/Components/ListItems/1.2/Caption.qml 2015-06-01 10:41:20 +0000
338@@ -38,7 +38,7 @@
339 \endqml
340 */
341 Item {
342- height: captionText.height + units.gu(1)
343+ height: captionText.contentHeight + units.gu(2) * 2
344 width: parent ? parent.width : units.gu(31)
345
346 /*!
347@@ -49,8 +49,14 @@
348
349 Label {
350 id: captionText
351- anchors.centerIn: parent
352- width: parent.width - units.gu(1)
353+ anchors {
354+ verticalCenter: parent.verticalCenter
355+ left: parent.left
356+ right: parent.right
357+ //Margins are currently hardcoded to avoid adding new API
358+ leftMargin: units.gu(2)
359+ rightMargin: units.gu(2)
360+ }
361 wrapMode: Text.Wrap
362 color: Theme.palette.normal.backgroundText
363 horizontalAlignment: Text.AlignLeft
364
365=== modified file 'modules/Ubuntu/Components/ListItems/1.3/Caption.qml'
366--- modules/Ubuntu/Components/ListItems/1.3/Caption.qml 2015-04-29 07:21:29 +0000
367+++ modules/Ubuntu/Components/ListItems/1.3/Caption.qml 2015-06-01 10:41:20 +0000
368@@ -38,7 +38,7 @@
369 \endqml
370 */
371 Item {
372- height: captionText.height + units.gu(1)
373+ height: captionText.contentHeight + units.gu(2) * 2
374 width: parent ? parent.width : units.gu(31)
375
376 /*!
377@@ -49,8 +49,14 @@
378
379 Label {
380 id: captionText
381- anchors.centerIn: parent
382- width: parent.width - units.gu(1)
383+ anchors {
384+ verticalCenter: parent.verticalCenter
385+ left: parent.left
386+ right: parent.right
387+ //Margins are currently hardcoded to avoid adding new API
388+ leftMargin: units.gu(2)
389+ rightMargin: units.gu(2)
390+ }
391 wrapMode: Text.Wrap
392 color: theme.palette.normal.backgroundText
393 horizontalAlignment: Text.AlignLeft
394
395=== modified file 'modules/Ubuntu/Components/ListItems/1.3/ItemSelector.qml'
396--- modules/Ubuntu/Components/ListItems/1.3/ItemSelector.qml 2015-04-29 07:21:29 +0000
397+++ modules/Ubuntu/Components/ListItems/1.3/ItemSelector.qml 2015-06-01 10:41:20 +0000
398@@ -217,7 +217,7 @@
399 }
400 state: itemSelector.expanded ? "expanded" : "collapsed"
401 theme.version: Ubuntu.toolkitVersion
402- style: theme.createStyleComponent("ListItemOptionSelectorStyle.qml", listContainer)
403+ styleName: "ListItemOptionSelectorStyle"
404
405 states: [ State {
406 name: "expanded"
407
408=== modified file 'modules/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml'
409--- modules/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml 2015-04-29 07:21:29 +0000
410+++ modules/Ubuntu/Components/ListItems/1.3/ProgressionVisual.qml 2015-06-01 10:41:20 +0000
411@@ -26,5 +26,5 @@
412 property real splitMargin
413
414 theme.version: Ubuntu.toolkitVersion
415- style: theme.createStyleComponent("ProgressionVisualStyle.qml", progressionVisual)
416+ styleName: "ProgressionVisualStyle"
417 }
418
419=== modified file 'modules/Ubuntu/Components/Pickers/1.3/DatePicker.qml'
420--- modules/Ubuntu/Components/Pickers/1.3/DatePicker.qml 2015-04-29 07:44:05 +0000
421+++ modules/Ubuntu/Components/Pickers/1.3/DatePicker.qml 2015-06-01 10:41:20 +0000
422@@ -421,7 +421,7 @@
423 }
424
425 theme.version: Ubuntu.toolkitVersion
426- style: theme.createStyleComponent("DatePickerStyle.qml", datePicker)
427+ styleName: "DatePickerStyle"
428 Binding {
429 target: __styleInstance
430 property: "view"
431
432=== modified file 'modules/Ubuntu/Components/Pickers/1.3/Dialer.qml'
433--- modules/Ubuntu/Components/Pickers/1.3/Dialer.qml 2015-04-29 07:44:05 +0000
434+++ modules/Ubuntu/Components/Pickers/1.3/Dialer.qml 2015-06-01 10:41:20 +0000
435@@ -146,7 +146,7 @@
436 activeFocusOnPress: true
437
438 theme.version: Ubuntu.toolkitVersion
439- style: theme.createStyleComponent("DialerStyle.qml", dialer)
440+ styleName: "DialerStyle"
441
442 Item {
443 id: internal
444
445=== modified file 'modules/Ubuntu/Components/Pickers/1.3/DialerHand.qml'
446--- modules/Ubuntu/Components/Pickers/1.3/DialerHand.qml 2015-04-29 07:44:05 +0000
447+++ modules/Ubuntu/Components/Pickers/1.3/DialerHand.qml 2015-06-01 10:41:20 +0000
448@@ -144,7 +144,7 @@
449 height: parent.height
450 activeFocusOnPress: true
451 theme.version: Ubuntu.toolkitVersion
452- style: theme.createStyleComponent("DialerHandStyle.qml", dialerHand)
453+ styleName: "DialerHandStyle"
454
455 /*! \internal */
456 onParentChanged: {
457
458=== modified file 'modules/Ubuntu/Components/Pickers/1.3/Picker.qml'
459--- modules/Ubuntu/Components/Pickers/1.3/Picker.qml 2015-04-29 07:44:05 +0000
460+++ modules/Ubuntu/Components/Pickers/1.3/Picker.qml 2015-06-01 10:41:20 +0000
461@@ -160,7 +160,7 @@
462 activeFocusOnPress: true
463
464 theme.version: Ubuntu.toolkitVersion
465- style: theme.createStyleComponent("PickerStyle.qml", picker)
466+ styleName: "PickerStyle"
467
468 /*! \internal */
469 property int __clickedIndex: -1
470
471=== modified file 'modules/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml'
472--- modules/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml 2015-04-29 07:44:05 +0000
473+++ modules/Ubuntu/Components/Pickers/1.3/PickerDelegate.qml 2015-06-01 10:41:20 +0000
474@@ -48,7 +48,7 @@
475 }
476
477 theme.version: Ubuntu.toolkitVersion
478- style: theme.createStyleComponent("PickerDelegateStyle.qml", pickerDelegate)
479+ styleName: "PickerDelegateStyle"
480
481 QtObject {
482 id: internal
483
484=== modified file 'modules/Ubuntu/Components/Popups/1.3/Dialog.qml'
485--- modules/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-04-29 08:55:31 +0000
486+++ modules/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-06-01 10:41:20 +0000
487@@ -214,6 +214,6 @@
488 }
489
490 theme.version: Ubuntu.toolkitVersion
491- style: theme.createStyleComponent("DialogForegroundStyle.qml", foreground)
492+ styleName: "DialogForegroundStyle"
493 }
494 }
495
496=== modified file 'modules/Ubuntu/Components/Popups/1.3/Popover.qml'
497--- modules/Ubuntu/Components/Popups/1.3/Popover.qml 2015-04-29 08:55:31 +0000
498+++ modules/Ubuntu/Components/Popups/1.3/Popover.qml 2015-06-01 10:41:20 +0000
499@@ -238,7 +238,7 @@
500 signal hideCompleted()
501
502 theme.version: Ubuntu.toolkitVersion
503- style: theme.createStyleComponent("PopoverForegroundStyle.qml", foreground)
504+ styleName: "PopoverForegroundStyle"
505 }
506
507 QtObject {
508
509=== modified file 'modules/Ubuntu/Components/Popups/1.3/SheetBase.qml'
510--- modules/Ubuntu/Components/Popups/1.3/SheetBase.qml 2015-04-29 08:55:31 +0000
511+++ modules/Ubuntu/Components/Popups/1.3/SheetBase.qml 2015-06-01 10:41:20 +0000
512@@ -110,6 +110,6 @@
513 }
514
515 theme.version: Ubuntu.toolkitVersion
516- style: theme.createStyleComponent("SheetForegroundStyle.qml", sheet)
517+ styleName: "SheetForegroundStyle"
518 }
519 }
520
521=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml'
522--- modules/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-05-14 21:36:26 +0000
523+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-06-01 10:41:20 +0000
524@@ -58,19 +58,21 @@
525 Repeater {
526 objectName: "actions_repeater"
527 model: numberOfSlots.used
528- PageHeadButton {
529+ AbstractButton {
530+ style: IconButtonStyle { }
531 id: actionButton
532 objectName: action.objectName + "_action_button"
533+ height: actionsContainer.height
534 action: actionsContainer.visibleActions[index]
535- iconWidth: units.gu(2)
536 }
537 }
538
539- PageHeadButton {
540+ AbstractButton {
541+ style: IconButtonStyle { }
542 id: actionsOverflowButton
543 objectName: "actions_overflow_button"
544+ height: actionsContainer.height
545 visible: numberOfSlots.requested > numberOfSlots.available
546- iconWidth: units.gu(2)
547
548 // Ensure resetting of X when this button is not visible to avoid
549 // miscalculation of actionsContainer.width. Fixes bug #1408481.
550
551=== added file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml'
552--- modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 1970-01-01 00:00:00 +0000
553+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 2015-06-01 10:41:20 +0000
554@@ -0,0 +1,80 @@
555+/*
556+ * Copyright 2015 Canonical Ltd.
557+ *
558+ * This program is free software; you can redistribute it and/or modify
559+ * it under the terms of the GNU Lesser General Public License as published by
560+ * the Free Software Foundation; version 3.
561+ *
562+ * This program is distributed in the hope that it will be useful,
563+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
564+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
565+ * GNU Lesser General Public License for more details.
566+ *
567+ * You should have received a copy of the GNU Lesser General Public License
568+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
569+ */
570+
571+import QtQuick 2.4
572+import Ubuntu.Components 1.3
573+
574+Item {
575+ id: iconButtonStyle
576+
577+ implicitWidth: units.gu(5)
578+ implicitHeight: units.gu(5)
579+
580+ /*!
581+ The color of the icons.
582+ */
583+ property color foregroundColor: "#808080"
584+
585+ /*!
586+ The background color of the button.
587+ */
588+ property color backgroundColor: styledItem.pressed ?
589+ theme.palette.selected.background :
590+ "transparent"
591+
592+ property real iconWidth: units.gu(2)
593+ property real iconHeight: iconWidth
594+
595+ /*!
596+ Show a text label under the icon.
597+ */
598+ property bool showLabel: false
599+
600+ Rectangle {
601+ id: background
602+ color: iconButtonStyle.backgroundColor
603+ anchors.fill: parent
604+ }
605+
606+ Icon {
607+ id: icon
608+ anchors.centerIn: parent
609+ width: iconButtonStyle.iconWidth
610+ height: iconButtonStyle.iconHeight
611+ source: styledItem.iconSource
612+ color: iconButtonStyle.foregroundColor
613+ opacity: styledItem.enabled ? 1.0 : 0.3
614+ }
615+
616+ Component {
617+ id: labelComponent
618+ Label {
619+ objectName: styledItem.objectName + "_label"
620+ color: iconButtonStyle.foregroundColor
621+ opacity: styledItem.enabled ? 1.0 : 0.3
622+ text: styledItem.text
623+ fontSize: "xx-small"
624+ }
625+ }
626+ Loader {
627+ anchors {
628+ top: icon.bottom
629+ topMargin: units.gu(0.5)
630+ horizontalCenter: parent.horizontalCenter
631+ }
632+ sourceComponent: iconButtonStyle.showLabel ? labelComponent : null
633+ }
634+}
635
636=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml'
637--- modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml 2015-05-12 15:05:28 +0000
638+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml 2015-06-01 10:41:20 +0000
639@@ -17,6 +17,7 @@
640 import QtQuick 2.4
641 import Ubuntu.Components 1.3
642
643+// TODO: Remove this component when PageHeadStyle uses ActionBar
644 AbstractButton {
645 id: button
646
647
648=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml'
649--- modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml 2015-05-11 14:43:39 +0000
650+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml 2015-06-01 10:41:20 +0000
651@@ -106,7 +106,7 @@
652 // backgroundColor is used in the new HeadDividerStyle
653 property color backgroundColor: styledItem.dividerColor
654
655- style: theme.createStyleComponent("HeadDividerStyle.qml", divider)
656+ styleName: "HeadDividerStyle"
657
658 property PageHeadSections sections: styledItem.config.sections
659
660
661=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
662--- modules/Ubuntu/Components/plugin/plugin.cpp 2015-04-27 07:06:30 +0000
663+++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-06-01 10:41:20 +0000
664@@ -210,6 +210,7 @@
665 qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings");
666 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
667 qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13);
668+ qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
669 }
670
671 void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
672
673=== modified file 'modules/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp'
674--- modules/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-05-18 05:42:05 +0000
675+++ modules/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-06-01 10:41:20 +0000
676@@ -23,6 +23,7 @@
677 #include <QtQml/QQmlComponent>
678 #include <QtQml/QQmlContext>
679 #include <QtQml/QQmlInfo>
680+#include <QtQml/QQmlEngine>
681
682 /*!
683 \qmltype Theme
684@@ -74,6 +75,14 @@
685
686 void UCDeprecatedTheme::showDeprecatedNote(QObject *onItem, const char *note)
687 {
688+ QQmlContext ctx(QQmlEngine::contextForObject(onItem));
689+ // No warnings due to deprecated code used in the components themselves
690+ if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
691+ return;
692+ // Warnings without a filename are not helpful
693+ if (ctx.baseUrl().isEmpty())
694+ return;
695+
696 QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));
697 if (m_notes.contains(noteId))
698 return;
699
700=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
701--- modules/Ubuntu/Components/plugin/uclistitem.cpp 2015-04-14 08:31:20 +0000
702+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2015-06-01 10:41:20 +0000
703@@ -185,7 +185,6 @@
704 , suppressClick(false)
705 , ready(false)
706 , customColor(false)
707- , customStyle(false)
708 , xAxisMoveThresholdGU(DEFAULT_SWIPE_THRESHOLD_GU)
709 , color(Qt::transparent)
710 , highlightColor(Qt::transparent)
711@@ -196,7 +195,6 @@
712 , trailingActions(0)
713 , mainAction(0)
714 {
715- styleLoadingMethod = DelayTillExplicitRequested;
716 }
717 UCListItemPrivate::~UCListItemPrivate()
718 {
719@@ -229,6 +227,7 @@
720 // watch grid unit size change and set implicit size
721 QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), q, SLOT(_q_updateSize()));
722 _q_updateSize();
723+ setStyleName("ListItemStyle");
724 }
725
726 void UCListItemPrivate::_q_themeChanged()
727@@ -260,12 +259,6 @@
728 Q_Q(UCListItem);
729 // update divider colors
730 divider->paletteChanged();
731- // if not using custom style, reload style component from theme
732- if (!customStyle && componentComplete) {
733- // use style setter but reset custom style flag
734- setStyle(getTheme()->createStyleComponent("ListItemStyle.qml", q));
735- customStyle = false;
736- }
737
738 // update colors, panels
739 if (!customColor) {
740@@ -315,44 +308,35 @@
741 Q_EMIT q->dragModeChanged();
742 }
743
744-/*!
745- * \qmlproperty Component ListItem::style
746- * Holds the style of the component defining the components visualizing the leading/
747- * trailing actions, selection and dragging mode handlers as well as different
748- * animations. The component does not assume any visuals present in the style,
749- * and will load its content only when requested.
750- * \sa ListItemStyle
751- */
752 void UCListItemPrivate::preStyleChanged()
753 {
754 snapOut();
755 UCStyledItemBasePrivate::preStyleChanged();
756- // delete style if it was non-custom style
757- if (!customStyle && styleComponent) {
758- styleComponent->deleteLater();
759- styleComponent = 0;
760- }
761- customStyle = true;
762 }
763
764 // creates the style item, with altered default value of the animatePanels style property
765 // the property is turned on after the panel initialization.
766-void UCListItemPrivate::loadStyleItem(bool animated)
767+bool UCListItemPrivate::loadStyleItem(bool animated)
768 {
769- if (!styleComponent) {
770- // try to create the style if possible
771- postThemeChanged();
772- }
773- UCStyledItemBasePrivate::loadStyleItem(animated);
774+ // the style should be loaded only if one of the condition is satisfied
775+ if (!swiped && !selectMode() && !dragMode()) {
776+ return false;
777+ }
778+
779+ if (!UCStyledItemBasePrivate::loadStyleItem(animated)) {
780+ return false;
781+ }
782+
783 UCListItemStyle *myStyle = qobject_cast<UCListItemStyle*>(styleItem);
784 if (!myStyle) {
785 // the style is not derived from ListItemStyle, clean
786 preStyleChanged();
787- return;
788+ return false;
789 }
790 // bring the panels foreground
791 styleItem->setZ(0);
792 listItemStyle()->setAnimatePanels(true);
793+ return true;
794 }
795
796 // called when units size changes
797@@ -885,6 +869,13 @@
798 * \endqml
799 *
800 * \sa ViewItems::dragMode, ViewItems::dragUpdated
801+ *
802+ * \section2 Note on styling
803+ * ListItem's styling differs from the other component sstyling, as ListItem loads
804+ * the style only when either of the leadin/trailing panels are swiped, or when the
805+ * item enters in select- or drag mode. The component does not assume any visuals
806+ * to be present in the style.
807+ * \sa ListItemStyle
808 */
809
810 /*!
811@@ -1134,6 +1125,7 @@
812 d->parentAttached->disableInteractive(this, true);
813 }
814 d->setSwiped(true);
815+ d->loadStyleItem();
816 }
817 }
818
819
820=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
821--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2015-04-14 08:31:20 +0000
822+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2015-06-01 10:41:20 +0000
823@@ -74,7 +74,6 @@
824 bool suppressClick:1;
825 bool ready:1;
826 bool customColor:1;
827- bool customStyle:1;
828 qreal xAxisMoveThresholdGU;
829 QBasicTimer pressAndHoldTimer;
830 QPointF lastPos;
831@@ -98,7 +97,7 @@
832 bool contentMoving() const;
833 void setContentMoving(bool moved);
834 virtual void preStyleChanged();
835- virtual void loadStyleItem(bool animated = true);
836+ virtual bool loadStyleItem(bool animated = true);
837 bool dragging();
838 bool dragMode();
839 void setDragMode(bool draggable);
840
841=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase.cpp'
842--- modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-04-21 13:21:17 +0000
843+++ modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-06-01 10:41:20 +0000
844@@ -24,7 +24,6 @@
845
846 UCStyledItemBasePrivate::UCStyledItemBasePrivate()
847 : activeFocusOnPress(false)
848- , styleLoadingMethod(Immediate)
849 , styleComponent(0)
850 , styleItemContext(0)
851 , styleItem(0)
852@@ -41,8 +40,10 @@
853 {
854 Q_Q(UCStyledItemBase);
855 q->setFlag(QQuickItem::ItemIsFocusScope);
856- QObject::connect(&UCTheme::defaultTheme(), &UCTheme::nameChanged,
857- q, &UCStyledItemBase::themeChanged);
858+ QObject::connect(&UCTheme::defaultTheme(), SIGNAL(nameChanged()),
859+ q, SLOT(_q_reloadStyle()));
860+ QObject::connect(&UCTheme::defaultTheme(), SIGNAL(versionChanged()),
861+ q, SLOT(_q_reloadStyle()));
862 }
863
864
865@@ -90,12 +91,17 @@
866 * \qml
867 * StyledItem {
868 * id: myItem
869- * style: theme.createStyleComponent("MyItemStyle.qml", myItem)
870+ * styleName: "MyItemStyle"
871 * }
872 * \endqml
873 *
874- * The Component set on \l style is instantiated and placed below everything else
875- * that the Item contains.
876+ * The style set on \l styleName is instantiated and placed below everything else
877+ * that the Item contains. When the style is defined in this way, the style is taken
878+ * from the current theme the StyledItem is themed with. Another way tpo set the
879+ * style of a component is to set the \l style property. This property expects a
880+ * component and it has precedence over the \l styleName, meaning that when both
881+ * \l styleName and \l style are set, the style will be created from the \l style
882+ * componment.
883 *
884 * A reference to the Item being styled is accessible from the style and named
885 * 'styledItem'.
886@@ -201,7 +207,26 @@
887
888 /*!
889 * \qmlproperty Component StyledItem::style
890- * Component instantiated immediately and placed below everything else.
891+ * Style component instantiated immediately and placed below everything else.
892+ * Has precedence over the \l styleName. When both set, the style will be
893+ * created from the component given as property value, and can be reset to the
894+ * theme style when set to null or reset (set to undefined).
895+ * \qml
896+ * Button {
897+ * text: "Press to reset"
898+ * style: Rectangle {
899+ * color: "tan"
900+ * Label {
901+ * anchors {
902+ * fill: parent
903+ * margins: units.gu(1)
904+ * }
905+ * text: styledItem.text
906+ * }
907+ * }
908+ * onClicked: style = undefined
909+ * }
910+ * \endqml
911 */
912 QQmlComponent *UCStyledItemBasePrivate::style() const
913 {
914@@ -218,6 +243,42 @@
915 postStyleChanged();
916 loadStyleItem();
917 }
918+void UCStyledItemBasePrivate::resetStyle()
919+{
920+ setStyle(Q_NULLPTR);
921+}
922+
923+/*!
924+ * \qmlproperty string StyledItem::styleName
925+ * The property specifies the component style name. The style name is a document
926+ * in the current theme, and should not contain the qml file extension. If specified
927+ * an error will be shown.
928+ * \qml
929+ * StyledItem {
930+ * id: myItem
931+ * styleName: "MyItemStyle"
932+ * }
933+ * \endqml
934+ * \note \l style property has precedence over styleName.
935+ */
936+QString UCStyledItemBasePrivate::styleName() const
937+{
938+ return styleDocument;
939+}
940+void UCStyledItemBasePrivate::setStyleName(const QString &name)
941+{
942+ if (name == styleDocument) {
943+ return;
944+ }
945+ QString prevName = styleDocument;
946+ styleDocument = name;
947+ if (prevName != styleDocument && !styleComponent) {
948+ preStyleChanged();
949+ postStyleChanged();
950+ }
951+ Q_EMIT q_func()->styleNameChanged();
952+ loadStyleItem();
953+}
954
955 // performs pre-style change actions, removes style item size change
956 // connections and destroys the style component
957@@ -236,36 +297,37 @@
958 }
959 }
960
961-// performs post-style change actions, creates the context object the
962-// style item will be created in
963-void UCStyledItemBasePrivate::postStyleChanged()
964+// loads the style animated or not, depending on the loading time
965+// returns true on successful style loading
966+bool UCStyledItemBasePrivate::loadStyleItem(bool animated)
967 {
968- if (!styleComponent || styleItemContext) {
969- return;
970+ if (styleItem || (!styleComponent && styleDocument.isEmpty()) || !componentComplete) {
971+ // the style loading is delayed
972+ return false;
973 }
974 Q_Q(UCStyledItemBase);
975+ // either styleComponent or styleName is valid
976+ QQmlComponent *component = styleComponent;
977+ if (!component) {
978+ component = getTheme()->createStyleComponent(styleDocument + ".qml", q);
979+ }
980+ if (!component) {
981+ return false;
982+ }
983+ // create context
984 // use creation context as parent to create the context we load the style item with
985- QQmlContext *creationContext = styleComponent->creationContext();
986+ QQmlContext *creationContext = component->creationContext();
987 if (!creationContext) {
988 creationContext = qmlContext(q);
989 }
990 styleItemContext = new QQmlContext(creationContext);
991 styleItemContext->setContextObject(q);
992 styleItemContext->setContextProperty("styledItem", q);
993-}
994-
995-// loads the style animated or not, depending on the loading time
996-void UCStyledItemBasePrivate::loadStyleItem(bool animated)
997-{
998- if (styleItem || !styleComponent || !styleItemContext || (styleLoadingMethod != Immediate && !componentComplete)) {
999- // the style loading is delayed
1000- return;
1001- }
1002- Q_Q(UCStyledItemBase);
1003 styleItemContext->setContextProperty("animated", animated);
1004- QObject *object = styleComponent->beginCreate(styleItemContext);
1005+ QObject *object = component->beginCreate(styleItemContext);
1006 if (!object) {
1007- return;
1008+ delete styleItemContext;
1009+ return false;
1010 }
1011 // link context to the style item to delete them together
1012 QQml_setParent_noEvent(styleItemContext, object);
1013@@ -281,7 +343,11 @@
1014 } else {
1015 delete object;
1016 }
1017- styleComponent->completeCreate();
1018+ component->completeCreate();
1019+ // delete temporary component
1020+ if (!styleComponent) {
1021+ delete component;
1022+ }
1023
1024 // make sure we reset the animated property to true
1025 if (!animated) {
1026@@ -292,6 +358,7 @@
1027 _q_styleResized();
1028 connectStyleSizeChanges(true);
1029 Q_EMIT q->styleInstanceChanged();
1030+ return true;
1031 }
1032
1033 /*!
1034@@ -339,6 +406,19 @@
1035 }
1036 }
1037
1038+// reloads style component due to theme, theme.name or theme.version change
1039+void UCStyledItemBasePrivate::_q_reloadStyle()
1040+{
1041+ if (styleComponent) {
1042+ return;
1043+ }
1044+ Q_Q(UCStyledItemBase);
1045+ preStyleChanged();
1046+ postStyleChanged();
1047+ loadStyleItem();
1048+ Q_EMIT q->themeChanged();
1049+}
1050+
1051 // handle implicit size changes implied by the style components
1052 void UCStyledItemBasePrivate::_q_styleResized()
1053 {
1054@@ -395,8 +475,10 @@
1055 theme :
1056 (!parentStyledItem ? &UCTheme::defaultTheme() : NULL);
1057 if (connectedSet) {
1058- QObject::disconnect(connectedSet, &UCTheme::nameChanged,
1059- q, &UCStyledItemBase::themeChanged);
1060+ QObject::disconnect(connectedSet, SIGNAL(nameChanged()),
1061+ q, SLOT(_q_reloadStyle()));
1062+ QObject::disconnect(connectedSet, SIGNAL(versionChanged()),
1063+ q, SLOT(_q_reloadStyle()));
1064 }
1065
1066 UCTheme *prevSet = theme;
1067@@ -419,8 +501,10 @@
1068 theme :
1069 (!parentStyledItem ? &UCTheme::defaultTheme() : NULL);
1070 if (connectedSet) {
1071- QObject::connect(connectedSet, &UCTheme::nameChanged,
1072- q, &UCStyledItemBase::themeChanged);
1073+ QObject::connect(connectedSet, SIGNAL(nameChanged()),
1074+ q, SLOT(_q_reloadStyle()));
1075+ QObject::connect(connectedSet, SIGNAL(versionChanged()),
1076+ q, SLOT(_q_reloadStyle()));
1077 }
1078 // detach previous set and attach the new one
1079 if (prevSet) {
1080@@ -437,6 +521,13 @@
1081 postThemeChanged();
1082
1083 Q_EMIT q->themeChanged();
1084+
1085+ // perform style reload
1086+ if (!styleComponent) {
1087+ preStyleChanged();
1088+ postStyleChanged();
1089+ loadStyleItem();
1090+ }
1091 }
1092 void UCStyledItemBasePrivate::resetTheme()
1093 {
1094@@ -542,10 +633,10 @@
1095 {
1096 QQuickItem::componentComplete();
1097 Q_D(UCStyledItemBase);
1098- if (d->styleLoadingMethod == UCStyledItemBasePrivate::DelayTillCompleted) {
1099- // the delayed completion disables animations
1100- d->loadStyleItem(false);
1101- }
1102+ // no animation at this time
1103+ // prepare style context if not been done yet
1104+ d->postStyleChanged();
1105+ d->loadStyleItem(false);
1106 }
1107
1108 // grab pressed state and focus if it can be
1109
1110=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase.h'
1111--- modules/Ubuntu/Components/plugin/ucstyleditembase.h 2015-04-13 13:42:03 +0000
1112+++ modules/Ubuntu/Components/plugin/ucstyleditembase.h 2015-06-01 10:41:20 +0000
1113@@ -29,8 +29,9 @@
1114 Q_PROPERTY(bool activeFocusOnPress
1115 READ activefocusOnPress WRITE setActiveFocusOnPress
1116 NOTIFY activeFocusOnPressChanged REVISION 1)
1117- Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQmlComponent *style READ style WRITE setStyle NOTIFY styleChanged FINAL DESIGNABLE false)
1118+ Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQmlComponent *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL DESIGNABLE false)
1119 Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQuickItem *__styleInstance READ styleInstance NOTIFY styleInstanceChanged FINAL DESIGNABLE false)
1120+ Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged FINAL REVISION 2)
1121 Q_PRIVATE_PROPERTY(d_func(), UCTheme *theme READ getTheme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL REVISION 2)
1122 public:
1123 explicit UCStyledItemBase(QQuickItem *parent = 0);
1124@@ -46,6 +47,7 @@
1125 void styleInstanceChanged();
1126 Q_REVISION(1) void activeFocusOnPressChanged();
1127 Q_REVISION(2) void themeChanged();
1128+ Q_REVISION(2) void styleNameChanged();
1129
1130 protected:
1131 UCStyledItemBase(UCStyledItemBasePrivate &, QQuickItem *parent);
1132@@ -60,6 +62,7 @@
1133 Q_PRIVATE_SLOT(d_func(), void _q_styleResized())
1134 Q_PRIVATE_SLOT(d_func(), void _q_ascendantChanged(QQuickItem*))
1135 Q_PRIVATE_SLOT(d_func(), void _q_parentStyleChanged())
1136+ Q_PRIVATE_SLOT(d_func(), void _q_reloadStyle())
1137 };
1138
1139 #endif // UCSTYLEDITEMBASE_H
1140
1141=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase_p.h'
1142--- modules/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-04-14 07:46:04 +0000
1143+++ modules/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-06-01 10:41:20 +0000
1144@@ -29,16 +29,11 @@
1145 Q_DECLARE_PUBLIC(UCStyledItemBase)
1146 public:
1147
1148- enum StyleLoadingMethod {
1149- Immediate,
1150- DelayTillCompleted,
1151- DelayTillExplicitRequested
1152- };
1153-
1154 static UCStyledItemBasePrivate *get(UCStyledItemBase *item) {
1155 return item->d_func();
1156 }
1157
1158+ void _q_reloadStyle();
1159 void _q_styleResized();
1160 void _q_ascendantChanged(QQuickItem *ascendant);
1161 void _q_parentStyleChanged();
1162@@ -52,11 +47,15 @@
1163
1164 QQmlComponent *style() const;
1165 void setStyle(QQmlComponent *style);
1166+ void resetStyle();
1167 QQuickItem *styleInstance();
1168
1169+ QString styleName() const;
1170+ void setStyleName(const QString &name);
1171+
1172 virtual void preStyleChanged();
1173- virtual void postStyleChanged();
1174- virtual void loadStyleItem(bool animated = true);
1175+ virtual void postStyleChanged() {}
1176+ virtual bool loadStyleItem(bool animated = true);
1177
1178 UCTheme *getTheme() const;
1179 void setTheme(UCTheme *theme);
1180@@ -67,7 +66,7 @@
1181
1182 public:
1183 bool activeFocusOnPress:1;
1184- StyleLoadingMethod styleLoadingMethod;
1185+ QString styleDocument;
1186 QQmlComponent *styleComponent;
1187 QPointer<QQmlContext> styleItemContext;
1188 QQuickItem *styleItem;
1189
1190=== modified file 'modules/Ubuntu/Components/plugin/uctheme.cpp'
1191--- modules/Ubuntu/Components/plugin/uctheme.cpp 2015-05-02 09:20:35 +0000
1192+++ modules/Ubuntu/Components/plugin/uctheme.cpp 2015-06-01 10:41:20 +0000
1193@@ -121,15 +121,18 @@
1194 * }
1195 * \endqml
1196 *
1197- * The \l createStyleComponent function can be used to create the style for a
1198- * component. The following example will create the style with the inherited
1199- * theme.
1200+ * The style can be set on a StyledItem either using \l StyledItem::styleName or
1201+ * \l StyledItem::style properties. When set through \l StyledItem::styleName,
1202+ * the component will load the style from the current theme set, and must be a
1203+ * QML document. The \l StyledItem::style property is a Component which can be
1204+ * declared local, or loaded with a Loader or created using Qt.createComponent()
1205+ * function.
1206+ * The following example will create the style with the inherited theme.
1207 * \qml
1208 * import QtQuick 2.4
1209 * import Ubuntu.Components 1.3
1210 * StyledItem {
1211- * id: myItem
1212- * style: theme.createStyleComponent("MyItemStyle.qml", myItem)
1213+ * styleName: "MyItemStyle"
1214 * }
1215 * \endqml
1216 * All styled toolkit components such as \l Button, \l CheckBox, \l Switch, etc.
1217@@ -642,24 +645,20 @@
1218 }
1219 m_version = version;
1220 Q_EMIT versionChanged();
1221- // emit also nameChanged() so we reload the theme/style
1222- Q_EMIT nameChanged();
1223 }
1224
1225-/*!
1226- * \qmlmethod Component ThemeSettings::createStyleComponent(string styleName, object parent)
1227+/*
1228 * Returns an instance of the style component named \a styleName and parented
1229 * to \a parent.
1230 */
1231-QQmlComponent* UCTheme::createStyleComponent(const QString& styleName, QObject* parent)
1232-{
1233- return createStyleComponent(styleName, parent, m_version);
1234-}
1235-
1236 QQmlComponent* UCTheme::createStyleComponent(const QString& styleName, QObject* parent, quint16 version)
1237 {
1238 QQmlComponent *component = NULL;
1239
1240+ if (!version) {
1241+ version = m_version;
1242+ }
1243+
1244 if (parent != NULL) {
1245 QQmlEngine* engine = qmlEngine(parent);
1246 if (engine != m_engine && !m_engine) {
1247@@ -681,6 +680,9 @@
1248 qmlInfo(parent) << component->errorString();
1249 delete component;
1250 component = NULL;
1251+ } else {
1252+ // set context for the component
1253+ QQmlEngine::setContextForObject(component, qmlContext(parent));
1254 }
1255 } else {
1256 qmlInfo(parent) <<
1257
1258=== modified file 'modules/Ubuntu/Components/plugin/uctheme.h'
1259--- modules/Ubuntu/Components/plugin/uctheme.h 2015-05-02 08:49:38 +0000
1260+++ modules/Ubuntu/Components/plugin/uctheme.h 2015-06-01 10:41:20 +0000
1261@@ -76,8 +76,7 @@
1262 void setVersion(quint16 version);
1263
1264 // internal, used by the deprecated Theme.createStyledComponent()
1265- QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version);
1266- Q_INVOKABLE QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent);
1267+ QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version = 0);
1268 static void registerToContext(QQmlContext* context);
1269
1270 // helper functions
1271
1272=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/__init__.py'
1273--- tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2015-04-14 21:02:06 +0000
1274+++ tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2015-06-01 10:41:20 +0000
1275@@ -94,6 +94,7 @@
1276 def setUp(self):
1277 super().setUp()
1278 self.launch_application()
1279+ self.pointing_device = Pointer(self.input_device_class.create())
1280
1281 def launch_application(self):
1282 fake_application = fixture_setup.FakeApplication(
1283@@ -130,8 +131,6 @@
1284 self.assertThat(
1285 self.main_view.visible, Eventually(Equals(True)))
1286
1287- self.pointing_device = Pointer(self.input_device_class.create())
1288-
1289 @property
1290 def main_view(self):
1291 """
1292@@ -149,44 +148,20 @@
1293 UP, DOWN, LEFT, RIGHT = range(0, 4)
1294
1295
1296-class QMLFileAppTestCase(base.UbuntuUIToolkitAppTestCase):
1297+class QMLFileAppTestCase(UbuntuUIToolkitWithFakeAppRunningTestCase):
1298 """Base test case for self tests that launch a QML file."""
1299
1300 test_qml_file_path = '/path/to/file.qml'
1301 desktop_file_path = None
1302
1303 def setUp(self):
1304+ with open(self.test_qml_file_path) as qml_file:
1305+ self.test_qml = qml_file.read()
1306 super().setUp()
1307- self.pointing_device = Pointer(self.input_device_class.create())
1308- self.launch_application()
1309
1310 def get_command_line(self, command_line):
1311 return command_line
1312
1313- def launch_application(self):
1314- desktop_file_path = self._get_desktop_file_path()
1315- command_line = [
1316- base.get_toolkit_launcher_command(),
1317- "-I", _get_module_include_path(),
1318- self.test_qml_file_path,
1319- '--desktop_file_hint={0}'.format(desktop_file_path)
1320- ]
1321- self.app = self.launch_test_application(
1322- *self.get_command_line(command_line),
1323- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase,
1324- app_type='qt')
1325-
1326- self.assertThat(
1327- self.main_view.visible, Eventually(Equals(True)))
1328-
1329- def _get_desktop_file_path(self):
1330- if self.desktop_file_path is None:
1331- desktop_file_path = _write_test_desktop_file()
1332- self.addCleanup(os.remove, desktop_file_path)
1333- return desktop_file_path
1334- else:
1335- self.desktop_file_path
1336-
1337 @property
1338 def main_view(self):
1339 """
1340
1341=== modified file 'tests/resources/navigation/tabs.qml'
1342--- tests/resources/navigation/tabs.qml 2015-04-24 10:45:31 +0000
1343+++ tests/resources/navigation/tabs.qml 2015-06-01 10:41:20 +0000
1344@@ -15,8 +15,8 @@
1345 */
1346
1347 import QtQuick 2.0
1348-import Ubuntu.Components 1.2
1349-import Ubuntu.Components.ListItems 1.0 as ListItem
1350+import Ubuntu.Components 1.3
1351+import Ubuntu.Components.ListItems 1.3 as ListItem
1352
1353 MainView {
1354 width: 800
1355
1356=== modified file 'tests/unit/tst_performance/PaletteConfigurationAllColors.qml'
1357--- tests/unit/tst_performance/PaletteConfigurationAllColors.qml 2015-03-19 11:21:42 +0000
1358+++ tests/unit/tst_performance/PaletteConfigurationAllColors.qml 2015-06-01 10:41:20 +0000
1359@@ -16,7 +16,7 @@
1360
1361 import QtQuick 2.4
1362 import Ubuntu.Components 1.3
1363-import Ubuntu.Components.Themes 1.0
1364+import Ubuntu.Components.Themes 1.3
1365
1366 StyledItem {
1367 width: 100
1368
1369=== modified file 'tests/unit/tst_performance/PaletteConfigurationOneColor.qml'
1370--- tests/unit/tst_performance/PaletteConfigurationOneColor.qml 2015-03-19 11:21:42 +0000
1371+++ tests/unit/tst_performance/PaletteConfigurationOneColor.qml 2015-06-01 10:41:20 +0000
1372@@ -16,7 +16,7 @@
1373
1374 import QtQuick 2.4
1375 import Ubuntu.Components 1.3
1376-import Ubuntu.Components.Themes 1.0
1377+import Ubuntu.Components.Themes 1.3
1378
1379 StyledItem {
1380 width: 100
1381
1382=== modified file 'tests/unit_x11/tst_components/tst_actionbar.qml'
1383--- tests/unit_x11/tst_components/tst_actionbar.qml 2015-05-14 21:41:16 +0000
1384+++ tests/unit_x11/tst_components/tst_actionbar.qml 2015-06-01 10:41:20 +0000
1385@@ -30,7 +30,7 @@
1386 },
1387 Action {
1388 iconName: "appointment"
1389- text: "Appointment"
1390+ text: "Date"
1391 },
1392 Action {
1393 iconName: "attachment"
1394
1395=== modified file 'tests/unit_x11/tst_components/tst_header_presets.qml'
1396--- tests/unit_x11/tst_components/tst_header_presets.qml 2015-03-03 13:20:06 +0000
1397+++ tests/unit_x11/tst_components/tst_header_presets.qml 2015-06-01 10:41:20 +0000
1398@@ -1,5 +1,5 @@
1399 /*
1400- * Copyright 2014 Canonical Ltd.
1401+ * Copyright 2015 Canonical Ltd.
1402 *
1403 * This program is free software; you can redistribute it and/or modify
1404 * it under the terms of the GNU Lesser General Public License as published by
1405@@ -35,6 +35,13 @@
1406 objectName: "selectAction"
1407 text: "Select all"
1408 iconName: "select"
1409+ onTriggered: {
1410+ if (page.head.preset === "") {
1411+ page.head.preset = "select";
1412+ } else {
1413+ page.head.preset = "";
1414+ }
1415+ }
1416 }
1417 ]
1418 }
1419
1420=== modified file 'tests/unit_x11/tst_subtheming/DeprecatedTheme.qml'
1421--- tests/unit_x11/tst_subtheming/DeprecatedTheme.qml 2015-05-01 11:32:48 +0000
1422+++ tests/unit_x11/tst_subtheming/DeprecatedTheme.qml 2015-06-01 10:41:20 +0000
1423@@ -21,5 +21,5 @@
1424 width: units.gu(40)
1425 height: units.gu(40)
1426 theme.name: "Ubuntu.Components.Themes.SuruGradient"
1427- style: theme.createStyleComponent("OptionSelectorStyle.qml", item)
1428+ styleName: "OptionSelectorStyle"
1429 }
1430
1431=== modified file 'tests/unit_x11/tst_subtheming/SimpleItem.qml'
1432--- tests/unit_x11/tst_subtheming/SimpleItem.qml 2015-03-12 20:11:38 +0000
1433+++ tests/unit_x11/tst_subtheming/SimpleItem.qml 2015-06-01 10:41:20 +0000
1434@@ -17,13 +17,9 @@
1435 import QtQuick 2.4
1436 import Ubuntu.Components 1.3
1437
1438-Item {
1439+StyledItem {
1440 id: item
1441- property ThemeSettings theme: ThemeSettings {}
1442- property Component style
1443-
1444- property string styleDocument
1445- onStyleDocumentChanged: style = theme.createStyleComponent(styleDocument, item)
1446+ theme: ThemeSettings {}
1447
1448 property string themeName
1449 onThemeNameChanged: theme.name = themeName;
1450
1451=== added file 'tests/unit_x11/tst_subtheming/StyleKept.qml'
1452--- tests/unit_x11/tst_subtheming/StyleKept.qml 1970-01-01 00:00:00 +0000
1453+++ tests/unit_x11/tst_subtheming/StyleKept.qml 2015-06-01 10:41:20 +0000
1454@@ -0,0 +1,43 @@
1455+/*
1456+ * Copyright 2015 Canonical Ltd.
1457+ *
1458+ * This program is free software; you can redistribute it and/or modify
1459+ * it under the terms of the GNU Lesser General Public License as published by
1460+ * the Free Software Foundation; version 3.
1461+ *
1462+ * This program is distributed in the hope that it will be useful,
1463+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1464+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1465+ * GNU Lesser General Public License for more details.
1466+ *
1467+ * You should have received a copy of the GNU Lesser General Public License
1468+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1469+ */
1470+import QtQuick 2.4
1471+import Ubuntu.Components 1.3
1472+
1473+Item {
1474+ width: units.gu(40)
1475+ height: units.gu(40)
1476+
1477+ Button {
1478+ objectName: "TestButton"
1479+ text: "PressMe..."
1480+ style: Rectangle {
1481+ objectName: "TestStyle"
1482+ // FIXME: move these properties to the Style API
1483+ property color defaultColor: "blue"
1484+ property Gradient defaultGradient
1485+ property font defaultFont
1486+
1487+ anchors.fill: styledItem
1488+ color: defaultColor
1489+ Label {
1490+ anchors.fill: parent
1491+ horizontalAlignment: Text.AlignHCenter
1492+ verticalAlignment: Text.AlignVCenter
1493+ text: styledItem.text
1494+ }
1495+ }
1496+ }
1497+}
1498
1499=== added file 'tests/unit_x11/tst_subtheming/StyleOverride.qml'
1500--- tests/unit_x11/tst_subtheming/StyleOverride.qml 1970-01-01 00:00:00 +0000
1501+++ tests/unit_x11/tst_subtheming/StyleOverride.qml 2015-06-01 10:41:20 +0000
1502@@ -0,0 +1,46 @@
1503+/*
1504+ * Copyright 2015 Canonical Ltd.
1505+ *
1506+ * This program is free software; you can redistribute it and/or modify
1507+ * it under the terms of the GNU Lesser General Public License as published by
1508+ * the Free Software Foundation; version 3.
1509+ *
1510+ * This program is distributed in the hope that it will be useful,
1511+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1512+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1513+ * GNU Lesser General Public License for more details.
1514+ *
1515+ * You should have received a copy of the GNU Lesser General Public License
1516+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1517+ */
1518+import QtQuick 2.4
1519+import Ubuntu.Components 1.3
1520+
1521+Item {
1522+ width: units.gu(40)
1523+ height: units.gu(40)
1524+
1525+ Button {
1526+ objectName: "TestButton"
1527+ text: "PressMe..."
1528+ }
1529+
1530+ property Component customStyle: Component {
1531+ Rectangle {
1532+ objectName: "TestStyle"
1533+ // FIXME: move these properties to the Style API
1534+ property color defaultColor: "blue"
1535+ property Gradient defaultGradient
1536+ property font defaultFont
1537+
1538+ anchors.fill: styledItem
1539+ color: defaultColor
1540+ Label {
1541+ anchors.fill: parent
1542+ horizontalAlignment: Text.AlignHCenter
1543+ verticalAlignment: Text.AlignVCenter
1544+ text: styledItem.text
1545+ }
1546+ }
1547+ }
1548+}
1549
1550=== modified file 'tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml'
1551--- tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml 2015-04-27 16:25:09 +0000
1552+++ tests/unit_x11/tst_subtheming/StyledItemAppThemeFallback.qml 2015-06-01 10:41:20 +0000
1553@@ -20,5 +20,5 @@
1554 id: item
1555 theme.name: "themes.CustomTheme"
1556 theme.version: Ubuntu.version(1, 0)
1557- style: theme.createStyleComponent("TestStyle.qml", item)
1558+ styleName: "TestStyle"
1559 }
1560
1561=== modified file 'tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml'
1562--- tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml 2015-05-02 09:20:35 +0000
1563+++ tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml 2015-06-01 10:41:20 +0000
1564@@ -20,5 +20,5 @@
1565 id: item
1566 theme.name: "themes.CustomTheme"
1567 theme.version: Ubuntu.toolkitVersion
1568- style: theme.createStyleComponent("TestStyle.qml", item)
1569+ styleName: "TestStyle"
1570 }
1571
1572=== modified file 'tests/unit_x11/tst_subtheming/StyledItemFallback.qml'
1573--- tests/unit_x11/tst_subtheming/StyledItemFallback.qml 2015-04-27 14:46:31 +0000
1574+++ tests/unit_x11/tst_subtheming/StyledItemFallback.qml 2015-06-01 10:41:20 +0000
1575@@ -20,5 +20,5 @@
1576 id: item
1577 theme.name: "TestModule.TestTheme"
1578 theme.version: Ubuntu.version(1, 0)
1579- style: theme.createStyleComponent("TestStyle.qml", item)
1580+ styleName: "TestStyle"
1581 }
1582
1583=== modified file 'tests/unit_x11/tst_subtheming/StyledItemV12.qml'
1584--- tests/unit_x11/tst_subtheming/StyledItemV12.qml 2015-04-27 12:46:28 +0000
1585+++ tests/unit_x11/tst_subtheming/StyledItemV12.qml 2015-06-01 10:41:20 +0000
1586@@ -20,5 +20,5 @@
1587 id: item
1588 theme.name: "themes.CustomTheme"
1589 theme.version: Ubuntu.version(1, 2)
1590- style: theme.createStyleComponent("TestStyle.qml", item)
1591+ styleName: "TestStyle"
1592 }
1593
1594=== modified file 'tests/unit_x11/tst_subtheming/StyledItemV13.qml'
1595--- tests/unit_x11/tst_subtheming/StyledItemV13.qml 2015-04-27 12:46:28 +0000
1596+++ tests/unit_x11/tst_subtheming/StyledItemV13.qml 2015-06-01 10:41:20 +0000
1597@@ -20,5 +20,5 @@
1598 id: item
1599 theme.name: "themes.CustomTheme"
1600 theme.version: Ubuntu.toolkitVersion
1601- style: theme.createStyleComponent("TestStyle.qml", item)
1602+ styleName: "TestStyle"
1603 }
1604
1605=== modified file 'tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml'
1606--- tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml 2015-04-27 12:46:28 +0000
1607+++ tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml 2015-06-01 10:41:20 +0000
1608@@ -17,4 +17,5 @@
1609 import QtQuick 2.0
1610
1611 Item {
1612+ objectName: "TestStyle"
1613 }
1614
1615=== modified file 'tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml'
1616--- tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml 2015-04-25 06:35:16 +0000
1617+++ tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml 2015-06-01 10:41:20 +0000
1618@@ -17,5 +17,6 @@
1619 import QtQuick 2.0
1620
1621 Item {
1622+ objectName: "TestStyle"
1623 property string newProperty: "version1.3"
1624 }
1625
1626=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp'
1627--- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-05-02 09:20:35 +0000
1628+++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-06-01 10:41:20 +0000
1629@@ -21,6 +21,7 @@
1630 #include <QtQml/QQmlContext>
1631 #include <QtQml/QQmlComponent>
1632 #include "uctheme.h"
1633+#include "quickutils.h"
1634 #include "uctestcase.h"
1635 #include "ucstyleditembase_p.h"
1636 #include "ucnamespace.h"
1637@@ -62,12 +63,6 @@
1638 QTest::waitForEvents();
1639 }
1640
1641- void setStyle(const QString &style)
1642- {
1643- rootObject()->setProperty("styleDocument", style);
1644- QTest::waitForEvents();
1645- }
1646-
1647 UCTheme *theme()
1648 {
1649 return rootObject()->property("theme").value<UCTheme*>();
1650@@ -134,25 +129,27 @@
1651 QTest::addColumn<QString>("styleName");
1652 QTest::addColumn<QString>("parentName");
1653 QTest::addColumn<bool>("success");
1654- QTest::newRow("Existing style") << "TestStyle.qml" << "SimpleItem.qml" << true;
1655- QTest::newRow("Non existing style") << "NotExistingTestStyle.qml" << "SimpleItem.qml" << false;
1656+ QTest::addColumn<QString>("warning");
1657+ QTest::newRow("Existing style") << "TestStyle" << "SimpleItem.qml" << true << QString();
1658+ QTest::newRow("Non existing style") << "NotExistingTestStyle" << "SimpleItem.qml" << false << "QML SimpleItem: Warning: Style NotExistingTestStyle.qml not found in theme TestModule.TestTheme";
1659 }
1660 void test_create_style_component()
1661 {
1662 QFETCH(QString, styleName);
1663 QFETCH(QString, parentName);
1664 QFETCH(bool, success);
1665+ QFETCH(QString, warning);
1666
1667- if (styleName == "NotExistingTestStyle.qml") {
1668- ThemeTestCase::ignoreWarning(parentName, 20, 1, "QML SimpleItem: Warning: Style NotExistingTestStyle.qml not found in theme TestModule.TestTheme");
1669+ if (!warning.isEmpty()) {
1670+ ThemeTestCase::ignoreWarning(parentName, 20, 1, warning);
1671 }
1672 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "./themes");
1673
1674 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(parentName));
1675 view->setTheme("TestModule.TestTheme");
1676- view->setStyle(styleName);
1677- QQmlComponent *style = view->rootObject()->property("style").value<QQmlComponent*>();
1678- QCOMPARE(style != NULL, success);
1679+ view->rootObject()->setProperty("styleName", styleName);
1680+ QQuickItem *testStyle = view->rootObject()->findChild<QQuickItem*>("TestStyle");
1681+ QCOMPARE(testStyle != NULL, success);
1682 }
1683
1684 void test_relative_theme_paths_environment_variables_data()
1685@@ -166,23 +163,23 @@
1686
1687 QTest::newRow("One toolkit theme path")
1688 << "./themes" << ""
1689- << "TestModule.TestTheme" << "TestStyle.qml"
1690+ << "TestModule.TestTheme" << "TestStyle"
1691 << "" << true;
1692 QTest::newRow("Two toolkit theme paths")
1693 << "./themes:./themes/TestModule" << ""
1694- << "CustomTheme" << "TestStyle.qml"
1695+ << "CustomTheme" << "TestStyle"
1696 << "" << true;
1697 QTest::newRow("One XDG path")
1698 << "" << "./themes"
1699- << "TestModule.TestTheme" << "TestStyle.qml"
1700+ << "TestModule.TestTheme" << "TestStyle"
1701 << "" << true;
1702 QTest::newRow("Two XDG paths")
1703 << "" << "./themes:./themes/TestModule"
1704- << "CustomTheme" << "TestStyle.qml"
1705+ << "CustomTheme" << "TestStyle"
1706 << "" << true;
1707 QTest::newRow("No variables")
1708 << "" << ""
1709- << QString() << "TestStyle.qml"
1710+ << QString() << "TestStyle"
1711 << "QML SimpleItem: Warning: Style TestStyle.qml not found in theme Ubuntu.Components.Themes.Ambiance" << false;
1712 }
1713
1714@@ -206,9 +203,9 @@
1715 if (!theme.isEmpty()) {
1716 view->setTheme(theme);
1717 }
1718- view->setStyle(style);
1719- QQmlComponent *styleComponent = view->rootObject()->property("style").value<QQmlComponent*>();
1720- QCOMPARE(styleComponent != NULL, success);
1721+ view->rootObject()->setProperty("styleName", style);
1722+ QQuickItem *styleItem = view->rootObject()->findChild<QQuickItem*>("TestStyle");
1723+ QCOMPARE(styleItem != NULL, success);
1724 }
1725
1726 void test_import_path()
1727@@ -662,7 +659,7 @@
1728 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
1729 qputenv("XDG_DATA_DIRS", "./themes:./themes/TestModule");
1730 if (!warning.isEmpty()) {
1731- ThemeTestCase::ignoreWarning(document, row, column, warning, 2);
1732+ ThemeTestCase::ignoreWarning(document, row, column, warning);
1733 }
1734 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(document));
1735 UCStyledItemBase *styledItem = qobject_cast<UCStyledItemBase*>(view->rootObject());
1736@@ -683,6 +680,67 @@
1737 // which will cause a warning; therefore we mark the warning to be ignored
1738 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.");
1739 }
1740+
1741+ void test_style_change_has_precedence()
1742+ {
1743+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleOverride.qml"));
1744+ QQmlComponent *style = view->rootObject()->property("customStyle").value<QQmlComponent*>();
1745+ QQuickItem *button = view->findItem<QQuickItem*>("TestButton");
1746+
1747+ button->setProperty("style", QVariant::fromValue(style));
1748+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1749+ }
1750+
1751+ void test_style_kept_when_stylename_changes_data()
1752+ {
1753+ QTest::addColumn<QString>("styleName");
1754+
1755+ QTest::newRow("Empty style name") << QString();
1756+ QTest::newRow("Any style name") << "Bumblebee";
1757+ }
1758+ void test_style_kept_when_stylename_changes()
1759+ {
1760+ QFETCH(QString, styleName);
1761+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml"));
1762+ QQuickItem *button = view->findItem<QQuickItem*>("TestButton");
1763+
1764+ button->setProperty("styleName", styleName);
1765+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1766+ }
1767+
1768+ void test_style_kept_when_theme_changes()
1769+ {
1770+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml"));
1771+ QQuickItem *button = view->findItem<QQuickItem*>("TestButton");
1772+ UCTheme *theme = button->property("theme").value<UCTheme*>();
1773+ QVERIFY(theme);
1774+
1775+ theme->setName("Ubuntu.Components.Themes.SuruDark");
1776+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1777+ }
1778+
1779+ void test_style_reset_to_theme_style()
1780+ {
1781+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml"));
1782+ UCStyledItemBase *button = view->findItem<UCStyledItemBase*>("TestButton");
1783+ UCTheme *theme = UCStyledItemBasePrivate::get(button)->getTheme();
1784+ QVERIFY(theme);
1785+
1786+ QVERIFY(button->findChild<QQuickItem*>("TestStyle"));
1787+ // reset style property, which should reset style to the theme style
1788+ UCStyledItemBasePrivate::get(button)->resetStyle();
1789+ QQuickItem *styleItem = UCStyledItemBasePrivate::get(button)->styleInstance();
1790+ QCOMPARE(QuickUtils::className(styleItem), QString("ButtonStyle"));
1791+ }
1792+
1793+ void test_stylename_extension_failure()
1794+ {
1795+ ThemeTestCase::ignoreWarning("DeprecatedTheme.qml", 19, 1, "QML StyledItem: Warning: Style OptionSelectorStyle.qml.qml not found in theme Ubuntu.Components.Themes.SuruGradient");
1796+ // add also for Ambiance, as ThemeTestCase destructor resets the theme, which will cause style warning for the default theme
1797+ ThemeTestCase::ignoreWarning("DeprecatedTheme.qml", 19, 1, "QML StyledItem: Warning: Style OptionSelectorStyle.qml.qml not found in theme Ubuntu.Components.Themes.Ambiance");
1798+ QScopedPointer<ThemeTestCase> view(new ThemeTestCase("DeprecatedTheme.qml"));
1799+ view->rootObject()->setProperty("styleName", "OptionSelectorStyle.qml");
1800+ }
1801 };
1802
1803 QTEST_MAIN(tst_Subtheming)
1804
1805=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.pro'
1806--- tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-05-02 09:20:35 +0000
1807+++ tests/unit_x11/tst_subtheming/tst_subtheming.pro 2015-06-01 10:41:20 +0000
1808@@ -31,6 +31,8 @@
1809 StyledItemFallback.qml \
1810 StyledItemAppThemeFallback.qml \
1811 DeprecatedTheme.qml \
1812- StyledItemAppThemeVersioned.qml
1813+ StyledItemAppThemeVersioned.qml \
1814+ StyleOverride.qml \
1815+ StyleKept.qml
1816
1817

Subscribers

People subscribed via source and target branches

to status/vote changes: