on xenial help sign in
Fix first column of the preview table to be 25%

This way two consecutive tables have the second column start at the same X coordinate Approved by: Andrea Cimitan

commitf00f521425149e59e45b898738c696c046300fbf authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 9 Nov 2016, 15:04 (10 years ago) parentf91b083daa3a96
2 files changed+28−2
qml/Dash/Previews/PreviewTable.qml+6−1 tests/qmltests/Dash/Previews/tst_PreviewTable.qml+22−1
qml/Dash/Previews/PreviewTable.qml+6−1
@@ -77,7 +77,12 @@ PreviewWidget {
7777 font.weight: index == 0 ? Font.Normal : Font.Light
7878 wrapMode: Text.Wrap
7979 Layout.alignment: Qt.AlignTop
80− Layout.maximumWidth: column.width - x
80+ Layout.minimumHeight: Math.max(units.gu(2.75), contentHeight) // FIXME Reevaluate if we need this once we move away from Qt 5.4
81+ Layout.maximumWidth: index == 0 ? column.width / 3 : column.width - x
82+ Layout.minimumWidth: index == 0 ? column.width / 3 : -1
83+ height: -1 // FIXME Qt 5.4 needs this otherwise wrapped columns
84+ // get the height wrong and the next row looks weird
85+ // remove once we stop supporting Qt 5.4 (if 5.5 doesn't need it)
8186 }
8287 }
8388 }
tests/qmltests/Dash/Previews/tst_PreviewTable.qml+22−1
@@ -31,6 +31,11 @@ Rectangle {
3131 "values": [ [ "Long Label 1", "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
3232 }
3333
34+ property var widgetDataComplete2: {
35+ "title": "Short Title here",
36+ "values": [ [ "Publisher/Creator", "Unity8 team" ], [ "Label A", "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Author", "Best 3v3r"], [ "Summary", "If i knew how to write summaries i'd be working somewhere else"] ]
37+ }
38+
3439 property var widgetDataNoTitle: {
3540 "values": [ [ "Long Label 1", "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
3641 }
@@ -51,6 +56,22 @@ Rectangle {
5156 }
5257 }
5358
59+ PreviewWidgetFactory {
60+ id: previewTable2
61+ anchors { left: parent.left; right: parent.right; top: previewTable.bottom; topMargin: units.gu(4) }
62+ widgetType: "table"
63+
64+ Rectangle {
65+ color: "red"
66+ anchors.fill: parent
67+ opacity: 0.5
68+ }
69+
70+ Component.onCompleted: {
71+ previewTable2.widgetData = widgetDataComplete2
72+ }
73+ }
74+
5475 UT.UnityTestCase {
5576 name: "PreviewTableTest"
5677 when: windowShown
@@ -62,7 +83,7 @@ Rectangle {
6283 function test_label_heights() {
6384 verify(findChild(previewTable, "label00").height == findChild(previewTable, "label10").height);
6485 verify(findChild(previewTable, "label01").height == findChild(previewTable, "label11").height);
65− verify(findChild(previewTable, "label01").height > findChild(previewTable, "label00").height * 3);
86+ verify(findChild(previewTable, "label01").contentHeight > findChild(previewTable, "label00").contentHeight * 3);
6687 verify(findChild(previewTable, "label00").height == findChild(previewTable, "label20").height);
6788 verify(findChild(previewTable, "label20").height == findChild(previewTable, "label21").height);
6889 }