Merge lp:~zsombi/ubuntu-ui-toolkit/fixActionListTrunk into lp:ubuntu-ui-toolkit

Proposed by Zsombor Egri
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 1356
Merged at revision: 1356
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/fixActionListTrunk
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 196 lines (+95/-25)
5 files modified
components.api (+2/-1)
src/Ubuntu/UbuntuToolkit/actionlist.cpp (+3/-0)
src/Ubuntu/UbuntuToolkit/actionlist_p.h (+4/-1)
tests/unit/components/tst_action.qml (+0/-23)
tests/unit/visual/tst_actionlist.13.qml (+86/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/fixActionListTrunk
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) Approve
Zoltan Balogh Approve
Review via email: mp+305845@code.launchpad.net

Commit message

Fix ActionList API break.

Description of the change

Fix ActionList API break.

To post a comment you must log in.
Revision history for this message
Zoltan Balogh (bzoltan) :
review: Approve
Revision history for this message
Olivier Tilloy (osomon) wrote :

Fixes webbrowser-app context menus and its unit tests.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components.api'
--- components.api 2016-08-22 16:01:43 +0000
+++ components.api 2016-09-15 15:12:08 +0000
@@ -64,7 +64,8 @@
64 property list<Action> actions64 property list<Action> actions
65 default property list<Action> children65 default property list<Action> children
66Ubuntu.Components.ActionList 1.3 ActionList: QtObject66Ubuntu.Components.ActionList 1.3 ActionList: QtObject
67 default property list<Action> actions67 property list<Action> actions
68 default property list<Action> children
68 signal added(Action action)69 signal added(Action action)
69 signal removed(Action action)70 signal removed(Action action)
70 function addAction(Action action)71 function addAction(Action action)
7172
=== modified file 'src/Ubuntu/UbuntuToolkit/actionlist.cpp'
--- src/Ubuntu/UbuntuToolkit/actionlist.cpp 2016-07-18 14:54:46 +0000
+++ src/Ubuntu/UbuntuToolkit/actionlist.cpp 2016-09-15 15:12:08 +0000
@@ -79,6 +79,7 @@
79 }79 }
80 m_actions.append(action);80 m_actions.append(action);
81 Q_EMIT added(action);81 Q_EMIT added(action);
82 Q_EMIT childrenChanged();
82}83}
8384
84/*!85/*!
@@ -94,6 +95,7 @@
94 }95 }
95 if (m_actions.removeOne(action)) {96 if (m_actions.removeOne(action)) {
96 Q_EMIT removed(action);97 Q_EMIT removed(action);
98 Q_EMIT childrenChanged();
97 }99 }
98}100}
99101
@@ -134,6 +136,7 @@
134 ActionList *actionList = qobject_cast<ActionList*>(list->object);136 ActionList *actionList = qobject_cast<ActionList*>(list->object);
135 if (actionList) {137 if (actionList) {
136 actionList->m_actions.clear();138 actionList->m_actions.clear();
139 Q_EMIT actionList->childrenChanged();
137 }140 }
138}141}
139142
140143
=== modified file 'src/Ubuntu/UbuntuToolkit/actionlist_p.h'
--- src/Ubuntu/UbuntuToolkit/actionlist_p.h 2016-07-18 14:54:46 +0000
+++ src/Ubuntu/UbuntuToolkit/actionlist_p.h 2016-09-15 15:12:08 +0000
@@ -28,7 +28,9 @@
28{28{
29 Q_OBJECT29 Q_OBJECT
30 Q_PROPERTY(QQmlListProperty<UT_PREPEND_NAMESPACE(UCAction)> actions READ actions)30 Q_PROPERTY(QQmlListProperty<UT_PREPEND_NAMESPACE(UCAction)> actions READ actions)
31 Q_CLASSINFO("DefaultProperty", "actions")31 // children alias
32 Q_PROPERTY(QQmlListProperty<UT_PREPEND_NAMESPACE(UCAction)> children READ actions NOTIFY childrenChanged)
33 Q_CLASSINFO("DefaultProperty", "children")
32public:34public:
33 explicit ActionList(QObject *parent = 0);35 explicit ActionList(QObject *parent = 0);
3436
@@ -41,6 +43,7 @@
41 void removeAction(UT_PREPEND_NAMESPACE(UCAction) *action);43 void removeAction(UT_PREPEND_NAMESPACE(UCAction) *action);
4244
43Q_SIGNALS:45Q_SIGNALS:
46 void childrenChanged();
44 void added(UCAction *action);47 void added(UCAction *action);
45 void removed(UCAction *action);48 void removed(UCAction *action);
4649
4750
=== modified file 'tests/unit/components/tst_action.qml'
--- tests/unit/components/tst_action.qml 2016-06-24 13:07:32 +0000
+++ tests/unit/components/tst_action.qml 2016-09-15 15:12:08 +0000
@@ -185,17 +185,6 @@
185 compare(checkableAction.checked, false, "Non-checkable action should never be checked");185 compare(checkableAction.checked, false, "Non-checkable action should never be checked");
186 }186 }
187187
188 function test_actionlist() {
189 verify(actionList.actions.length, 2, "Default actions not added to actionList");
190 }
191
192 function test_actionlist_dynamic_actions() {
193 actionList.addAction(dynamicListAction);
194 verify(actionList.actions.length, 3, "Dynamic action not added to actionList");
195 actionList.removeAction(dynamicListAction);
196 verify(actionList.actions.length, 2, "Dynamic action not remove from actionList");
197 }
198
199 function test_exclusive_group() {188 function test_exclusive_group() {
200 compare(exclusiveGroup.actions.length, 3, "Incorrect number of actions");189 compare(exclusiveGroup.actions.length, 3, "Incorrect number of actions");
201 }190 }
@@ -311,18 +300,6 @@
311 checkable: true300 checkable: true
312 }301 }
313302
314 ActionList {
315 id: actionList
316 Action {
317 }
318 Action {
319 }
320 }
321
322 Action {
323 id: dynamicListAction
324 }
325
326 ExclusiveGroup {303 ExclusiveGroup {
327 id: exclusiveGroup304 id: exclusiveGroup
328 Action {305 Action {
329306
=== added file 'tests/unit/visual/tst_actionlist.13.qml'
--- tests/unit/visual/tst_actionlist.13.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/visual/tst_actionlist.13.qml 2016-09-15 15:12:08 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtTest 1.0
18import Ubuntu.Test 1.3
19import Ubuntu.Components 1.3
20import QtQuick 2.4
21import Ubuntu.Components.Popups 1.3
22
23Button {
24 id: root
25 width: units.gu(50)
26 height: units.gu(50)
27
28 property Item popup: null
29
30 Component {
31 id: menuFactory
32 ActionSelectionPopover {
33 delegate: ListItemLayout {
34 property Action action
35 title.text: action.text
36 }
37
38 actions: ActionList {
39 Action {
40 objectName: "foo"
41 text: "foo"
42 }
43 Action {
44 objectName: "bar"
45 text: "bar"
46 }
47 }
48 }
49 }
50 onClicked: popup = PopupUtils.open(menuFactory, root)
51
52 ActionList {
53 id: actionList
54 Action {
55 }
56 Action {
57 }
58 }
59
60 Action {
61 id: dynamicListAction
62 }
63
64 UbuntuTestCase {
65 when: windowShown
66
67 function test_actionlist() {
68 verify(actionList.actions.length, 2, "Default actions not added to actionList");
69 }
70
71 function test_actionlist_dynamic_actions() {
72 actionList.addAction(dynamicListAction);
73 verify(actionList.actions.length, 3, "Dynamic action not added to actionList");
74 actionList.removeAction(dynamicListAction);
75 verify(actionList.actions.length, 2, "Dynamic action not remove from actionList");
76 }
77
78 function test_bug1623841() {
79 mouseClick(root, centerOf(root).x, centerOf(root).y);
80 waitForRendering(root.popup, 500);
81 // check if the delegates are shown
82 verify(findChild(root.popup, "foo_button"));
83 verify(findChild(root.popup, "bar_button"));
84 }
85 }
86}

Subscribers

People subscribed via source and target branches

to status/vote changes: