Merge lp:~zsombi/ubuntu-ui-toolkit/40-visualize-options into lp:~zsombi/ubuntu-ui-toolkit/listitem-master

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: 1293
Merged at revision: 1273
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/40-visualize-options
Merge into: lp:~zsombi/ubuntu-ui-toolkit/listitem-master
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/35-options-panel-swipe
Diff against target: 511 lines (+220/-34)
9 files modified
components.api (+2/-2)
modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml (+77/-3)
modules/Ubuntu/Components/plugin/uclistitem.cpp (+44/-10)
modules/Ubuntu/Components/plugin/uclistitem.h (+5/-6)
modules/Ubuntu/Components/plugin/uclistitem_p.h (+3/-0)
modules/Ubuntu/Components/plugin/uclistitemactionsattached.cpp (+1/-0)
modules/Ubuntu/Components/plugin/ucstyleditembase.cpp (+2/-4)
tests/resources/listitems/ListItemTest.qml (+41/-5)
tests/unit_x11/tst_components/tst_listitem.qml (+45/-4)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/40-visualize-options
Reviewer Review Type Date Requested Status
Tim Peeters Approve
Review via email: mp+235166@code.launchpad.net
To post a comment you must log in.
1256. By Zsombor Egri

prereq sync

1257. By Zsombor Egri

prereq sync

1258. By Zsombor Egri

prereq sync

1259. By Zsombor Egri

prereq sync

1260. By Zsombor Egri

prereq sync

1261. By Zsombor Egri

prereq sync

1262. By Zsombor Egri

prereq sync

1263. By Zsombor Egri

prereq sync

1264. By Zsombor Egri

prereq sync

1265. By Zsombor Egri

prereq sync

1266. By Zsombor Egri

prereq sync

1267. By Zsombor Egri

prereq sync

1268. By Zsombor Egri

prereq sync

1269. By Zsombor Egri

disabled actions are shown 50% dimmed

1270. By Zsombor Egri

prereq sync

1271. By Zsombor Egri

prereq sync

1272. By Zsombor Egri

fixing panel and test app due to prereq changes

1273. By Zsombor Egri

small fixes

1274. By Zsombor Egri

prereq sync

1275. By Zsombor Egri

prereq sync

1276. By Zsombor Egri

test fixed

1277. By Zsombor Egri

prereq sync

1278. By Zsombor Egri

prereq sync

1279. By Zsombor Egri

tests added

Revision history for this message
Zsombor Egri (zsombi) wrote :

ListItem's data and child properties had to be renamed as findChild()/findInvisibleChild() won't find the panel item anymore.

1280. By Zsombor Egri

API updated

1281. By Zsombor Egri

prereq sync

1282. By Zsombor Egri

prereq sync

1283. By Zsombor Egri

use correct signal to forward children changes

1284. By Zsombor Egri

prereq sync

1285. By Zsombor Egri

prereq sync

1286. By Zsombor Egri

prereq sync

1287. By Zsombor Egri

prereq sync

1288. By Zsombor Egri

ListItemPanel fixes

Revision history for this message
Tim Peeters (tpeeters) wrote :

I am testing with this test program https://code.launchpad.net/~tpeeters/+junk/lists and I see the following potential UX problems:
- When I swipe left/right, and then release the mouse button, the list item stays exactly where it was, see https://www.dropbox.com/s/iinpzauwtm7hhsn/Screenshot%202014-11-24%2015.23.47.png?dl=0 I think it should snap in or out, or to the nearest border between actions
- When I press an action, there is no visible highlight on the action
- When I press an action, the list item itself gets highlighted. But when I release the button, the highlight stays.

Revision history for this message
Tim Peeters (tpeeters) wrote :

I like to have some more flexibility in coloring the background of the panel. Currently the left one is always red, the right one white.

I would like to have the possibility to easily change these standard colors (left: green, right: yellow, or example). And maybe even have the possibility to change the background color per action in each of the panels. That last possibility is still a point of discussion.

Revision history for this message
Tim Peeters (tpeeters) wrote :

