on xenial help sign in
Fix first column of the preview table to be 25%
f00f521Albert Astals Cid
qml/Dash/Previews/PreviewTable.qml+6−1
@@ -77,7 +77,12 @@ PreviewWidget {
77 font.weight: index == 0 ? Font.Normal : Font.Light
77 font.weight: index == 0 ? Font.Normal : Font.Light
78 wrapMode: Text.Wrap
78 wrapMode: Text.Wrap
79 Layout.alignment: Qt.AlignTop
79 Layout.alignment: Qt.AlignTop
80+ Layout.minimumHeight: Math.max(units.gu(2.75), contentHeight) // FIXME Reevaluate if we need this once we move away from Qt 5.4
80− Layout.maximumWidth: column.width - x
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)
81 }
86 }
82 }
87 }
83 }
88 }
tests/qmltests/Dash/Previews/tst_PreviewTable.qml+22−1
@@ -31,6 +31,11 @@ Rectangle {
31 "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"] ]
31 "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"] ]
32 }
32 }
33
33
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+
34 property var widgetDataNoTitle: {
39 property var widgetDataNoTitle: {
35 "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"] ]
40 "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"] ]
36 }
41 }
@@ -51,6 +56,22 @@ Rectangle {
51 }
56 }
52 }
57 }
53
58
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+
54 UT.UnityTestCase {
75 UT.UnityTestCase {
55 name: "PreviewTableTest"
76 name: "PreviewTableTest"
56 when: windowShown
77 when: windowShown
@@ -62,7 +83,7 @@ Rectangle {
62 function test_label_heights() {
83 function test_label_heights() {
63 verify(findChild(previewTable, "label00").height == findChild(previewTable, "label10").height);
84 verify(findChild(previewTable, "label00").height == findChild(previewTable, "label10").height);
64 verify(findChild(previewTable, "label01").height == findChild(previewTable, "label11").height);
85 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);
66 verify(findChild(previewTable, "label00").height == findChild(previewTable, "label20").height);
87 verify(findChild(previewTable, "label00").height == findChild(previewTable, "label20").height);
67 verify(findChild(previewTable, "label20").height == findChild(previewTable, "label21").height);
88 verify(findChild(previewTable, "label20").height == findChild(previewTable, "label21").height);
68 }
89 }