Merge lp:~faenil/ubuntu-ui-toolkit/listitemlayout_lp1514173 into lp:ubuntu-ui-toolkit/staging

Proposed by Andrea Bernabei
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1716
Merged at revision: 1711
Proposed branch: lp:~faenil/ubuntu-ui-toolkit/listitemlayout_lp1514173
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 314 lines (+83/-29)
10 files modified
components.api (+1/-0)
examples/ubuntu-ui-toolkit-gallery/ListItemLayouts.qml (+8/-8)
examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml (+1/-1)
src/Ubuntu/Components/plugin/privates/threelabelsslot_p.cpp (+3/-3)
src/Ubuntu/Components/plugin/uclistitemlayout.cpp (+20/-11)
src/Ubuntu/Components/plugin/uclistitemlayout.h (+2/-1)
src/Ubuntu/Components/plugin/ucslotslayout.cpp (+10/-2)
src/Ubuntu/Components/plugin/ucslotslayout.h (+3/-2)
src/Ubuntu/Test/UbuntuTestCase.qml (+5/-0)
tests/unit_x11/tst_components/tst_slotslayout.qml (+30/-1)
To merge this branch: bzr merge lp:~faenil/ubuntu-ui-toolkit/listitemlayout_lp1514173
Reviewer Review Type Date Requested Status
Zsombor Egri Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+276942@code.launchpad.net

Commit message

ListItemLayout: set QML context of the predefined labels. Fixes lp1514173

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1711. By Andrea Bernabei

slotslayout test: add ignoreWarning to qml context test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1712. By Andrea Bernabei

update components.api

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1713. By Andrea Bernabei

ListItemLayout: allocate default mainSlot in its getter. Fixes qmlplugindump crash.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1714. By Andrea Bernabei

UbuntuTestCase: add documentation for testUtil property

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

A small comment, and we're good.

review: Needs Fixing
1715. By Andrea Bernabei

ListItemLayout: don't fire mainSlotChanged when setting the default main slot

1716. By Andrea Bernabei