I like to have a delete action that deletes the list item that the action was added to, but for leadingActions, I use a reference to a common set of actions that we have for each list item. So I would need the Action.trigger() function to be called with the index of the list item in order to know which one needs to be deleted. Or do you know a better solution?

This is not only the case for deleting of list items. Each action (edit, move, reply e-mail, todo item done, etc) needs to know to which list item it applies.

Revision history for this message
Giorgio Venturi (giorgio-venturi-deactivatedaccount) wrote :

Hi Tim,

- When you swipe left/right, and then release, the list item should snap in and reveal *all the trailing or leading actions*
- When you press an action, there *should be* a visible highlight on the action (tap state)
- When you press an action, the list item should not be highlighted.
- I would recommend to give the possibility to change the background colour per action in each of the panels, but provide a default colour

Revision history for this message
Zsombor Egri (zsombi) wrote :

> I am testing with this test program
> https://code.launchpad.net/~tpeeters/+junk/lists and I see the following
> potential UX problems:
> - When I swipe left/right, and then release the mouse button, the list item
> stays exactly where it was, see https://www.dropbox.com/s/iinpzauwtm7hhsn/Scre
> enshot%202014-11-24%2015.23.47.png?dl=0 I think it should snap in or out, or
> to the nearest border between actions

I think we should go thru the MRs because you keep posting comments that will be solved in later MRs. snap comes in 55. It should either snap in or out, there's no snap to action borders, Mark disliked that.

> - When I press an action, there is no visible highlight on the action

No visible highlight was requested or specified by design.

> - When I press an action, the list item itself gets highlighted. But when I
> release the button, the highlight stays.

Hmm, that's a bug. And I think it got fixed in a later MR, but must check it.

Revision history for this message
Zsombor Egri (zsombi) wrote :

> I like to have some more flexibility in coloring the background of the panel.
> Currently the left one is always red, the right one white.

As discussed, we can add these properties to ListItemActions, but that will always be applied to these objects. The panel delegates are linked to ListItems, so in that sense these properties would rather be welcomed there than ListItemActions. We can discuss this later, and perhaps have it in a later MR.
>
> I would like to have the possibility to easily change these standard colors
> (left: green, right: yellow, or example). And maybe even have the possibility
> to change the background color per action in each of the panels. That last
> possibility is still a point of discussion.

Per action can be driven thru the ListItemActions.delegate (comes in MR# 50). Otherwise these color props must be added to action, which shouldn't be the case. OTOH, custom panel theme can be used any time for this.

Revision history for this message
Zsombor Egri (zsombi) wrote :

> I like to have a delete action that deletes the list item that the action was
> added to, but for leadingActions, I use a reference to a common set of actions
> that we have for each list item. So I would need the Action.trigger() function
> to be called with the index of the list item in order to know which one needs
> to be deleted. Or do you know a better solution?

It is done like that. The index is provided in MR #60.

>
> This is not only the case for deleting of list items. Each action (edit, move,
> reply e-mail, todo item done, etc) needs to know to which list item it
> applies.

Watch for MR #60 :)

Revision history for this message
Zsombor Egri (zsombi) wrote :

> Hi Tim,
>
> - When you swipe left/right, and then release, the list item should snap in
> and reveal *all the trailing or leading actions*

MR #55.

> - When you press an action, there *should be* a visible highlight on the
> action (tap state)

This is the first time I hear this. It would be nice to know what they mean about that.

> - When you press an action, the list item should not be highlighted.

If it done so, this is because there's no MouseArea yet in the ListItemPanel to handle the press events. When that is there, the highlight will also disappear. So the previous founding you had was because of this.

> - I would recommend to give the possibility to change the background colour
> per action in each of the panels, but provide a default colour

That requires color properties to be given in Actions. I do not think this is nice way to do things. OTOH, ListItemActions.delegate can be used for this, but then delegates must handle the action visualization, just like done in MR %50.

1289. By Zsombor Egri

highlight when pressed

1290. By Zsombor Egri

highlight fix

1291. By Zsombor Egri

highlight fix

Revision history for this message
Zsombor Egri (zsombi) wrote :

Pressed action highlight added; Highlight when actions are pressed fixed.

1292. By Zsombor Egri

revert UCStyledItemBase changes from rev 1290 so we do not forward child mouse events as normal mouse events, as we can get loads of similar mouse events (i.e. press events) on ListItem when a child is pressed. Instead handle mouse events in child filter

1293. By Zsombor Egri

calling super-class method

Revision history for this message
Tim Peeters (tpeeters) wrote :

works good now, including highlights :)

