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
=== modified file 'components.api'
--- components.api 2015-11-09 16:03:08 +0000
+++ components.api 2015-11-10 11:54:07 +0000
@@ -1521,6 +1521,7 @@
1521 function var typeString(var string)1521 function var typeString(var string)
1522 function var warningFormat(var line, var column, var message)1522 function var warningFormat(var line, var column, var message)
1523 function var waitForHeaderAnimation(var mainView)1523 function var waitForHeaderAnimation(var mainView)
1524 readonly property QuickTestUtil testUtil
1524Ubuntu.Components.UriHandler 1.0 0.1: QtObject singleton1525Ubuntu.Components.UriHandler 1.0 0.1: QtObject singleton
1525 signal opened(QStringList uris)1526 signal opened(QStringList uris)
1526Ubuntu.Components.ListItems.ValueSelector 1.0 0.1: Empty1527Ubuntu.Components.ListItems.ValueSelector 1.0 0.1: Empty
15271528
=== modified file 'examples/ubuntu-ui-toolkit-gallery/ListItemLayouts.qml'
--- examples/ubuntu-ui-toolkit-gallery/ListItemLayouts.qml 2015-09-30 21:14:25 +0000
+++ examples/ubuntu-ui-toolkit-gallery/ListItemLayouts.qml 2015-11-10 11:54:07 +0000
@@ -28,7 +28,7 @@
2828
29 ListItem {29 ListItem {
30 id: addressbookListItem30 id: addressbookListItem
31 height: addressbookLayout.height31 height: addressbookLayout.height + (divider.visible ? divider.height : 0)
3232
33 ListItemLayout {33 ListItemLayout {
34 id: addressbookLayout34 id: addressbookLayout
@@ -48,7 +48,7 @@
4848
49 ListItem {49 ListItem {
50 id: addressbookDetailsListItem50 id: addressbookDetailsListItem
51 height: addressbookDetailsLayout.height + divider.height51 height: addressbookDetailsLayout.height + (divider.visible ? divider.height : 0)
52 ListItemLayout {52 ListItemLayout {
53 id: addressbookDetailsLayout53 id: addressbookDetailsLayout
5454
@@ -73,7 +73,7 @@
73 ListItem {73 ListItem {
74 id: telegramContactsListItem74 id: telegramContactsListItem
7575
76 height: telegramContactsLayout.height76 height: telegramContactsLayout.height + (divider.visible ? divider.height : 0)
7777
78 ListItemLayout {78 ListItemLayout {
79 id: telegramContactsLayout79 id: telegramContactsLayout
@@ -92,7 +92,7 @@
9292
93 ListItem {93 ListItem {
94 id: systemSettings194 id: systemSettings1
95 height: systemSettings1_layout.height95 height: systemSettings1_layout.height + (divider.visible ? divider.height : 0)
9696
97 ListItemLayout {97 ListItemLayout {
98 id: systemSettings1_layout98 id: systemSettings1_layout
@@ -110,7 +110,7 @@
110110
111 ListItem {111 ListItem {
112 id: systemSettings2112 id: systemSettings2
113 height: systemSettings2_layout.height113 height: systemSettings2_layout.height + (divider.visible ? divider.height : 0)
114114
115 ListItemLayout {115 ListItemLayout {
116 id: systemSettings2_layout116 id: systemSettings2_layout
@@ -129,7 +129,7 @@
129129
130 ListItem {130 ListItem {
131 id: systemSettings3131 id: systemSettings3
132 height: systemSettings3_layout.height132 height: systemSettings3_layout.height + (divider.visible ? divider.height : 0)
133133
134 ListItemLayout {134 ListItemLayout {
135 id: systemSettings3_layout135 id: systemSettings3_layout
@@ -157,7 +157,7 @@
157 spacing: 0157 spacing: 0
158158
159 ListItem {159 ListItem {
160 height: customLabelsLayout.height160 height: customLabelsLayout.height + (divider.visible ? divider.height : 0)
161161
162 ListItemLayout {162 ListItemLayout {
163 id: customLabelsLayout163 id: customLabelsLayout
@@ -220,7 +220,7 @@
220220
221 ListItem {221 ListItem {
222 id: dialerHistoryListItem222 id: dialerHistoryListItem
223 height: dialerHistoryLayout.height223 height: dialerHistoryLayout.height + (divider.visible ? divider.height : 0)
224224
225 ListItemLayout {225 ListItemLayout {
226 id: dialerHistoryLayout226 id: dialerHistoryLayout
227227
=== modified file 'examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml'
--- examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml 2015-09-28 12:26:13 +0000
+++ examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml 2015-11-10 11:54:07 +0000
@@ -20,7 +20,7 @@
20ListItem {20ListItem {
21 property alias title: layout.title21 property alias title: layout.title
2222
23 height: layout.height23 height: layout.height + (divider.visible ? divider.height : 0)
24 onPressAndHold: selectMode = !selectMode24 onPressAndHold: selectMode = !selectMode
2525
26 ListItemLayout { id: layout }26 ListItemLayout { id: layout }
2727
=== modified file 'src/Ubuntu/Components/plugin/privates/threelabelsslot_p.cpp'
--- src/Ubuntu/Components/plugin/privates/threelabelsslot_p.cpp 2015-10-12 14:32:17 +0000
+++ src/Ubuntu/Components/plugin/privates/threelabelsslot_p.cpp 2015-11-10 11:54:07 +0000
@@ -143,7 +143,7 @@
143 Q_D(UCThreeLabelsSlot);143 Q_D(UCThreeLabelsSlot);
144 if (d->m_title == Q_NULLPTR) {144 if (d->m_title == Q_NULLPTR) {
145 d->m_title = new UCLabel(this);145 d->m_title = new UCLabel(this);
146 QQmlData::get(d->m_title, true);146 QQmlEngine::setContextForObject(d->m_title, qmlContext(this));
147 d->m_title->init();147 d->m_title->init();
148148
149 QQuickAnchors *titleAnchors = QQuickItemPrivate::get(d->m_title)->anchors();149 QQuickAnchors *titleAnchors = QQuickItemPrivate::get(d->m_title)->anchors();
@@ -180,7 +180,7 @@
180 Q_D(UCThreeLabelsSlot);180 Q_D(UCThreeLabelsSlot);
181 if (d->m_subtitle == Q_NULLPTR) {181 if (d->m_subtitle == Q_NULLPTR) {
182 d->m_subtitle = new UCLabel(this);182 d->m_subtitle = new UCLabel(this);
183 QQmlData::get(d->m_subtitle, true);183 QQmlEngine::setContextForObject(d->m_subtitle, qmlContext(this));
184 d->m_subtitle->init();184 d->m_subtitle->init();
185185
186 QQuickAnchors *subtitleAnchors = QQuickItemPrivate::get(d->m_subtitle)->anchors();186 QQuickAnchors *subtitleAnchors = QQuickItemPrivate::get(d->m_subtitle)->anchors();
@@ -202,7 +202,7 @@
202 Q_D(UCThreeLabelsSlot);202 Q_D(UCThreeLabelsSlot);
203 if (d->m_summary == Q_NULLPTR) {203 if (d->m_summary == Q_NULLPTR) {
204 d->m_summary = new UCLabel(this);204 d->m_summary = new UCLabel(this);
205 QQmlData::get(d->m_summary, true);205 QQmlEngine::setContextForObject(d->m_summary, qmlContext(this));
206 d->m_summary->init();206 d->m_summary->init();
207207
208 QQuickAnchors *summaryAnchors = QQuickItemPrivate::get(d->m_summary)->anchors();208 QQuickAnchors *summaryAnchors = QQuickItemPrivate::get(d->m_summary)->anchors();
209209
=== modified file 'src/Ubuntu/Components/plugin/uclistitemlayout.cpp'
--- src/Ubuntu/Components/plugin/uclistitemlayout.cpp 2015-10-01 08:47:31 +0000
+++ src/Ubuntu/Components/plugin/uclistitemlayout.cpp 2015-11-10 11:54:07 +0000
@@ -212,16 +212,7 @@
212UCListItemLayout::UCListItemLayout(QQuickItem *parent)212UCListItemLayout::UCListItemLayout(QQuickItem *parent)
213 : UCSlotsLayout(parent)213 : UCSlotsLayout(parent)
214{214{
215 //don't set the parent, we have to create qqmldata first215
216 UCThreeLabelsSlot *main = new UCThreeLabelsSlot();
217
218 //create QML data for mainSlot otherwise qmlAttachedProperties
219 //calls in SlotsLayout will fail
220 QQmlData::get(main, true);
221 main->setParent(this);
222
223 //this will also set the parentItem
224 UCSlotsLayout::setMainSlot(main);
225}216}
226217
227/*!218/*!
@@ -269,7 +260,25 @@
269 return qobject_cast<UCThreeLabelsSlot *>(mainSlot())->summary();260 return qobject_cast<UCThreeLabelsSlot *>(mainSlot())->summary();
270}261}
271262
272void UCListItemLayout::setMainSlot(QQuickItem *slot) {263QQuickItem *UCListItemLayout::mainSlot() {
264 if (UCSlotsLayout::mainSlot() == Q_NULLPTR) {
265 //don't set the parent, we have to create qqmldata first
266 UCThreeLabelsSlot *main = new UCThreeLabelsSlot();
267
268 //create QML data for mainSlot otherwise qmlAttachedProperties
269 //calls in SlotsLayout will fail (setContextForObject will create the QQmlData)
270 QQmlEngine::setContextForObject(main, qmlContext(this));
271 main->setParent(this);
272
273 //this will also set the parentItem
274 UCSlotsLayout::setMainSlot(main, false);
275 }
276
277 return UCSlotsLayout::mainSlot();
278}
279
280void UCListItemLayout::setMainSlot(QQuickItem *slot, bool fireSignal) {
273 Q_UNUSED(slot);281 Q_UNUSED(slot);
282 Q_UNUSED(fireSignal);
274 qmlInfo(this) << "Setting a different mainSlot on ListItemLayout is not supported. Please use SlotsLayout instead.";283 qmlInfo(this) << "Setting a different mainSlot on ListItemLayout is not supported. Please use SlotsLayout instead.";
275}284}
276285
=== modified file 'src/Ubuntu/Components/plugin/uclistitemlayout.h'
--- src/Ubuntu/Components/plugin/uclistitemlayout.h 2015-09-30 15:53:49 +0000
+++ src/Ubuntu/Components/plugin/uclistitemlayout.h 2015-11-10 11:54:07 +0000
@@ -30,9 +30,10 @@
30public:30public:
31 explicit UCListItemLayout(QQuickItem *parent = 0);31 explicit UCListItemLayout(QQuickItem *parent = 0);
3232
33 QQuickItem *mainSlot() override;
33 //we don't allow changing the main slot on ListItemLayout because otherwise34 //we don't allow changing the main slot on ListItemLayout because otherwise
34 //accessing title/subtitle/summary would lead to a crash35 //accessing title/subtitle/summary would lead to a crash
35 void setMainSlot(QQuickItem *slot) override;36 void setMainSlot(QQuickItem *slot, bool fireSignal = true) override;
3637
37 UCLabel *title();38 UCLabel *title();
38 UCLabel *subtitle();39 UCLabel *subtitle();
3940
=== modified file 'src/Ubuntu/Components/plugin/ucslotslayout.cpp'
--- src/Ubuntu/Components/plugin/ucslotslayout.cpp 2015-10-12 14:32:17 +0000
+++ src/Ubuntu/Components/plugin/ucslotslayout.cpp 2015-11-10 11:54:07 +0000
@@ -990,13 +990,18 @@
990 }990 }
991 \endqml991 \endqml
992 */992 */
993QQuickItem *UCSlotsLayout::mainSlot()
994{
995 Q_D(const UCSlotsLayout);
996 return d->mainSlot;
997}
993QQuickItem *UCSlotsLayout::mainSlot() const998QQuickItem *UCSlotsLayout::mainSlot() const
994{999{
995 Q_D(const UCSlotsLayout);1000 Q_D(const UCSlotsLayout);
996 return d->mainSlot;1001 return d->mainSlot;
997}1002}
9981003
999void UCSlotsLayout::setMainSlot(QQuickItem *item)1004void UCSlotsLayout::setMainSlot(QQuickItem *item, bool fireSignal)
1000{1005{
1001 Q_D(UCSlotsLayout);1006 Q_D(UCSlotsLayout);
1002 if (d->mainSlot != item && item != Q_NULLPTR) {1007 if (d->mainSlot != item && item != Q_NULLPTR) {
@@ -1008,7 +1013,10 @@
1008 }1013 }
1009 d->mainSlot = item;1014 d->mainSlot = item;
1010 d->mainSlot->setParentItem(this);1015 d->mainSlot->setParentItem(this);
1011 Q_EMIT mainSlotChanged();1016
1017 if (fireSignal) {
1018 Q_EMIT mainSlotChanged();
1019 }
1012 }1020 }
1013}1021}
10141022
10151023
=== modified file 'src/Ubuntu/Components/plugin/ucslotslayout.h'
--- src/Ubuntu/Components/plugin/ucslotslayout.h 2015-09-30 15:53:49 +0000
+++ src/Ubuntu/Components/plugin/ucslotslayout.h 2015-11-10 11:54:07 +0000
@@ -36,8 +36,9 @@
36public:36public:
37 explicit UCSlotsLayout(QQuickItem *parent = 0);37 explicit UCSlotsLayout(QQuickItem *parent = 0);
3838
39 QQuickItem *mainSlot() const;39 virtual QQuickItem *mainSlot();
40 virtual void setMainSlot(QQuickItem *item);40 virtual QQuickItem *mainSlot() const;
41 virtual void setMainSlot(QQuickItem *item, bool fireSignal = true);
4142
42 UCSlotsLayoutPadding *padding();43 UCSlotsLayoutPadding *padding();
4344
4445
=== modified file 'src/Ubuntu/Test/UbuntuTestCase.qml'
--- src/Ubuntu/Test/UbuntuTestCase.qml 2015-09-17 06:29:36 +0000
+++ src/Ubuntu/Test/UbuntuTestCase.qml 2015-11-10 11:54:07 +0000
@@ -34,6 +34,11 @@
34 }34 }
3535
36 /*!36 /*!
37 This property holds the inner TestUtil instance.
38 */
39 property alias testUtil: util
40
41 /*!
37 Find a child from the item based on the objectName.42 Find a child from the item based on the objectName.
38 */43 */
39 function findChild(obj,objectName) {44 function findChild(obj,objectName) {
4045
=== modified file 'tests/unit_x11/tst_components/tst_slotslayout.qml'
--- tests/unit_x11/tst_components/tst_slotslayout.qml 2015-10-01 12:49:42 +0000
+++ tests/unit_x11/tst_components/tst_slotslayout.qml 2015-11-10 11:54:07 +0000
@@ -294,6 +294,10 @@
294 name: "SlotsLayout"294 name: "SlotsLayout"
295 when: windowShown295 when: windowShown
296296
297 function warningMsg(msg) {
298 return testUtil.callerFile() + ": " + msg
299 }
300
297 //Visual rule:301 //Visual rule:
298 //when we have at least one slot which is taller than mainSlot and taller than 4GU,302 //when we have at least one slot which is taller than mainSlot and taller than 4GU,
299 //we want the top and bottom padding to be 1GU instead of 2GU303 //we want the top and bottom padding to be 1GU instead of 2GU
@@ -841,8 +845,33 @@
841845
842 Label {id: customMainSlot }846 Label {id: customMainSlot }
843 function test_warningOnAttemptToChangeListItemLayoutMainSlot() {847 function test_warningOnAttemptToChangeListItemLayoutMainSlot() {
848 ignoreWarning(warningFormat(60, 9, "QML ListItemLayout: Setting a different mainSlot on ListItemLayout is not supported. Please use SlotsLayout instead."))
844 layoutLabels.mainSlot = customMainSlot849 layoutLabels.mainSlot = customMainSlot
845 console.log(warningFormat(60, 9, "QML ListItemLayout: Setting a different mainSlot on ListItemLayout is not supported. Please use SlotsLayout instead."))850 }
851
852
853 Component {
854 id: layoutTestQmlContextComponent
855 ListItemLayout {
856 id: layoutTestQmlContext
857 title.text: "<html><body><p dir='ltr'>TEST <img align=absmiddle height=\"10\" width=\"10\" src=\"file:///test.png\" /> </p></body></html>"
858 title.textFormat: Text.RichText
859 subtitle.text: "<html><body><p dir='ltr'>TEST <img align=absmiddle height=\"10\" width=\"10\" src=\"file:///test.png\" /> </p></body></html>"
860 subtitle.textFormat: Text.RichText
861 summary.text: "<html><body><p dir='ltr'>TEST <img align=absmiddle height=\"10\" width=\"10\" src=\"file:///test.png\" /> </p></body></html>"
862 summary.textFormat: Text.RichText
863 }
864 }
865 //lp#1514173
866 //this will make the test segfault if there is a regression
867 function test_defaultLabelsQmlContext() {
868 ignoreWarning(warningMsg("QML Label: Cannot open: file:///test.png"))
869 var obj = layoutTestQmlContextComponent.createObject(main)
870 //wait for rendering otherwise we will not get the "cannot find file" warning
871 //because the img is loaded async
872 waitForRendering(obj)
873 compare(obj !== null, true, "QML ListItemLayout: testing labels' QML context.")
874 obj.destroy()
846 }875 }
847 }876 }
848}877}

Subscribers

People subscribed via source and target branches