on xenial help sign in
Ellide title and values if past the max width
c44da69Albert Astals Cid
qml/Dash/Previews/PreviewTable.qml+4
@@ -37,6 +37,7 @@ PreviewWidget {
37 id: column
37 id: column
38 objectName: "column"
38 objectName: "column"
39 spacing: units.gu(1)
39 spacing: units.gu(1)
40+ width: parent.width
40
41
41 Label {
42 Label {
42 id: titleLabel
43 id: titleLabel
@@ -51,6 +52,7 @@ PreviewWidget {
51 visible: text !== ""
52 visible: text !== ""
52 opacity: .8
53 opacity: .8
53 text: widgetData["title"] || ""
54 text: widgetData["title"] || ""
55+ elide: Text.ElideRight
54 }
56 }
55
57
56 GridLayout {
58 GridLayout {
@@ -72,6 +74,8 @@ PreviewWidget {
72 visible: root.expanded || rowIndex < maximumCollapsedRowCount
74 visible: root.expanded || rowIndex < maximumCollapsedRowCount
73 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
75 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
74 font.bold: index == 0
76 font.bold: index == 0
77+ elide: Text.ElideRight
78+ Layout.maximumWidth: column.width - x
75 }
79 }
76 }
80 }
77 }
81 }
tests/qmltests/Dash/Previews/tst_PreviewTable.qml+4−3
@@ -27,17 +27,18 @@ Rectangle {
27 color: Theme.palette.selected.background
27 color: Theme.palette.selected.background
28
28
29 property var widgetDataComplete: {
29 property var widgetDataComplete: {
30− "title": "Title here",
30+ "title": "Title here longa long long long long long long long long long long",
31− "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
31+ "values": [ [ "Long Label 1", "Value 1"], [ "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 widgetDataNoTitle: {
34 property var widgetDataNoTitle: {
35 "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
35 "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
36 }
36 }
37
37
38− PreviewTable {
38+ PreviewWidgetFactory {
39 id: previewTable
39 id: previewTable
40 anchors { left: parent.left; right: parent.right }
40 anchors { left: parent.left; right: parent.right }
41+ widgetType: "table"
41 widgetData: widgetDataComplete
42 widgetData: widgetDataComplete
42
43
43 Rectangle {
44 Rectangle {