review: Approve

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 2014-11-25 07:30:59 +0000
3+++ components.api 2014-11-25 07:31:01 +0000
4@@ -874,8 +874,8 @@
5 Property { name: "contentMoving"; type: "bool"; isReadonly: true }
6 Property { name: "color"; type: "QColor" }
7 Property { name: "highlightColor"; type: "QColor" }
8- Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
9- Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true }
10+ Property { name: "listItemData"; type: "QObject"; isList: true; isReadonly: true }
11+ Property { name: "listItemChildren"; type: "QQuickItem"; isList: true; isReadonly: true }
12 Property { name: "style"; type: "QQmlComponent"; isPointer: true }
13 Property { name: "__styleInstance"; type: "QQuickItem"; isReadonly: true; isPointer: true }
14 Signal { name: "clicked" }
15
16=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml'
17--- modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml 2014-11-25 07:30:59 +0000
18+++ modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml 2014-11-25 07:31:01 +0000
19@@ -21,16 +21,30 @@
20 This component is the holder of the ListItem options.
21 */
22 Item {
23- id: panel
24
25 // styling properties
26 /*
27- Color of teh background.
28+ Color of the background.
29 */
30 // FIXME: use Palette colors instead when available
31 property color backgroundColor: (leading ? UbuntuColors.red : "white")
32
33- width: units.gu(20)
34+ /*
35+ Color used in coloring the icons.
36+ */
37+ // FIXME: use Palette colors instead when available
38+ property color foregroundColor: leading ? "white" : UbuntuColors.darkGrey
39+
40+ /*
41+ Specifies the width of the component visualizing the action.
42+ */
43+ property real visualizedActionWidth: units.gu(2.5)
44+
45+ // panel implementation
46+ id: panel
47+ width: Math.max(
48+ optionsRow.childrenRect.width,
49+ ListItemActions.visibleActions.length * MathUtils.clamp(visualizedActionWidth, height, optionsRow.maxItemWidth))
50
51 // used for module/autopilot testing
52 objectName: "ListItemPanel" + (leading ? "Leading" : "Trailing")
53@@ -61,4 +75,64 @@
54 }
55 color: panel.backgroundColor
56 }
57+
58+ Row {
59+ id: optionsRow
60+ anchors {
61+ left: parent.left
62+ top: parent.top
63+ bottom: parent.bottom
64+ leftMargin: spacing
65+ }
66+
67+ property real maxItemWidth: panel.parent ? (panel.parent.width / panel.ListItemActions.visibleActions.length) : 0
68+
69+ Repeater {
70+ model: panel.ListItemActions.visibleActions
71+ AbstractButton {
72+ action: modelData
73+ enabled: action.enabled
74+ opacity: action.enabled ? 1.0 : 0.5
75+ width: MathUtils.clamp(delegateLoader.item ? delegateLoader.item.width : 0, height, optionsRow.maxItemWidth)
76+ anchors {
77+ top: parent.top
78+ bottom: parent.bottom
79+ }
80+
81+ Rectangle {
82+ anchors.fill: parent
83+ color: Theme.palette.selected.background
84+ visible: pressed
85+ }
86+
87+ Loader {
88+ id: delegateLoader
89+ height: parent.height
90+ sourceComponent: panel.ListItemActions.delegate ? panel.ListItemActions.delegate : defaultDelegate
91+ property Action action: modelData
92+ property int index: index
93+ onItemChanged: {
94+ // use action's objectName to identify the visualized action
95+ if (item && item.objectName === "") {
96+ item.objectName = modelData.objectName;
97+ }
98+ }
99+ }
100+ }
101+ }
102+ }
103+
104+ Component {
105+ id: defaultDelegate
106+ Item {
107+ width: height
108+ Icon {
109+ width: panel.visualizedActionWidth
110+ height: width
111+ name: action.iconName
112+ color: panel.foregroundColor
113+ anchors.centerIn: parent
114+ }
115+ }
116+ }
117 }
118
119=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
120--- modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-11-25 07:30:59 +0000
121+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-11-25 07:31:01 +0000
122@@ -27,6 +27,7 @@
123 #include <QtQuick/private/qquickflickable_p.h>
124 #include <QtQuick/private/qquickpositioners_p.h>
125 #include <QtQuick/private/qquickanimation_p.h>
126+#include <QtQuick/private/qquickmousearea_p.h>
127 #include "uclistitemstyle.h"
128
129 #define MIN(x, y) ((x < y) ? x : y)
130@@ -361,7 +362,7 @@
131 // content will be redirected to the contentItem, therefore we must report
132 // children changes as it would come from the main component
133 QObject::connect(contentItem, &QQuickItem::childrenChanged,
134- q, &UCListItem::childrenChanged);
135+ q, &UCListItem::listItemChildrenChanged);
136 q->setFlag(QQuickItem::ItemHasContents);
137 // turn activeFocusOnPress on
138 q->setActiveFocusOnPress(true);
139@@ -508,6 +509,22 @@
140 (parentItem ? QQuickItemPrivate::get(parentItem)->childItems.indexOf(q) : -1);
141 }
142
143+// returns true if the highlight is possible
144+bool UCListItemPrivate::canHighlight(QMouseEvent *event)
145+{
146+ // localPos is a position relative to ListItem which will give us a child from
147+ // from the original coordinates; therefore we must map the position to the contentItem
148+ Q_Q(UCListItem);
149+ QPointF myPos = q->mapToItem(contentItem, event->localPos());
150+ QQuickItem *child = contentItem->childAt(myPos.x(), myPos.y());
151+ bool activeComponent = child && (child->acceptedMouseButtons() & event->button()) && !qobject_cast<QQuickText*>(child);
152+ // do highlight if not pressed above the active component, and the component has either
153+ // action, leading or trailing actions list or at least an active child component declared
154+ QQuickMouseArea *ma = q->findChild<QQuickMouseArea*>();
155+ bool activeMouseArea = ma && ma->isEnabled();
156+ return !activeComponent && (leadingActions || trailingActions || activeMouseArea);
157+}
158+
159 // set pressed flag and update contentItem
160 void UCListItemPrivate::setPressed(bool pressed)
161 {
162@@ -813,7 +830,7 @@
163 // while moving, we cannot select any items
164 return;
165 }
166- if (event->button() == Qt::LeftButton) {
167+ if (event->button() == Qt::LeftButton && d->canHighlight(event)) {
168 d->setPressed(true);
169 d->lastPos = d->pressedPos = event->localPos();
170 // connect the Flickable to know when to rebound
171@@ -916,6 +933,24 @@
172 }
173 }
174
175+bool UCListItem::childMouseEventFilter(QQuickItem *child, QEvent *event)
176+{
177+ QEvent::Type type = event->type();
178+ if (type == QEvent::MouseButtonPress) {
179+ // suppress click event if pressed over an active area, except Text, which can also handle
180+ // mouse clicks when content is an URL
181+ QMouseEvent *mouse = static_cast<QMouseEvent*>(event);
182+ if (child->isEnabled() && (child->acceptedMouseButtons() & mouse->button()) && !qobject_cast<QQuickText*>(child)) {
183+ Q_D(UCListItem);
184+ d->suppressClick = true;
185+ }
186+ } else if (type == QEvent::MouseButtonRelease) {
187+ Q_D(UCListItem);
188+ d->suppressClick = false;
189+ }
190+ return UCStyledItemBase::childMouseEventFilter(child, event);
191+}
192+
193 bool UCListItem::eventFilter(QObject *target, QEvent *event)
194 {
195 QPointF myPos;
196@@ -1118,25 +1153,24 @@
197 }
198
199 /*!
200- * \qmlproperty list<Object> ListItem::data
201+ * \qmlproperty list<Object> ListItem::listItemData
202 * \default
203+ * \internal
204 * Overloaded default property containing all the children and resources.
205 */
206-QQmlListProperty<QObject> UCListItem::data()
207+QQmlListProperty<QObject> UCListItemPrivate::data()
208 {
209- Q_D(UCListItem);
210- return QQuickItemPrivate::get(d->contentItem)->data();
211+ return QQuickItemPrivate::get(contentItem)->data();
212 }
213
214 /*!
215- * \qmlproperty list<Item> ListItem::children
216+ * \qmlproperty list<Item> ListItem::listItemChildren
217 * \internal
218 * Overloaded default property containing all the visible children of the item.
219 */
220-QQmlListProperty<QQuickItem> UCListItem::children()
221+QQmlListProperty<QQuickItem> UCListItemPrivate::children()
222 {
223- Q_D(UCListItem);
224- return QQuickItemPrivate::get(d->contentItem)->children();
225+ return QQuickItemPrivate::get(contentItem)->children();
226 }
227
228 #include "moc_uclistitem.cpp"
229
230=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.h'
231--- modules/Ubuntu/Components/plugin/uclistitem.h 2014-11-25 07:30:59 +0000
232+++ modules/Ubuntu/Components/plugin/uclistitem.h 2014-11-25 07:31:01 +0000
233@@ -37,12 +37,12 @@
234 Q_PRIVATE_PROPERTY(UCListItem::d_func(), bool contentMoving READ contentMoving NOTIFY contentMovingChanged)
235 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
236 Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor NOTIFY highlightColorChanged)
237- Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false)
238- Q_PROPERTY(QQmlListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
239+ Q_PRIVATE_PROPERTY(UCListItem::d_func(), QQmlListProperty<QObject> listItemData READ data DESIGNABLE false)
240+ Q_PRIVATE_PROPERTY(UCListItem::d_func(), QQmlListProperty<QQuickItem> listItemChildren READ children NOTIFY listItemChildrenChanged DESIGNABLE false)
241 // FIXME move these to StyledItemBase with subtheming
242 Q_PRIVATE_PROPERTY(UCListItem::d_func(), QQmlComponent *style READ style WRITE setStyle NOTIFY styleChanged)
243 Q_PRIVATE_PROPERTY(UCListItem::d_func(), QQuickItem *__styleInstance READ styleInstance NOTIFY __styleInstanceChanged)
244- Q_CLASSINFO("DefaultProperty", "data")
245+ Q_CLASSINFO("DefaultProperty", "listItemData")
246 public:
247 explicit UCListItem(QQuickItem *parent = 0);
248 ~UCListItem();
249@@ -69,6 +69,7 @@
250 void mousePressEvent(QMouseEvent *event);
251 void mouseReleaseEvent(QMouseEvent *event);
252 void mouseMoveEvent(QMouseEvent *event);
253+ bool childMouseEventFilter(QQuickItem *child, QEvent *event);
254 bool eventFilter(QObject *, QEvent *);
255
256 Q_SIGNALS:
257@@ -78,7 +79,7 @@
258 void contentMovingChanged();
259 void colorChanged();
260 void highlightColorChanged();
261- void childrenChanged();
262+ void listItemChildrenChanged();
263
264 void clicked();
265
266@@ -92,8 +93,6 @@
267
268 private:
269 Q_DECLARE_PRIVATE(UCListItem)
270- QQmlListProperty<QObject> data();
271- QQmlListProperty<QQuickItem> children();
272 Q_PRIVATE_SLOT(d_func(), void _q_updateThemedData())
273 Q_PRIVATE_SLOT(d_func(), void _q_rebound())
274 Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
275
276=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
277--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-11-25 07:30:59 +0000
278+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-11-25 07:31:01 +0000
279@@ -48,6 +48,7 @@
280 void promptRebound();
281 void _q_updateSize();
282 int index();
283+ bool canHighlight(QMouseEvent *event);
284 void setPressed(bool pressed);
285 void setSwiped(bool tugged);
286 bool grabPanel(UCListItemActions *optionList, bool isTugged);
287@@ -83,6 +84,8 @@
288 UCListItemStyle *styleItem;
289
290 // getter/setters
291+ QQmlListProperty<QObject> data();
292+ QQmlListProperty<QQuickItem> children();
293 bool contentMoving() const;
294 void setContentMoving(bool moved);
295 QQuickPropertyAnimation *snapAnimation() const;
296
297=== modified file 'modules/Ubuntu/Components/plugin/uclistitemactionsattached.cpp'
298--- modules/Ubuntu/Components/plugin/uclistitemactionsattached.cpp 2014-11-25 07:30:59 +0000
299+++ modules/Ubuntu/Components/plugin/uclistitemactionsattached.cpp 2014-11-25 07:31:01 +0000
300@@ -64,6 +64,7 @@
301 QObject::connect(action, &UCAction::visibleChanged,
302 this, &UCListItemActionsAttached::updateVisibleActions);
303 }
304+ updateVisibleActions();
305 }
306 Q_EMIT containerChanged();
307 Q_EMIT visibleActionsChanged();
308
309=== modified file 'modules/Ubuntu/Components/plugin/ucstyleditembase.cpp'
310--- modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2014-09-02 12:49:00 +0000
311+++ modules/Ubuntu/Components/plugin/ucstyleditembase.cpp 2014-11-25 07:31:01 +0000
312@@ -186,13 +186,11 @@
313 // therefore must check containment
314 QPointF point = mapFromItem(child, mouse->localPos());
315 if (contains(point)) {
316- QMouseEvent press(event->type(), point, mouse->windowPos(), mouse->screenPos(),
317- mouse->button(), mouse->buttons(), mouse->modifiers());
318- mousePressEvent(&press);
319+ requestFocus(Qt::MouseFocusReason);
320 }
321 }
322 // let the event be passed to children
323- return false;
324+ return QQuickItem::childMouseEventFilter(child, event);
325 }
326
327 #include "moc_ucstyleditembase.cpp"
328
329=== modified file 'tests/resources/listitems/ListItemTest.qml'
330--- tests/resources/listitems/ListItemTest.qml 2014-11-25 07:30:59 +0000
331+++ tests/resources/listitems/ListItemTest.qml 2014-11-25 07:31:01 +0000
332@@ -27,6 +27,8 @@
333 Action {
334 objectName: "stock"
335 id: stock
336+ iconName: "starred"
337+ onTriggered: print(iconName, "triggered")
338 }
339
340 ListItemActions {
341@@ -34,10 +36,29 @@
342 objectName: "StockLeading"
343 actions: [
344 Action {
345- },
346- Action {
347- },
348- Action {
349+ iconName: "delete"
350+ onTriggered: print(iconName, "triggered")
351+ },
352+ Action {
353+ iconName: "alarm-clock"
354+ enabled: false
355+ onTriggered: print(iconName, "triggered")
356+ },
357+ Action {
358+ iconName: "camcorder"
359+ onTriggered: print(iconName, "triggered")
360+ },
361+ Action {
362+ iconName: "stock_website"
363+ onTriggered: print(iconName, "triggered")
364+ },
365+ Action {
366+ iconName: "starred"
367+ onTriggered: print(iconName, "triggered")
368+ },
369+ Action {
370+ iconName: "go-home"
371+ onTriggered: print(iconName, "triggered")
372 }
373 ]
374 }
375@@ -55,7 +76,7 @@
376 iconName: "edit"
377 },
378 Action {
379- iconName: "copy"
380+ iconName: "email"
381 }
382 ]
383
384@@ -83,6 +104,16 @@
385 }
386 trailingActions: leading
387 }
388+ ListItem {
389+ Label {
390+ anchors.fill: parent
391+ text: "Another standalone ListItem"
392+ }
393+ leadingActions: testItem.leadingActions
394+ trailingActions: ListItemActions {
395+ actions: leading.actions
396+ }
397+ }
398
399 ListView {
400 id: view
401@@ -115,6 +146,11 @@
402 height: units.gu(20)
403 clip: true
404 contentHeight: column.childrenRect.height
405+ ListItemActions {
406+ id: trailing
407+ actions: leading.actions
408+ }
409+
410 Column {
411 id: column
412 width: view.width
413
414=== modified file 'tests/unit_x11/tst_components/tst_listitem.qml'
415--- tests/unit_x11/tst_components/tst_listitem.qml 2014-11-25 07:30:59 +0000
416+++ tests/unit_x11/tst_components/tst_listitem.qml 2014-11-25 07:31:01 +0000
417@@ -26,15 +26,23 @@
418
419 Action {
420 id: stockAction
421+ iconName: "starred"
422+ objectName: "stockAction"
423 }
424 ListItemActions {
425 id: leading
426 actions: [
427 Action {
428- },
429- Action {
430- },
431- Action {
432+ iconName: "starred"
433+ objectName: "leading_1"
434+ },
435+ Action {
436+ iconName: "starred"
437+ objectName: "leading_2"
438+ },
439+ Action {
440+ iconName: "starred"
441+ objectName: "leading_3"
442 }
443 ]
444 }
445@@ -42,6 +50,7 @@
446 id: trailing
447 actions: [
448 stockAction,
449+ stockAction,
450 ]
451 }
452 ListItemActions {
453@@ -107,6 +116,10 @@
454 signalName: "interactiveChanged"
455 }
456
457+ function panelItem(item, leading) {
458+ return findInvisibleChild(item, (leading ? "ListItemPanelLeading" : "ListItemPanelTrailing"));
459+ }
460+
461 function rebound(item, watchTarget) {
462 if (watchTarget === undefined) {
463 watchTarget = item;
464@@ -200,6 +213,8 @@
465 }
466 compare(listItem.pressed, false, "Item is pressed still!");
467 mouseRelease(listItem, listItem.width / 2, dy);
468+ // dismiss
469+ rebound(listItem);
470 }
471 function test_touch_click_on_listitem() {
472 var listItem = findChild(listView, "listItem0");
473@@ -216,6 +231,8 @@
474 compare(listItem.pressed, false, "Item is pressed still!");
475 // cleanup, wait few milliseconds to avoid dbl-click collision
476 TestExtras.touchRelease(0, listItem, Qt.point(listItem.width / 2, dy));
477+ // dismiss
478+ rebound(listItem);
479 }
480
481 function test_background_height_change_on_divider_visible() {
482@@ -311,5 +328,29 @@
483 verify(!data.item.__styleInstance.snapAnimation.running, "Animation is still running!");
484 fuzzyCompare(data.item.contentItem.x, 0.0, 0.1, "Not snapped out!!");
485 }
486+
487+ function test_visualized_actions_data() {
488+ var listItem0 = findChild(listView, "listItem0");
489+ var listItem1 = findChild(listView, "listItem1");
490+ return [
491+ {tag: "Leading actions", item: listItem0, leading: true, expected: ["leading_1", "leading_2", "leading_3"]},
492+ {tag: "Trailing actions", item: listItem0, leading: false, expected: ["stockAction"]},
493+ ];
494+ }
495+ function test_visualized_actions(data) {
496+ movingSpy.target = data.item;
497+ flick(data.item, centerOf(data.item).x, centerOf(data.item).y, data.leading ? units.gu(20) : -units.gu(20), 0);
498+ movingSpy.wait();
499+
500+ // check if the action is visible
501+ var panel = panelItem(data.item, data.leading);
502+ verify(panel, "Panel not visible");
503+ for (var i in data.expected) {
504+ var actionItem = findChild(panel, data.expected[i]);
505+ verify(actionItem, data.expected[i] + " action not found");
506+ }
507+ // dismiss
508+ rebound(data.item);
509+ }
510 }
511 }

Subscribers

People subscribed via source and target branches

to all changes: