Merge lp:~tpeeters/ubuntu-ui-toolkit/120-HeaderState into lp:ubuntu-ui-toolkit/staging
- 120-HeaderState
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Cris Dywan |
Approved revision: | 1130 |
Merged at revision: | 1136 |
Proposed branch: | lp:~tpeeters/ubuntu-ui-toolkit/120-HeaderState |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Prerequisite: | lp:~tpeeters/ubuntu-ui-toolkit/110-headerInput |
Diff against target: |
329 lines (+183/-68) 6 files modified
components.api (+6/-0) modules/Ubuntu/Components/PageHeadConfiguration.qml (+3/-0) modules/Ubuntu/Components/PageHeadState.qml (+113/-0) modules/Ubuntu/Components/qmldir (+1/-0) tests/resources/toolbar/header.qml (+18/-32) tests/resources/toolbar/headerTextInput.qml (+42/-36) |
To merge this branch: | bzr merge lp:~tpeeters/ubuntu-ui-toolkit/120-HeaderState |
Related bugs: | |
Related blueprints: |
New header and bottom edge
(Essential)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Cris Dywan | Approve | ||
Review via email: mp+224813@code.launchpad.net |
Commit message
Add PageHeadState component.
Description of the change
Add PageHeadState to make it easier to configure the page header when changing states.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1121
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1122
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1123. By Tim Peeters
-
merge 110-headerInput
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1123
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 1124. By Tim Peeters
-
kick jenkins
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1124
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
Could PageHeadState potentially be used instead of the State { PropertyChanges } hack, if there's no way to correctly reset the actions otherwise? It seems like a bad idea to push internal details into app logic.
- 1125. By Tim Peeters
-
use PageHeadState for all States in example
Tim Peeters (tpeeters) wrote : | # |
I updated the example to use PageHeadState instead of the state there. But still this state is needed to reset the actions after the state was changed, so I am not sure this is what you meant.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1125
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
How about defining the search action in the default state? That way there's no redundancy, it's less hacky and less confusing to read. Like so http://
- 1126. By Tim Peeters
-
name the default state
- 1127. By Tim Peeters
-
fix example code
- 1128. By Tim Peeters
-
remove searchAction
- 1129. By Tim Peeters
-
fix
- 1130. By Tim Peeters
-
remove comment
Cris Dywan (kalikiana) wrote : | # |
Looking nice now!
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1127
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'components.api' |
2 | --- components.api 2014-07-02 13:39:29 +0000 |
3 | +++ components.api 2014-07-03 11:13:13 +0000 |
4 | @@ -250,6 +250,12 @@ |
5 | property list<Action> actions |
6 | property Action backAction |
7 | property Item contents |
8 | +PageHeadState 1.1 |
9 | +State |
10 | + property PageHeadConfiguration head |
11 | + property list<Action> actions |
12 | + property Action backAction |
13 | + property Item contents |
14 | PageStack 0.1 1.0 |
15 | PageTreeNode |
16 | property bool __showHeader |
17 | |
18 | === modified file 'modules/Ubuntu/Components/PageHeadConfiguration.qml' |
19 | --- modules/Ubuntu/Components/PageHeadConfiguration.qml 2014-06-30 17:49:31 +0000 |
20 | +++ modules/Ubuntu/Components/PageHeadConfiguration.qml 2014-07-03 11:13:13 +0000 |
21 | @@ -59,6 +59,9 @@ |
22 | } |
23 | } |
24 | \endqml |
25 | + |
26 | + See \l PageHeadState for an example that shows how search mode can |
27 | + be implemented. |
28 | */ |
29 | property Item contents: null |
30 | } |
31 | |
32 | === added file 'modules/Ubuntu/Components/PageHeadState.qml' |
33 | --- modules/Ubuntu/Components/PageHeadState.qml 1970-01-01 00:00:00 +0000 |
34 | +++ modules/Ubuntu/Components/PageHeadState.qml 2014-07-03 11:13:13 +0000 |
35 | @@ -0,0 +1,113 @@ |
36 | +/* |
37 | + * Copyright 2014 Canonical Ltd. |
38 | + * |
39 | + * This program is free software; you can redistribute it and/or modify |
40 | + * it under the terms of the GNU Lesser General Public License as published by |
41 | + * the Free Software Foundation; version 3. |
42 | + * |
43 | + * This program is distributed in the hope that it will be useful, |
44 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
45 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
46 | + * GNU Lesser General Public License for more details. |
47 | + * |
48 | + * You should have received a copy of the GNU Lesser General Public License |
49 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
50 | + */ |
51 | + |
52 | +import QtQuick 2.2 |
53 | + |
54 | +/*! |
55 | + \qmltype PageHeadState |
56 | + \inqmlmodule Ubuntu.Components 1.1 |
57 | + \ingroup ubuntu |
58 | + \since Ubuntu.Components 1.1 |
59 | + \brief PageHeadState is a helper component to make it easier to |
60 | + configure the page header when changing states. |
61 | + |
62 | + This example shows how to add an action to the header that |
63 | + enables the user to enter search/input mode: |
64 | + \qml |
65 | + import QtQuick 2.2 |
66 | + import Ubuntu.Components 1.1 |
67 | + |
68 | + MainView { |
69 | + id: mainView |
70 | + width: units.gu(40) |
71 | + height: units.gu(50) |
72 | + useDeprecatedToolbar: false |
73 | + |
74 | + Page { |
75 | + id: searchPage |
76 | + title: "Click the icon" |
77 | + |
78 | + Label { |
79 | + anchors.centerIn: parent |
80 | + text: searchPage.state == "search" ? "search mode" : "normal mode" |
81 | + } |
82 | + |
83 | + state: "default" |
84 | + states: [ |
85 | + PageHeadState { |
86 | + name: "default" |
87 | + head: searchPage.head |
88 | + actions: Action { |
89 | + iconName: "search" |
90 | + onTriggered: searchPage.state = "search" |
91 | + } |
92 | + }, |
93 | + PageHeadState { |
94 | + id: headerState |
95 | + name: "search" |
96 | + head: searchPage.head |
97 | + actions: [ |
98 | + Action { |
99 | + iconName: "contact" |
100 | + } |
101 | + ] |
102 | + backAction: Action { |
103 | + id: leaveSearchAction |
104 | + text: "back" |
105 | + iconName: "back" |
106 | + onTriggered: searchPage.state = "default" |
107 | + } |
108 | + contents: TextField { |
109 | + placeholderText: "search..." |
110 | + } |
111 | + } |
112 | + ] |
113 | + } |
114 | + } |
115 | + \endqml |
116 | + */ |
117 | +State { |
118 | + id: state |
119 | + |
120 | + /*! |
121 | + The head property of the \l Page which will be the target of |
122 | + the property changes of this State. This property must always |
123 | + be set before the State can be used. |
124 | + */ |
125 | + property PageHeadConfiguration head |
126 | + |
127 | + /*! |
128 | + The actions to be shown in the header with this state. |
129 | + */ |
130 | + property list<Action> actions |
131 | + |
132 | + /*! |
133 | + The back action for this state. |
134 | + */ |
135 | + property Action backAction |
136 | + |
137 | + /*! |
138 | + The contents of the header when this state is active. |
139 | + */ |
140 | + property Item contents |
141 | + |
142 | + PropertyChanges { |
143 | + target: state.head |
144 | + backAction: state.backAction |
145 | + actions: state.actions |
146 | + contents: state.contents |
147 | + } |
148 | +} |
149 | |
150 | === modified file 'modules/Ubuntu/Components/qmldir' |
151 | --- modules/Ubuntu/Components/qmldir 2014-07-02 13:39:29 +0000 |
152 | +++ modules/Ubuntu/Components/qmldir 2014-07-03 11:13:13 +0000 |
153 | @@ -99,3 +99,4 @@ |
154 | internal PageBase Page10.qml |
155 | Page 1.1 Page11.qml |
156 | PageHeadConfiguration 1.1 PageHeadConfiguration.qml |
157 | +PageHeadState 1.1 PageHeadState.qml |
158 | |
159 | === modified file 'tests/resources/toolbar/header.qml' |
160 | --- tests/resources/toolbar/header.qml 2014-06-30 12:09:25 +0000 |
161 | +++ tests/resources/toolbar/header.qml 2014-07-03 11:13:13 +0000 |
162 | @@ -145,49 +145,35 @@ |
163 | text: searchPage.state == "search" ? "search mode" : "normal mode" |
164 | } |
165 | |
166 | - head.actions: Action { |
167 | - id: searchAction |
168 | - iconName: "search" |
169 | - onTriggered: searchPage.state = "search" |
170 | - } |
171 | - |
172 | - state: "" |
173 | + state: "default" |
174 | states: [ |
175 | - State { |
176 | - name: "" |
177 | - PropertyChanges { |
178 | - target: searchPage.head |
179 | - // needed otherwise actions will not be |
180 | - // returned to its original state. |
181 | - actions: [ searchAction ] |
182 | + PageHeadState { |
183 | + name: "default" |
184 | + head: searchPage.head |
185 | + actions: Action { |
186 | + id: searchAction |
187 | + iconName: "search" |
188 | + onTriggered: searchPage.state = "search" |
189 | } |
190 | }, |
191 | - State { |
192 | - // TODO: The definition of this state will be |
193 | - // simplified a lot in a following MR that |
194 | - // introduces the HeaderState component. |
195 | + PageHeadState { |
196 | id: headerState |
197 | name: "search" |
198 | - property Action back: Action { |
199 | - id: leaveSearchAction |
200 | - text: "back" |
201 | - iconName: "back" |
202 | - onTriggered: searchPage.state = "" |
203 | - } |
204 | - property list<Action> actions: [ |
205 | + head: searchPage.head |
206 | + actions: [ |
207 | Action { |
208 | iconName: "contact" |
209 | } |
210 | ] |
211 | - property TextField input: TextField { |
212 | + backAction: Action { |
213 | + id: leaveSearchAction |
214 | + text: "back" |
215 | + iconName: "back" |
216 | + onTriggered: searchPage.state = "default" |
217 | + } |
218 | + contents: TextField { |
219 | placeholderText: "search..." |
220 | } |
221 | - PropertyChanges { |
222 | - target: searchPage.head |
223 | - backAction: headerState.back |
224 | - actions: headerState.actions |
225 | - contents: headerState.input |
226 | - } |
227 | } |
228 | ] |
229 | } |
230 | |
231 | === modified file 'tests/resources/toolbar/headerTextInput.qml' |
232 | --- tests/resources/toolbar/headerTextInput.qml 2014-05-06 16:20:50 +0000 |
233 | +++ tests/resources/toolbar/headerTextInput.qml 2014-07-03 11:13:13 +0000 |
234 | @@ -14,53 +14,59 @@ |
235 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
236 | */ |
237 | |
238 | -import QtQuick 2.0 |
239 | +import QtQuick 2.2 |
240 | import Ubuntu.Components 1.1 |
241 | |
242 | MainView { |
243 | - width: units.gu(50) |
244 | - height: units.gu(80) |
245 | + width: units.gu(40) |
246 | + height: units.gu(50) |
247 | useDeprecatedToolbar: false |
248 | |
249 | Page { |
250 | - title: "test page" |
251 | - |
252 | - id: page |
253 | - |
254 | - __customHeaderContents: Item { |
255 | - TextField { |
256 | - anchors { |
257 | - left: parent.left |
258 | - verticalCenter: parent.verticalCenter |
259 | - } |
260 | - } |
261 | - } |
262 | + id: searchPage |
263 | + title: "Click the icon" |
264 | |
265 | Label { |
266 | anchors.centerIn: parent |
267 | - text: "Hello, world" |
268 | - } |
269 | - |
270 | - tools: ToolbarItems { |
271 | - ToolbarButton { |
272 | - action: Action { |
273 | - iconName: "contact" |
274 | - text: "oh" |
275 | - onTriggered: print("lala") |
276 | - enabled: false |
277 | + text: searchPage.state == "search" ? "search mode" : "normal mode" |
278 | + } |
279 | + |
280 | + head.actions: Action { |
281 | + id: searchAction |
282 | + iconName: "search" |
283 | + onTriggered: searchPage.state = "search" |
284 | + } |
285 | + |
286 | + state: "" |
287 | + states: [ |
288 | + State { |
289 | + name: "" |
290 | + PropertyChanges { |
291 | + target: searchPage.head |
292 | + // needed otherwise actions will not be |
293 | + // returned to its original state. |
294 | + actions: [ searchAction ] |
295 | } |
296 | - } |
297 | - |
298 | - back: ToolbarButton { |
299 | - action: Action { |
300 | - text: "cancel" |
301 | - iconName: "cancel" |
302 | - onTriggered: { |
303 | - page.__customHeaderContents = null; |
304 | + }, |
305 | + PageHeadState { |
306 | + id: headerState |
307 | + name: "search" |
308 | + head: searchPage.head |
309 | + actions: [ |
310 | + Action { |
311 | + iconName: "contact" |
312 | } |
313 | - } |
314 | - anchors.verticalCenter: parent.verticalCenter |
315 | + ] |
316 | + backAction: Action { |
317 | + id: leaveSearchAction |
318 | + text: "back" |
319 | + iconName: "back" |
320 | + onTriggered: searchPage.state = "" |
321 | + } |
322 | + contents: TextField { |
323 | + placeholderText: "search..." |
324 | + } |
325 | } |
326 | - } |
327 | + ] |
328 | } |
329 | } |
FAILED: Continuous integration, rev:1120 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/501/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/1305 jenkins. qa.ubuntu. com/job/ generic- mediumtests- utopic/ 1143 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- utopic- amd64-ci/ 333 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- utopic- armhf-ci/ 333 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- utopic- armhf-ci/ 333/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- utopic- i386-ci/ 333 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- mako/1620 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/2207 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/2207/ artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 8957 jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-utopic/ 944 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/1286 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/1286/ artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/501/ rebuild
http://