on xenial help sign in
Don't ignore empty attributes in CardAttributes.qml and improve its encapsulation
3dd875dMichał Sawicz
plugins/Dash/CardAttributes.qml+4−1
@@ -26,8 +26,10 @@ GridLayout {
26 right: parent.right;
26 right: parent.right;
27 }
27 }
28 columns: 2 + repeater.count % 2
28 columns: 2 + repeater.count % 2
29+ rowSpacing: units.gu(.5)
29 property alias model: repeater.model
30 property alias model: repeater.model
30− property var color
31+ property color color: Theme.palette.normal.baseText
32+ property real fontScale: 1.0
31
33
32 Repeater {
34 Repeater {
33 id: repeater
35 id: repeater
@@ -42,6 +44,7 @@ GridLayout {
42 Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
44 Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
43 Layout.maximumWidth: Math.max(icon.width, label.x + label.implicitWidth)
45 Layout.maximumWidth: Math.max(icon.width, label.x + label.implicitWidth)
44 Layout.fillWidth: true
46 Layout.fillWidth: true
47+ height: implicitHeight || units.gu(2)
45 StatusIcon {
48 StatusIcon {
46 id: icon
49 id: icon
47 height: units.gu(2)
50 height: units.gu(2)
plugins/Dash/CardCreator.js+1
@@ -274,6 +274,7 @@ var kAttributesRowCode = 'CardAttributes { \n\
274 objectName: "attributesRow"; \n\
274 objectName: "attributesRow"; \n\
275 anchors { %1 } \n\
275 anchors { %1 } \n\
276 color: %2; \n\
276 color: %2; \n\
277+ fontScale: root.fontScale; \n\
277 model: cardData && cardData["attributes"]; \n\
278 model: cardData && cardData["attributes"]; \n\
278 }\n';
279 }\n';
279
280
tests/plugins/Dash/tst_CardAttributes.qml+4−1
@@ -26,7 +26,8 @@ Item {
26 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}],
26 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}],
27 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3"}],
27 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3"}],
28 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3"},{"value":"text4"}],
28 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3"},{"value":"text4"}],
29− [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3","style":"highlighted"},{"value":"text4","icon":"image://theme/close","style":"highlighted"},{"value":"text5"}]
29+ [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3","style":"highlighted"},{"value":"text4","icon":"image://theme/close","style":"highlighted"},{"value":"text5"}],
30+ [{"value":"text1","icon":"image://theme/ok"},{},{},{},{"value":"text5", "icon": "image://theme/search"}],
30 ]
31 ]
31
32
32 CardAttributes {
33 CardAttributes {
@@ -49,6 +50,8 @@ Item {
49 function test_columns(data) {
50 function test_columns(data) {
50 cardAttributes.model = data;
51 cardAttributes.model = data;
51 compare(cardAttributes.columns, 2 + data.length % 2);
52 compare(cardAttributes.columns, 2 + data.length % 2);
53+ var rows = Math.ceil(data.length / 3);
54+ tryCompare(cardAttributes, "height", rows * units.gu(2) + (rows - 1) * cardAttributes.rowSpacing);
52 }
55 }
53 }
56 }
54}
57}