Merge lp:~zsombi/ubuntu-ui-toolkit/50-custom-delegates into lp:ubuntu-ui-toolkit/staging
- 50-custom-delegates
- Merge into staging
Status: | Superseded |
---|---|
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/50-custom-delegates |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Prerequisite: | lp:~zsombi/ubuntu-ui-toolkit/45-selected-option-rebinds |
Diff against target: |
150 lines (+87/-0) 4 files modified
modules/Ubuntu/Components/ListItemPanel.qml (+1/-0) modules/Ubuntu/Components/plugin/uclistitemoptions.cpp (+56/-0) tests/resources/listitems/ListItemTest.qml (+16/-0) tests/unit_x11/tst_components/tst_listitem.qml (+14/-0) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/50-custom-delegates |
Related bugs: | |
Related blueprints: |
SDK: Design a new ListItem and layouts
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu SDK team | Pending | ||
Review via email: mp+232545@code.launchpad.net |
Commit message
Custom delegates to visualize Actions.
Description of the change
- 1227. By Zsombor Egri
-
prereq merge
- 1228. By Zsombor Egri
-
prereq merge
- 1229. By Zsombor Egri
-
prereq merge
- 1230. By Zsombor Egri
-
prereq merge
- 1231. By Zsombor Egri
-
prereq merge
- 1232. By Zsombor Egri
-
prereq merge
- 1233. By Zsombor Egri
-
prereq
- 1234. By Zsombor Egri
-
prereq
- 1235. By Zsombor Egri
-
remove rogue print
- 1236. By Zsombor Egri
-
prereq
- 1237. By Zsombor Egri
-
update panel's delegate when ListItemOptions delegate is changed on the fly
- 1238. By Zsombor Egri
-
prereq
- 1239. By Zsombor Egri
-
prereq
- 1240. By Zsombor Egri
-
prereq
- 1241. By Zsombor Egri
-
prereq merge
- 1242. By Zsombor Egri
-
version fixed on documentation
- 1243. By Zsombor Egri
-
prereq
- 1244. By Zsombor Egri
-
prereq
- 1245. By Zsombor Egri
-
prereq
- 1246. By Zsombor Egri
-
documentation fixed
- 1247. By Zsombor Egri
-
prereq
- 1248. By Zsombor Egri
-
prereq
- 1249. By Zsombor Egri
-
prereq
- 1250. By Zsombor Egri
-
prereq sync
- 1251. By Zsombor Egri
-
prereq sync
- 1252. By Zsombor Egri
-
prereq sync
- 1253. By Zsombor Egri
-
prereq sync
- 1254. By Zsombor Egri
-
prereq sync
- 1255. By Zsombor Egri
-
fixing tests
- 1256. By Zsombor Egri
-
prereq sync
- 1257. By Zsombor Egri
-
prereq sync
- 1258. By Zsombor Egri
-
documentation fxed
- 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
-
proper rebounding fix in test
- 1269. By Zsombor Egri
-
prereq sync
- 1270. By Zsombor Egri
-
prereq sync
- 1271. By Zsombor Egri
-
prereq sync
- 1272. By Zsombor Egri
-
fixing documentation
- 1273. By Zsombor Egri
-
prereq sync
- 1274. By Zsombor Egri
-
tests fixed
- 1275. By Zsombor Egri
-
prereq sync
- 1276. By Zsombor Egri
-
prereq sync
- 1277. By Zsombor Egri
-
tests adjusted
- 1278. By Zsombor Egri
-
prereq sync
- 1279. By Zsombor Egri
-
prereq sync
- 1280. By Zsombor Egri
-
prereq sync
- 1281. By Zsombor Egri
-
prereq sync
- 1282. By Zsombor Egri
-
prereq sync
- 1283. By Zsombor Egri
-
prereq sync
- 1284. By Zsombor Egri
-
prereq sync
- 1285. By Zsombor Egri
-
prereq sync
- 1286. By Zsombor Egri
-
documentation link fixed
- 1287. By Zsombor Egri
-
documentation link fixed
- 1288. By Zsombor Egri
-
more documentation fixes
- 1289. By Zsombor Egri
-
prereq sync
- 1290. By Zsombor Egri
-
remove typo from property documentation
- 1291. By Zsombor Egri
-
review comments added
Unmerged revisions
Preview Diff
1 | === modified file 'modules/Ubuntu/Components/ListItemPanel.qml' |
2 | --- modules/Ubuntu/Components/ListItemPanel.qml 2014-09-11 11:54:37 +0000 |
3 | +++ modules/Ubuntu/Components/ListItemPanel.qml 2014-09-11 11:54:37 +0000 |
4 | @@ -85,6 +85,7 @@ |
5 | height: parent.height |
6 | sourceComponent: panel.delegate ? panel.delegate : defaultDelegate |
7 | property Action option: modelData |
8 | + property int index: index |
9 | onItemChanged: { |
10 | // this is needed only for testing purposes |
11 | if (item && item.objectName === "") { |
12 | |
13 | === modified file 'modules/Ubuntu/Components/plugin/uclistitemoptions.cpp' |
14 | --- modules/Ubuntu/Components/plugin/uclistitemoptions.cpp 2014-09-11 11:54:37 +0000 |
15 | +++ modules/Ubuntu/Components/plugin/uclistitemoptions.cpp 2014-09-11 11:54:37 +0000 |
16 | @@ -223,6 +223,58 @@ |
17 | * Custom delegate which overrides the default one used by the ListItem. If the |
18 | * value is null, the default delegate will be used. |
19 | * |
20 | + * ListItemOptions provides the \c option context property which contains the |
21 | + * Action instance currently visualized. Using this property delegates can access |
22 | + * the information to be visualized. The trigger is handled by the \l panelItem |
23 | + * therefore only visualization is needed by the custom delegates. The other |
24 | + * context property exposed to delegates is the \c index, which specifies the |
25 | + * index of the option visualized. |
26 | + * |
27 | + * The delegate height is set automatically by the panelItem, and the width value |
28 | + * is clamped between height and the maximum width of the list item divided by the |
29 | + * number of options in the list. |
30 | + * \qml |
31 | + * import QtQuick 2.2 |
32 | + * import Ubuntu.Components 1.1 |
33 | + * |
34 | + * MainView { |
35 | + * width: units.gu(40) |
36 | + * height: units.gu(71) |
37 | + * |
38 | + * UbuntuListView { |
39 | + * anchors.fill: parent |
40 | + * model: 50 |
41 | + * delegate: ListItem { |
42 | + * trailingOptions: optionsList |
43 | + * } |
44 | + * ListItemOptions { |
45 | + * id: optionsList |
46 | + * delegate: Column { |
47 | + * width: height + units.gu(2) |
48 | + * Icon { |
49 | + * name: option.iconName |
50 | + * width: units.gu(3) |
51 | + * height: width |
52 | + * color: "blue" |
53 | + * anchors.horizontalCenter: parent.horizontalCenter |
54 | + * } |
55 | + * Label { |
56 | + * text: option.text + "#" + index |
57 | + * width: parent.width |
58 | + * horizontalAlignment: Text.AlignHCenter |
59 | + * } |
60 | + * } |
61 | + * Action { |
62 | + * iconName: "starred" |
63 | + * text: "Star" |
64 | + * } |
65 | + * } |
66 | + * } |
67 | + * } |
68 | + * \endqml |
69 | + * \note Putting a Rectangle in the delegate can be used to override the color |
70 | + * of the panel. |
71 | + * |
72 | * Defaults to null. |
73 | */ |
74 | QQmlComponent *UCListItemOptions::delegate() const |
75 | @@ -237,6 +289,10 @@ |
76 | return; |
77 | } |
78 | d->delegate = delegate; |
79 | + if (d->panelItem) { |
80 | + // update panel's delegate as well |
81 | + d->panelItem->setProperty("delegate", QVariant::fromValue(delegate)); |
82 | + } |
83 | Q_EMIT delegateChanged(); |
84 | } |
85 | |
86 | |
87 | === modified file 'tests/resources/listitems/ListItemTest.qml' |
88 | --- tests/resources/listitems/ListItemTest.qml 2014-09-11 11:54:37 +0000 |
89 | +++ tests/resources/listitems/ListItemTest.qml 2014-09-11 11:54:37 +0000 |
90 | @@ -28,6 +28,7 @@ |
91 | objectName: "stock" |
92 | id: stock |
93 | iconName: "starred" |
94 | + text: "Staaaar" |
95 | onTriggered: print(iconName, "triggered") |
96 | } |
97 | |
98 | @@ -74,6 +75,21 @@ |
99 | leadingOptions: ListItemOptions { |
100 | objectName: "InlineLeading" |
101 | options: [stock] |
102 | + delegate: Column { |
103 | + width: height + units.gu(2) |
104 | + Icon { |
105 | + width: units.gu(3) |
106 | + height: width |
107 | + name: option.iconName |
108 | + color: "blue" |
109 | + anchors.horizontalCenter: parent.horizontalCenter |
110 | + } |
111 | + Label { |
112 | + text: option.text + index |
113 | + width: parent.width |
114 | + horizontalAlignment: Text.AlignHCenter |
115 | + } |
116 | + } |
117 | } |
118 | trailingOptions: leading |
119 | } |
120 | |
121 | === modified file 'tests/unit_x11/tst_components/tst_listitem.qml' |
122 | --- tests/unit_x11/tst_components/tst_listitem.qml 2014-09-11 11:54:37 +0000 |
123 | +++ tests/unit_x11/tst_components/tst_listitem.qml 2014-09-11 11:54:37 +0000 |
124 | @@ -45,6 +45,9 @@ |
125 | options: [ |
126 | stockAction, |
127 | ] |
128 | + delegate: Item { |
129 | + objectName: "custom_delegate" |
130 | + } |
131 | } |
132 | ListItemOptions { |
133 | id: wrongOption |
134 | @@ -342,5 +345,16 @@ |
135 | waitForRendering(data.item, 400); |
136 | tryCompareFunction(function(){ return data.item.contentItem.x; }, 0, 1000); |
137 | } |
138 | + |
139 | + function test_custom_trailing_delegate() { |
140 | + listView.positionViewAtBeginning(); |
141 | + var item = findChild(listView, "listItem0"); |
142 | + flick(item, centerOf(item).x, centerOf(item).y, -units.gu(20), 0); |
143 | + verify(trailing.panelItem, "Panel is not visible"); |
144 | + var custom = findChild(trailing.panelItem, "custom_delegate"); |
145 | + verify(custom, "Custom delegate not in use"); |
146 | + // cleanup |
147 | + mouseClick(main, 0, 0); |
148 | + } |
149 | } |
150 | } |