Merge lp:~aacid/unity8/icon-actions into lp:unity8

Proposed by Albert Astals Cid on 2015-07-06
Status: Merged
Approved by: Andrea Cimitan on 2015-07-08
Approved revision: 1847
Merged at revision: 1873
Proposed branch: lp:~aacid/unity8/icon-actions
Merge into: lp:unity8
Diff against target: 231 lines (+200/-0)
4 files modified
qml/Dash/Previews/PreviewIconActions.qml (+72/-0)
qml/Dash/Previews/PreviewWidgetFactory.qml (+1/-0)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/Previews/tst_PreviewIconActions.qml (+126/-0)
To merge this branch: bzr merge lp:~aacid/unity8/icon-actions
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-07-15
Andrea Cimitan (community) 2015-07-06 Approve on 2015-07-08
Review via email: mp+263909@code.launchpad.net

Commit Message

icon-actions preview widget

Description of the Change

 * Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
sizes and behaviour are agreed by design

To post a comment you must log in.
lp:~aacid/unity8/icon-actions updated on 2015-07-06
1847. By Albert Astals Cid on 2015-07-06

Don't live in the past yo!

Andrea Cimitan (cimi) :
review: Needs Fixing
lp:~aacid/unity8/icon-actions updated on 2015-07-08
1848. By Albert Astals Cid on 2015-07-08

use row.actoins

1849. By Albert Astals Cid on 2015-07-08

sourcesize the icon

Albert Astals Cid (aacid) wrote :

> I'm missing where this is needed... maybe you wanted to add this check for the model of the repeater?
Yes, done

> sourceSize?
Added

> do we want those two logs?
Yeah, helps with manual testing (i.e. "make tryPreviewIconActions")

lp:~aacid/unity8/icon-actions updated on 2015-07-08
1850. By Albert Astals Cid on 2015-07-08

implicitHeight is better, thanks Cimi!

1851. By Albert Astals Cid on 2015-07-08

Make Cimi happy

1852. By Albert Astals Cid on 2015-07-08

Cimi wants more if

Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes
 * Did CI run pass? If not, please explain why.
ap
 * Did you make sure that the branch does not contain spurious tags?