UI toolkit gallery: fix height of ListItems in ListItemLayouts page

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Good to go now. Thanks for the fix!!!

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 2015-11-09 16:03:08 +0000
3+++ components.api 2015-11-10 11:54:07 +0000
4@@ -1521,6 +1521,7 @@
5 function var typeString(var string)
6 function var warningFormat(var line, var column, var message)
7 function var waitForHeaderAnimation(var mainView)
8+ readonly property QuickTestUtil testUtil
9 Ubuntu.Components.UriHandler 1.0 0.1: QtObject singleton
10 signal opened(QStringList uris)
11 Ubuntu.Components.ListItems.ValueSelector 1.0 0.1: Empty
12
13=== modified file 'examples/ubuntu-ui-toolkit-gallery/ListItemLayouts.qml'
14--- examples/ubuntu-ui-toolkit-gallery/ListItemLayouts.qml 2015-09-30 21:14:25 +0000
15+++ examples/ubuntu-ui-toolkit-gallery/ListItemLayouts.qml 2015-11-10 11:54:07 +0000
16@@ -28,7 +28,7 @@
17
18 ListItem {
19 id: addressbookListItem
20- height: addressbookLayout.height
21+ height: addressbookLayout.height + (divider.visible ? divider.height : 0)
22
23 ListItemLayout {
24 id: addressbookLayout
25@@ -48,7 +48,7 @@
26
27 ListItem {
28 id: addressbookDetailsListItem
29- height: addressbookDetailsLayout.height + divider.height
30+ height: addressbookDetailsLayout.height + (divider.visible ? divider.height : 0)
31 ListItemLayout {
32 id: addressbookDetailsLayout
33
34@@ -73,7 +73,7 @@
35 ListItem {
36 id: telegramContactsListItem
37
38- height: telegramContactsLayout.height
39+ height: telegramContactsLayout.height + (divider.visible ? divider.height : 0)
40
41 ListItemLayout {
42 id: telegramContactsLayout
43@@ -92,7 +92,7 @@
44
45 ListItem {
46 id: systemSettings1
47- height: systemSettings1_layout.height
48+ height: systemSettings1_layout.height + (divider.visible ? divider.height : 0)
49
50 ListItemLayout {
51 id: systemSettings1_layout
52@@ -110,7 +110,7 @@
53
54 ListItem {
55 id: systemSettings2
56- height: systemSettings2_layout.height
57+ height: systemSettings2_layout.height + (divider.visible ? divider.height : 0)
58
59 ListItemLayout {
60 id: systemSettings2_layout
61@@ -129,7 +129,7 @@
62
63 ListItem {
64 id: systemSettings3
65- height: systemSettings3_layout.height
66+ height: systemSettings3_layout.height + (divider.visible ? divider.height : 0)
67
68 ListItemLayout {
69 id: systemSettings3_layout
70@@ -157,7 +157,7 @@
71 spacing: 0
72
73 ListItem {
74- height: customLabelsLayout.height
75+ height: customLabelsLayout.height + (divider.visible ? divider.height : 0)
76
77 ListItemLayout {
78 id: customLabelsLayout
79@@ -220,7 +220,7 @@
80
81 ListItem {
82 id: dialerHistoryListItem
83- height: dialerHistoryLayout.height
84+ height: dialerHistoryLayout.height + (divider.visible ? divider.height : 0)
85
86 ListItemLayout {
87 id: dialerHistoryLayout
88
89=== modified file 'examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml'
90--- examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml 2015-09-28 12:26:13 +0000
91+++ examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml 2015-11-10 11:54:07 +0000
92@@ -20,7 +20,7 @@
93 ListItem {
94 property alias title: layout.title
95
96- height: layout.height
97+ height: layout.height + (divider.visible ? divider.height : 0)
98 onPressAndHold: selectMode = !selectMode
99
100 ListItemLayout { id: layout }
101
102=== modified file 'src/Ubuntu/Components/plugin/privates/threelabelsslot_p.cpp'
103--- src/Ubuntu/Components/plugin/privates/threelabelsslot_p.cpp 2015-10-12 14:32:17 +0000
104+++ src/Ubuntu/Components/plugin/privates/threelabelsslot_p.cpp 2015-11-10 11:54:07 +0000
105@@ -143,7 +143,7 @@
106 Q_D(UCThreeLabelsSlot);
107 if (d->m_title == Q_NULLPTR) {
108 d->m_title = new UCLabel(this);
109- QQmlData::get(d->m_title, true);
110+ QQmlEngine::setContextForObject(d->m_title, qmlContext(this));
111 d->m_title->init();
112
113 QQuickAnchors *titleAnchors = QQuickItemPrivate::get(d->m_title)->anchors();
114@@ -180,7 +180,7 @@
115 Q_D(UCThreeLabelsSlot);
116 if (d->m_subtitle == Q_NULLPTR) {
117 d->m_subtitle = new UCLabel(this);
118- QQmlData::get(d->m_subtitle, true);
119+ QQmlEngine::setContextForObject(d->m_subtitle, qmlContext(this));
120 d->m_subtitle->init();
121
122 QQuickAnchors *subtitleAnchors = QQuickItemPrivate::get(d->m_subtitle)->anchors();
123@@ -202,7 +202,7 @@
124 Q_D(UCThreeLabelsSlot);
125 if (d->m_summary == Q_NULLPTR) {
126 d->m_summary = new UCLabel(this);
127- QQmlData::get(d->m_summary, true);
128+ QQmlEngine::setContextForObject(d->m_summary, qmlContext(this));
129 d->m_summary->init();
130
131 QQuickAnchors *summaryAnchors = QQuickItemPrivate::get(d->m_summary)->anchors();
132
133=== modified file 'src/Ubuntu/Components/plugin/uclistitemlayout.cpp'
134--- src/Ubuntu/Components/plugin/uclistitemlayout.cpp 2015-10-01 08:47:31 +0000
135+++ src/Ubuntu/Components/plugin/uclistitemlayout.cpp 2015-11-10 11:54:07 +0000
136@@ -212,16 +212,7 @@
137 UCListItemLayout::UCListItemLayout(QQuickItem *parent)
138 : UCSlotsLayout(parent)
139 {
140- //don't set the parent, we have to create qqmldata first
141- UCThreeLabelsSlot *main = new UCThreeLabelsSlot();
142-
143- //create QML data for mainSlot otherwise qmlAttachedProperties
144- //calls in SlotsLayout will fail
145- QQmlData::get(main, true);
146- main->setParent(this);
147-
148- //this will also set the parentItem
149- UCSlotsLayout::setMainSlot(main);
150+
151 }
152
153 /*!
154@@ -269,7 +260,25 @@
155 return qobject_cast<UCThreeLabelsSlot *>(mainSlot())->summary();
156 }
157
158-void UCListItemLayout::setMainSlot(QQuickItem *slot) {
159+QQuickItem *UCListItemLayout::mainSlot() {
160+ if (UCSlotsLayout::mainSlot() == Q_NULLPTR) {
161+ //don't set the parent, we have to create qqmldata first
162+ UCThreeLabelsSlot *main = new UCThreeLabelsSlot();
163+
164+ //create QML data for mainSlot otherwise qmlAttachedProperties
165+ //calls in SlotsLayout will fail (setContextForObject will create the QQmlData)
166+ QQmlEngine::setContextForObject(main, qmlContext(this));
167+ main->setParent(this);
168+
169+ //this will also set the parentItem
170+ UCSlotsLayout::setMainSlot(main, false);
171+ }
172+
173+ return UCSlotsLayout::mainSlot();
174+}
175+
176+void UCListItemLayout::setMainSlot(QQuickItem *slot, bool fireSignal) {
177 Q_UNUSED(slot);
178+ Q_UNUSED(fireSignal);
179 qmlInfo(this) << "Setting a different mainSlot on ListItemLayout is not supported. Please use SlotsLayout instead.";
180 }
181
182=== modified file 'src/Ubuntu/Components/plugin/uclistitemlayout.h'
183--- src/Ubuntu/Components/plugin/uclistitemlayout.h 2015-09-30 15:53:49 +0000
184+++ src/Ubuntu/Components/plugin/uclistitemlayout.h 2015-11-10 11:54:07 +0000
185@@ -30,9 +30,10 @@
186 public:
187 explicit UCListItemLayout(QQuickItem *parent = 0);
188
189+ QQuickItem *mainSlot() override;
190 //we don't allow changing the main slot on ListItemLayout because otherwise
191 //accessing title/subtitle/summary would lead to a crash
192- void setMainSlot(QQuickItem *slot) override;
193+ void setMainSlot(QQuickItem *slot, bool fireSignal = true) override;
194
195 UCLabel *title();
196 UCLabel *subtitle();
197
198=== modified file 'src/Ubuntu/Components/plugin/ucslotslayout.cpp'
199--- src/Ubuntu/Components/plugin/ucslotslayout.cpp 2015-10-12 14:32:17 +0000
200+++ src/Ubuntu/Components/plugin/ucslotslayout.cpp 2015-11-10 11:54:07 +0000
201@@ -990,13 +990,18 @@
202 }
203 \endqml
204 */
205+QQuickItem *UCSlotsLayout::mainSlot()
206+{
207+ Q_D(const UCSlotsLayout);
208+ return d->mainSlot;
209+}
210 QQuickItem *UCSlotsLayout::mainSlot() const
211 {
212 Q_D(const UCSlotsLayout);
213 return d->mainSlot;
214 }
215
216-void UCSlotsLayout::setMainSlot(QQuickItem *item)
217+void UCSlotsLayout::setMainSlot(QQuickItem *item, bool fireSignal)
218 {
219 Q_D(UCSlotsLayout);
220 if (d->mainSlot != item && item != Q_NULLPTR) {
221@@ -1008,7 +1013,10 @@
222 }
223 d->mainSlot = item;
224 d->mainSlot->setParentItem(this);
225- Q_EMIT mainSlotChanged();
226+
227+ if (fireSignal) {
228+ Q_EMIT mainSlotChanged();
229+ }
230 }
231 }
232
233
234=== modified file 'src/Ubuntu/Components/plugin/ucslotslayout.h'
235--- src/Ubuntu/Components/plugin/ucslotslayout.h 2015-09-30 15:53:49 +0000
236+++ src/Ubuntu/Components/plugin/ucslotslayout.h 2015-11-10 11:54:07 +0000
237@@ -36,8 +36,9 @@
238 public:
239 explicit UCSlotsLayout(QQuickItem *parent = 0);
240
241- QQuickItem *mainSlot() const;
242- virtual void setMainSlot(QQuickItem *item);
243+ virtual QQuickItem *mainSlot();
244+ virtual QQuickItem *mainSlot() const;
245+ virtual void setMainSlot(QQuickItem *item, bool fireSignal = true);
246
247 UCSlotsLayoutPadding *padding();
248
249
250=== modified file 'src/Ubuntu/Test/UbuntuTestCase.qml'
251--- src/Ubuntu/Test/UbuntuTestCase.qml 2015-09-17 06:29:36 +0000
252+++ src/Ubuntu/Test/UbuntuTestCase.qml 2015-11-10 11:54:07 +0000
253@@ -34,6 +34,11 @@
254 }
255
256 /*!
257+ This property holds the inner TestUtil instance.
258+ */
259+ property alias testUtil: util
260+
261+ /*!
262 Find a child from the item based on the objectName.
263 */
264 function findChild(obj,objectName) {
265
266=== modified file 'tests/unit_x11/tst_components/tst_slotslayout.qml'
267--- tests/unit_x11/tst_components/tst_slotslayout.qml 2015-10-01 12:49:42 +0000
268+++ tests/unit_x11/tst_components/tst_slotslayout.qml 2015-11-10 11:54:07 +0000
269@@ -294,6 +294,10 @@
270 name: "SlotsLayout"
271 when: windowShown
272
273+ function warningMsg(msg) {
274+ return testUtil.callerFile() + ": " + msg
275+ }
276+
277 //Visual rule:
278 //when we have at least one slot which is taller than mainSlot and taller than 4GU,
279 //we want the top and bottom padding to be 1GU instead of 2GU
280@@ -841,8 +845,33 @@
281
282 Label {id: customMainSlot }
283 function test_warningOnAttemptToChangeListItemLayoutMainSlot() {
284+ ignoreWarning(warningFormat(60, 9, "QML ListItemLayout: Setting a different mainSlot on ListItemLayout is not supported. Please use SlotsLayout instead."))
285 layoutLabels.mainSlot = customMainSlot
286- console.log(warningFormat(60, 9, "QML ListItemLayout: Setting a different mainSlot on ListItemLayout is not supported. Please use SlotsLayout instead."))
287+ }
288+
289+
290+ Component {
291+ id: layoutTestQmlContextComponent
292+ ListItemLayout {
293+ id: layoutTestQmlContext
294+ title.text: "<html><body><p dir='ltr'>TEST <img align=absmiddle height=\"10\" width=\"10\" src=\"file:///test.png\" /> </p></body></html>"
295+ title.textFormat: Text.RichText
296+ subtitle.text: "<html><body><p dir='ltr'>TEST <img align=absmiddle height=\"10\" width=\"10\" src=\"file:///test.png\" /> </p></body></html>"
297+ subtitle.textFormat: Text.RichText
298+ summary.text: "<html><body><p dir='ltr'>TEST <img align=absmiddle height=\"10\" width=\"10\" src=\"file:///test.png\" /> </p></body></html>"
299+ summary.textFormat: Text.RichText
300+ }
301+ }
302+ //lp#1514173
303+ //this will make the test segfault if there is a regression
304+ function test_defaultLabelsQmlContext() {
305+ ignoreWarning(warningMsg("QML Label: Cannot open: file:///test.png"))
306+ var obj = layoutTestQmlContextComponent.createObject(main)
307+ //wait for rendering otherwise we will not get the "cannot find file" warning
308+ //because the img is loaded async
309+ waitForRendering(obj)
310+ compare(obj !== null, true, "QML ListItemLayout: testing labels' QML context.")
311+ obj.destroy()
312 }
313 }
314 }

Subscribers

People subscribed via source and target branches