Merge lp:~tpeeters/ubuntu-ui-toolkit/actionItem into lp:ubuntu-ui-toolkit
- actionItem
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 564 |
Merged at revision: | 542 |
Proposed branch: | lp:~tpeeters/ubuntu-ui-toolkit/actionItem |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
426 lines (+173/-38) 12 files modified
components.api (+7/-4) modules/Ubuntu/Components/AbstractButton.qml (+4/-8) modules/Ubuntu/Components/ActionItem.qml (+66/-0) modules/Ubuntu/Components/Button.qml (+3/-3) modules/Ubuntu/Components/ListItems/Empty.qml (+0/-5) modules/Ubuntu/Components/ListItems/MultiValue.qml (+1/-1) modules/Ubuntu/Components/ListItems/SingleValue.qml (+1/-1) modules/Ubuntu/Components/ListItems/Standard.qml (+1/-1) modules/Ubuntu/Components/ListItems/ValueSelector.qml (+1/-1) modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml (+4/-14) modules/Ubuntu/Components/qmldir (+1/-0) tests/unit/tst_components/tst_actionitem.qml (+84/-0) |
To merge this branch: | bzr merge lp:~tpeeters/ubuntu-ui-toolkit/actionItem |
Related bugs: | |
Related blueprints: |
Unified Action API in the Ubunt UI toolkit
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zsombor Egri | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+169039@code.launchpad.net |
Commit message
Add ActionItem component that copies the Action API, but adds a visual representation of the Action.
Description of the change
Add ActionItem component that copies the Action API, but adds a visual representation of the Action.
Action API will be simplified (remove itemHint, visible, update triggered) later (in separate MRs) when there is a new way to define tools for the toolbar using ActionItems.
Tim Peeters (tpeeters) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:557
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 558. By Tim Peeters
-
merge toolsItem branch
- 559. By Tim Peeters
-
empty change
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:558
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:559
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 560. By Tim Peeters
-
merge toolsItem branch
- 561. By Tim Peeters
-
fix iconSource test
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:560
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 562. By Tim Peeters
-
re-trigger jenkins test
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:561
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:562
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 563. By Tim Peeters
-
merge trunk
- 564. By Tim Peeters
-
update comment
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:564
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Zsombor Egri (zsombi) wrote : | # |
got it now the reason why this step was made.
Preview Diff
1 | === modified file 'components.api' |
2 | --- components.api 2013-06-13 08:56:42 +0000 |
3 | +++ components.api 2013-06-13 12:43:26 +0000 |
4 | @@ -1,6 +1,5 @@ |
5 | modules/Ubuntu/Components/AbstractButton.qml |
6 | -Item |
7 | - property Action action |
8 | +ActionItem |
9 | signal clicked() |
10 | signal pressAndHold() |
11 | property bool pressed |
12 | @@ -15,6 +14,12 @@ |
13 | property bool visible |
14 | property bool enabled |
15 | property Component itemHint |
16 | +modules/Ubuntu/Components/ActionItem.qml |
17 | +Item |
18 | + property Action action |
19 | + property string text |
20 | + property url iconSource |
21 | + signal triggered(var caller) |
22 | modules/Ubuntu/Components/ActionList.qml |
23 | QtObject |
24 | default property alias children |
25 | @@ -28,8 +33,6 @@ |
26 | modules/Ubuntu/Components/Button.qml |
27 | AbstractButton |
28 | property color color |
29 | - property url iconSource |
30 | - property string text |
31 | property string iconPosition |
32 | modules/Ubuntu/Components/CheckBox.qml |
33 | AbstractButton |
34 | |
35 | === modified file 'modules/Ubuntu/Components/AbstractButton.qml' |
36 | --- modules/Ubuntu/Components/AbstractButton.qml 2013-05-28 12:37:56 +0000 |
37 | +++ modules/Ubuntu/Components/AbstractButton.qml 2013-06-13 12:43:26 +0000 |
38 | @@ -27,18 +27,15 @@ |
39 | This class defines the behavior of the button: it defines the MouseArea |
40 | and the states. |
41 | */ |
42 | -Item { |
43 | +ActionItem { |
44 | id: button |
45 | |
46 | /*! |
47 | If an action is specified, the button's clicked signal will trigger the action. |
48 | Subclasses of AbstractButton can use other properties of action (for example |
49 | the text and iconSource). |
50 | + \qmlproperty Action action |
51 | */ |
52 | - property Action action: null |
53 | - |
54 | - visible: action ? action.visible : true |
55 | - enabled: action ? action.enabled : true |
56 | |
57 | /*! |
58 | This handler is called when there is a mouse click on the button |
59 | @@ -48,10 +45,9 @@ |
60 | signal clicked() |
61 | |
62 | /*! |
63 | - If \l action was set, action.triggered() is automatically called with |
64 | - the AbstractButton as parameter. |
65 | + If a button is clicked, its triggered() signal will automatically be called. |
66 | */ |
67 | - onClicked: if (action) action.triggered(button) |
68 | + onClicked: button.triggered(button) |
69 | |
70 | Keys.onEnterPressed: clicked() |
71 | Keys.onReturnPressed: clicked() |
72 | |
73 | === added file 'modules/Ubuntu/Components/ActionItem.qml' |
74 | --- modules/Ubuntu/Components/ActionItem.qml 1970-01-01 00:00:00 +0000 |
75 | +++ modules/Ubuntu/Components/ActionItem.qml 2013-06-13 12:43:26 +0000 |
76 | @@ -0,0 +1,66 @@ |
77 | +/* |
78 | + * Copyright 2012 Canonical Ltd. |
79 | + * |
80 | + * This program is free software; you can redistribute it and/or modify |
81 | + * it under the terms of the GNU Lesser General Public License as published by |
82 | + * the Free Software Foundation; version 3. |
83 | + * |
84 | + * This program is distributed in the hope that it will be useful, |
85 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
86 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
87 | + * GNU Lesser General Public License for more details. |
88 | + * |
89 | + * You should have received a copy of the GNU Lesser General Public License |
90 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
91 | + */ |
92 | + |
93 | +import QtQuick 2.0 |
94 | + |
95 | +/*! |
96 | + \qmlabstract ActionItem |
97 | + \inqmlmodule Ubuntu.Components 0.1 |
98 | + \ingroup ubuntu |
99 | + \brief A visual representation of an Action. The API of ActionItem is a |
100 | + copy of the API of \l Action, with additional properties to define |
101 | + visual aspects of the ActionItem. |
102 | + |
103 | + If \l action is set, the values of the other properties will by default |
104 | + be identical to the \l Action's property values. |
105 | +*/ |
106 | +Item { |
107 | + id: actionItem |
108 | + |
109 | + /*! |
110 | + The \l Action associated with this ActionItem. If action is set, |
111 | + the values of the Action properties are copied to the values of |
112 | + the ActionItem properties. |
113 | + */ |
114 | + property Action action: null |
115 | + |
116 | + // TODO: remove visible from action when we start using ActionItems |
117 | + // to define the toolbar contents. |
118 | + visible: action ? action.visible : true |
119 | + enabled: action ? action.enabled : true |
120 | + |
121 | + /*! |
122 | + The title of the actionItem. |
123 | + Default value: action.text |
124 | + */ |
125 | + property string text: action ? action.text : "" |
126 | + |
127 | + /*! |
128 | + The image associated with the actionItem. |
129 | + Default value: action.iconSource. |
130 | + */ |
131 | + property url iconSource: action ? action.iconSource : "" |
132 | + |
133 | + /*! |
134 | + Called when the actionItem is triggered. |
135 | + */ |
136 | + signal triggered(var caller) |
137 | + |
138 | + /*! |
139 | + If \l action is set, this will call action.trigger(caller). |
140 | + */ |
141 | + onTriggered: if (action) action.triggered(caller) |
142 | +} |
143 | |
144 | === modified file 'modules/Ubuntu/Components/Button.qml' |
145 | --- modules/Ubuntu/Components/Button.qml 2013-05-29 12:42:41 +0000 |
146 | +++ modules/Ubuntu/Components/Button.qml 2013-06-13 12:43:26 +0000 |
147 | @@ -49,7 +49,7 @@ |
148 | } |
149 | } |
150 | \endqml |
151 | - An \l Action can be used to specify \b clicked, \l iconSource and \l text. Example: |
152 | + An \l Action can be used to specify \b clicked, iconSource and text. Example: |
153 | \qml |
154 | Item { |
155 | Action { |
156 | @@ -83,16 +83,16 @@ |
157 | The source URL of the icon to display inside the button. |
158 | Leave this value blank for a text-only button. |
159 | If \l action is set, the default iconSource is that of the action. |
160 | + \qmlproperty url iconSource |
161 | */ |
162 | - property url iconSource: action ? action.iconSource : "" |
163 | |
164 | /*! |
165 | The text to display in the button. If an icon was defined, |
166 | the text will be shown next to the icon, otherwise it will |
167 | be centered. Leave blank for an icon-only button. |
168 | If \l action is set, the default text is that of the action. |
169 | + \qmlproperty string text |
170 | */ |
171 | - property string text: action ? action.text : undefined |
172 | |
173 | /*! |
174 | The position of the icon relative to the text. Options |
175 | |
176 | === modified file 'modules/Ubuntu/Components/ListItems/Empty.qml' |
177 | --- modules/Ubuntu/Components/ListItems/Empty.qml 2013-05-19 19:03:44 +0000 |
178 | +++ modules/Ubuntu/Components/ListItems/Empty.qml 2013-06-13 12:43:26 +0000 |
179 | @@ -89,11 +89,6 @@ |
180 | property bool highlightWhenPressed: true |
181 | |
182 | /*! |
183 | - The property holds the attached action to the list item. |
184 | - */ |
185 | - property Action action |
186 | - |
187 | - /*! |
188 | \preliminary |
189 | Defines if this item can be removed or not. |
190 | */ |
191 | |
192 | === modified file 'modules/Ubuntu/Components/ListItems/MultiValue.qml' |
193 | --- modules/Ubuntu/Components/ListItems/MultiValue.qml 2013-02-01 12:00:30 +0000 |
194 | +++ modules/Ubuntu/Components/ListItems/MultiValue.qml 2013-06-13 12:43:26 +0000 |
195 | @@ -50,7 +50,6 @@ |
196 | The text that is shown in the list item as a label. |
197 | \qmlproperty string text |
198 | */ |
199 | - property alias text: label.text |
200 | |
201 | /*! |
202 | \preliminary |
203 | @@ -73,6 +72,7 @@ |
204 | left: parent.left |
205 | right: parent.right |
206 | } |
207 | + text: multiValueListItem.text |
208 | } |
209 | LabelVisual { |
210 | id: valueLabel |
211 | |
212 | === modified file 'modules/Ubuntu/Components/ListItems/SingleValue.qml' |
213 | --- modules/Ubuntu/Components/ListItems/SingleValue.qml 2013-05-19 19:03:44 +0000 |
214 | +++ modules/Ubuntu/Components/ListItems/SingleValue.qml 2013-06-13 12:43:26 +0000 |
215 | @@ -52,7 +52,6 @@ |
216 | The text that is shown in the list item as a label. |
217 | \qmlproperty string text |
218 | */ |
219 | - property alias text: label.text |
220 | |
221 | /*! |
222 | \preliminary |
223 | @@ -68,6 +67,7 @@ |
224 | verticalCenter: parent.verticalCenter |
225 | left: parent.left |
226 | } |
227 | + text: listItem.text |
228 | width: Math.min(implicitWidth, parent.width * 0.8) |
229 | } |
230 | LabelVisual { |
231 | |
232 | === modified file 'modules/Ubuntu/Components/ListItems/Standard.qml' |
233 | --- modules/Ubuntu/Components/ListItems/Standard.qml 2013-05-24 09:12:56 +0000 |
234 | +++ modules/Ubuntu/Components/ListItems/Standard.qml 2013-06-13 12:43:26 +0000 |
235 | @@ -84,7 +84,6 @@ |
236 | The text that is shown in the list item as a label. |
237 | \qmlproperty string text |
238 | */ |
239 | - property alias text: label.text |
240 | |
241 | /*! |
242 | \preliminary |
243 | @@ -240,6 +239,7 @@ |
244 | right: control ? controlContainer.left : (progression ? progressionHelper.left : parent.right) |
245 | rightMargin: listItem.__contentsMargins |
246 | } |
247 | + text: listItem.text |
248 | } |
249 | |
250 | Item { |
251 | |
252 | === modified file 'modules/Ubuntu/Components/ListItems/ValueSelector.qml' |
253 | --- modules/Ubuntu/Components/ListItems/ValueSelector.qml 2013-05-14 13:33:39 +0000 |
254 | +++ modules/Ubuntu/Components/ListItems/ValueSelector.qml 2013-06-13 12:43:26 +0000 |
255 | @@ -63,7 +63,6 @@ |
256 | The text that is shown in the list item as a label. |
257 | \qmlproperty string text |
258 | */ |
259 | - property alias text: label.text |
260 | |
261 | /*! |
262 | \preliminary |
263 | @@ -159,6 +158,7 @@ |
264 | verticalCenter: parent.verticalCenter |
265 | left: parent.left |
266 | } |
267 | + text: selector.text |
268 | width: Math.min(implicitWidth, parent.width * 0.8) |
269 | } |
270 | LabelVisual { |
271 | |
272 | === modified file 'modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml' |
273 | --- modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml 2013-05-13 10:14:24 +0000 |
274 | +++ modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml 2013-06-13 12:43:26 +0000 |
275 | @@ -100,7 +100,6 @@ |
276 | /*! |
277 | The property holds the list of actions to be presented. Each action |
278 | triggered will use the actionHost as caller. |
279 | - |
280 | */ |
281 | property var actions |
282 | |
283 | @@ -110,15 +109,17 @@ |
284 | to access action data. |
285 | */ |
286 | property Component delegate: Empty { |
287 | - visible: action.visible && action.text !== "" |
288 | + id: listItem |
289 | Label { |
290 | - text: action.text |
291 | + text: listItem.text |
292 | anchors { |
293 | verticalCenter: parent.verticalCenter |
294 | horizontalCenter: parent.horizontalCenter |
295 | } |
296 | wrapMode: Text.Wrap |
297 | } |
298 | + /*! \internal */ |
299 | + onTriggered: popover.hide() |
300 | } |
301 | |
302 | grabDismissAreaEvents: false |
303 | @@ -151,22 +152,11 @@ |
304 | if (item.hasOwnProperty("modelData")) |
305 | item.modelData = modelData; |
306 | // auto-connect trigger |
307 | - // FIXME: define all these signals to the action to be in sync with HUD |
308 | - if (item.hasOwnProperty("clicked")) |
309 | - item.clicked.connect(triggerAction); |
310 | - else if (item.hasOwnProperty("accepted")) |
311 | - item.accepted.connect(triggerAction); |
312 | - else if (item.hasOwnProperty("triggered")) |
313 | - item.triggered.connect(triggerAction); |
314 | // if the delegate is a list item, hide divider of the last one |
315 | if (item.hasOwnProperty("showDivider")) |
316 | item.showDivider = index < (repeater.count - 1); |
317 | } |
318 | } |
319 | - function triggerAction() { |
320 | - modelData.triggered(target); |
321 | - popover.hide(); |
322 | - } |
323 | } |
324 | } |
325 | } |
326 | |
327 | === modified file 'modules/Ubuntu/Components/qmldir' |
328 | --- modules/Ubuntu/Components/qmldir 2013-05-20 13:39:43 +0000 |
329 | +++ modules/Ubuntu/Components/qmldir 2013-06-13 12:43:26 +0000 |
330 | @@ -1,6 +1,7 @@ |
331 | module Ubuntu.Components |
332 | plugin UbuntuComponents |
333 | Action 0.1 Action.qml |
334 | +ActionItem 0.1 ActionItem.qml |
335 | ActionList 0.1 ActionList.qml |
336 | ToolbarActions 0.1 ToolbarActions.qml |
337 | MainView 0.1 MainView.qml |
338 | |
339 | === added file 'tests/unit/tst_components/tst_actionitem.qml' |
340 | --- tests/unit/tst_components/tst_actionitem.qml 1970-01-01 00:00:00 +0000 |
341 | +++ tests/unit/tst_components/tst_actionitem.qml 2013-06-13 12:43:26 +0000 |
342 | @@ -0,0 +1,84 @@ |
343 | +/* |
344 | + * Copyright 2012 Canonical Ltd. |
345 | + * |
346 | + * This program is free software; you can redistribute it and/or modify |
347 | + * it under the terms of the GNU Lesser General Public License as published by |
348 | + * the Free Software Foundation; version 3. |
349 | + * |
350 | + * This program is distributed in the hope that it will be useful, |
351 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
352 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
353 | + * GNU Lesser General Public License for more details. |
354 | + * |
355 | + * You should have received a copy of the GNU Lesser General Public License |
356 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
357 | + */ |
358 | + |
359 | +import QtQuick 2.0 |
360 | +import QtTest 1.0 |
361 | +import Ubuntu.Components 0.1 |
362 | + |
363 | +TestCase { |
364 | + name: "ActionItemAPI" |
365 | + |
366 | + function initTestCase() { |
367 | + compare(item1.action, null, "action is null by default") |
368 | + compare(item1.text, "", "text is empty string set by default") |
369 | + compare(item1.iconSource, "", "iconSource is empty string by default") |
370 | + } |
371 | + |
372 | + function test_action() { |
373 | + compare(item1.action, null,"Action is null by default") |
374 | + item1.action = action1 |
375 | + compare(item1.action, action1, "Action can be set") |
376 | + compare(item1.text, action1.text, "text is automatically set to action text") |
377 | + compare(item1.iconSource, action1.iconSource, "iconSource is automatically set to action iconSource") |
378 | + var numTriggers = action1.triggerCount |
379 | + item1.triggered(null) |
380 | + compare(action1.triggerCount, numTriggers+1, "ActionItem triggered() triggers action") |
381 | + item1.action = null |
382 | + } |
383 | + |
384 | + // NOTE: This test must be run AFTER test_action(), otherwise setting the action will |
385 | + // not update the text |
386 | + function test_text() { |
387 | + compare(item1.text, "", "text is empty string by default") |
388 | + var newText = "new text" |
389 | + item1.text = newText |
390 | + compare(item1.text, newText, "text can be set") |
391 | + item1.text = "" |
392 | + compare(item1.text, "", "text can be unset") |
393 | + } |
394 | + |
395 | + // NOTE: This test must be run AFTER test_action(), otherwise setting the action will |
396 | + // will not update the iconSource |
397 | + function test_iconSource() { |
398 | + compare(item1.iconSource, "", "iconSource is empty string by default") |
399 | + var newIconSource = "../../../examples/ubuntu-ui-toolkit-gallery/small_avatar.png" |
400 | + item1.iconSource = newIconSource |
401 | + compare(item1.iconSource, Qt.resolvedUrl(newIconSource), "iconSource can be set") |
402 | + item1.iconSource = "" |
403 | + compare(item1.iconSource, "", "iconSource can be unset") |
404 | + } |
405 | + |
406 | + function test_signal_triggered() { |
407 | + signalSpy.signalName = "triggered"; |
408 | + compare(signalSpy.valid,true,"triggered signal exists") |
409 | + } |
410 | + |
411 | + ActionItem { |
412 | + id: item1 |
413 | + SignalSpy { |
414 | + id: signalSpy |
415 | + target: parent |
416 | + } |
417 | + } |
418 | + |
419 | + Action { |
420 | + id: action1 |
421 | + text: "actionText" |
422 | + iconSource: "imageURL" |
423 | + property int triggerCount: 0 |
424 | + onTriggered: triggerCount++ |
425 | + } |
426 | +} |
Don't approve until https:/ /code.launchpad .net/~tpeeters/ ubuntu- ui-toolkit/ toolsItem/ +merge/ 168932 is merged.