yeah

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'qml/Dash/Previews/PreviewIconActions.qml'
2--- qml/Dash/Previews/PreviewIconActions.qml 1970-01-01 00:00:00 +0000
3+++ qml/Dash/Previews/PreviewIconActions.qml 2015-07-08 12:53:05 +0000
4@@ -0,0 +1,72 @@
5+/*
6+ * Copyright (C) 2015 Canonical, Ltd.
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+import QtQuick 2.1
22+import Ubuntu.Components 1.1
23+
24+/*! This preview widget icons+label for number of items in widgetData["actions"].
25+ * For each of the items we recognize the fields "label", "icon", "temporaryIcon" and "id".
26+ * temporaryIcon is the icon that will be shown just after the user presses icon until the
27+ * scope refreshes the preview
28+ */
29+
30+PreviewWidget {
31+ id: root
32+
33+ implicitHeight: row.height
34+
35+ Row {
36+ id: row
37+ readonly property var actions: root.widgetData ? root.widgetData["actions"] : null
38+ width: parent.width
39+
40+ spacing: units.gu(2)
41+
42+ Repeater {
43+ model: row.actions
44+
45+ AbstractButton {
46+ objectName: "button" + modelData.id
47+ height: label.height
48+ width: childrenRect.width
49+
50+ Image {
51+ id: icon
52+ height: parent.height
53+ width: height
54+ source: modelData.icon
55+ sourceSize { width: icon.width; height: icon.height }
56+ }
57+
58+ Label {
59+ id: label
60+ anchors.left: icon.right
61+ anchors.leftMargin: visible ? units.gu(0.5) : 0
62+ text: modelData.label
63+ visible: text !== ""
64+ }
65+
66+ onClicked: {
67+ if (modelData.temporaryIcon) {
68+ icon.source = modelData.temporaryIcon;
69+ }
70+ root.triggered(root.widgetId, modelData.id, modelData);
71+ }
72+ }
73+ }
74+ }
75+
76+}
77
78=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
79--- qml/Dash/Previews/PreviewWidgetFactory.qml 2015-05-08 13:12:02 +0000
80+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2015-07-08 12:53:05 +0000
81@@ -53,6 +53,7 @@
82 case "expandable": return "PreviewExpandable.qml";
83 case "gallery": return "PreviewImageGallery.qml";
84 case "header": return "PreviewHeader.qml";
85+ case "icon-actions": return "PreviewIconActions.qml";
86 case "image": return "PreviewZoomableImage.qml";
87 case "progress": return "PreviewProgress.qml";
88 case "payments": return "PreviewPayments.qml";
89
90=== modified file 'tests/qmltests/CMakeLists.txt'
91--- tests/qmltests/CMakeLists.txt 2015-06-18 19:23:08 +0000
92+++ tests/qmltests/CMakeLists.txt 2015-07-08 12:53:05 +0000
93@@ -29,6 +29,7 @@
94 add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
95 add_unity8_qmltest(Dash/Previews PreviewExpandable)
96 add_unity8_qmltest(Dash/Previews PreviewHeader)
97+add_unity8_qmltest(Dash/Previews PreviewIconActions)
98 add_unity8_qmltest(Dash/Previews PreviewImageGallery)
99 add_unity8_qmltest(Dash/Previews PreviewPayments)
100 add_unity8_qmltest(Dash/Previews PreviewProgress)
101
102=== added file 'tests/qmltests/Dash/Previews/tst_PreviewIconActions.qml'
103--- tests/qmltests/Dash/Previews/tst_PreviewIconActions.qml 1970-01-01 00:00:00 +0000
104+++ tests/qmltests/Dash/Previews/tst_PreviewIconActions.qml 2015-07-08 12:53:05 +0000
105@@ -0,0 +1,126 @@
106+/*
107+ * Copyright 2015 Canonical Ltd.
108+ *
109+ * This program is free software; you can redistribute it and/or modify
110+ * it under the terms of the GNU General Public License as published by
111+ * the Free Software Foundation; version 3.
112+ *
113+ * This program is distributed in the hope that it will be useful,
114+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
115+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
116+ * GNU General Public License for more details.
117+ *
118+ * You should have received a copy of the GNU General Public License
119+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
120+ */
121+
122+import QtQuick 2.0
123+import QtTest 1.0
124+import "../../../../qml/Dash/Previews"
125+import Unity.Test 0.1 as UT
126+import Ubuntu.Components 0.1
127+
128+
129+Rectangle {
130+ id: root
131+ width: units.gu(60)
132+ height: units.gu(80)
133+
134+ property var actionDataActions: {
135+ "actions": [{"label": "10", "id": "someid", "icon": Qt.resolvedUrl("../artwork/avatar@12.png"), "temporaryIcon": Qt.resolvedUrl("../artwork/emblem.png")},
136+ {"label": "12", "id": "someid2", "icon": Qt.resolvedUrl("../artwork/checkers.png"), "temporaryIcon": Qt.resolvedUrl("../artwork/background.png")},
137+ {"label": "", "id": "someid3", "icon": Qt.resolvedUrl("../artwork/music-player-design.png")},
138+ ]
139+ }
140+
141+ SignalSpy {
142+ id: spy
143+ signalName: "triggered"
144+ }
145+
146+ PreviewIconActions {
147+ id: preview
148+ widgetId: "iconActions"
149+ widgetData: actionDataActions
150+ onTriggered: {
151+ if (timer.index !== -1) {
152+ if (!testcase.running) {
153+ console.log("Processing other click, ignoring");
154+ }
155+ return;
156+ }
157+
158+ for (var i in actionDataActions.actions) {
159+ if (actionId == actionDataActions.actions[i].id) {
160+ timer.index = i;
161+ break;
162+ }
163+ }
164+
165+ timer.start();
166+ if (!testcase.running) {
167+ console.log("triggered", widgetId, actionId);
168+ }
169+ }
170+ width: parent.width
171+ clip: true
172+ }
173+
174+ Timer {
175+ id: timer
176+ property int index: -1
177+ interval: 500
178+ onTriggered: {
179+ actionDataActions.actions[index].icon = Qt.resolvedUrl("../../UnityLogo.png");
180+ preview.widgetDataChanged();
181+ index = -1;
182+ }
183+ }
184+
185+ UT.UnityTestCase {
186+ id: testcase
187+ name: "PreviewIconActionTest"
188+ when: windowShown
189+
190+ function cleanup()
191+ {
192+ spy.clear();
193+ }
194+
195+ function test_checkButtonWithTemporary_data() {
196+ return [
197+ {tag: "with temporary", temporaryIcon: "emblem", index: 0},
198+ {tag: "without temporary", temporaryIcon: undefined, index: 2},
199+ ];
200+ }
201+
202+ function test_checkButtonWithTemporary(data) {
203+ spy.target = preview;
204+
205+ var buttonId = actionDataActions.actions[data.index].id;
206+ var buttonIcon = actionDataActions.actions[data.index].icon;
207+ var buttonTemporaryIcon = actionDataActions.actions[data.index]["temporaryIcon"];
208+ var buttonLabel = actionDataActions.actions[data.index].label;
209+
210+ var button = findChild(root, "button" + buttonId);
211+ var image = findChildsByType(button, "QQuickImage")[0];
212+ var label = findChildsByType(button, "Label")[0];
213+
214+ compare(image.source, buttonIcon);
215+ compare(label.text, buttonLabel);
216+ mouseClick(button);
217+ compare(spy.count, 1);
218+ compare(spy.signalArguments[0][1], buttonId);
219+
220+ if (buttonTemporaryIcon) {
221+ compare(image.source, buttonTemporaryIcon);
222+ }
223+
224+ tryCompareFunction(function() {
225+ var button = findChild(root, "button" + buttonId);
226+ var image = findChildsByType(button, "QQuickImage")[0];
227+ return image.source && image.source.toString().indexOf("UnityLogo") > -1;
228+ }, true);
229+ }
230+ }
231+}

Subscribers

People subscribed via source and target branches