on xenial help sign in
Don't ignore empty attributes in CardAttributes.qml and improve its encapsulation
commit3dd875d3adaf9885d14e7d3c66b1ed3ac0b102a2 authorMichał Sawicz <michal.sawicz@canonical.com> dateSat 16 Aug 2014, 12:23 (12 years ago) parent5613e47
3 files changed+9−2
plugins/Dash/CardAttributes.qml+4−1 plugins/Dash/CardCreator.js+1 tests/plugins/Dash/tst_CardAttributes.qml+4−1
plugins/Dash/CardAttributes.qml+4−1
@@ -26,8 +26,10 @@ GridLayout {
2626 right: parent.right;
2727 }
2828 columns: 2 + repeater.count % 2
29+ rowSpacing: units.gu(.5)
2930 property alias model: repeater.model
30− property var color
31+ property color color: Theme.palette.normal.baseText
32+ property real fontScale: 1.0
3133
3234 Repeater {
3335 id: repeater
@@ -42,6 +44,7 @@ GridLayout {
4244 Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
4345 Layout.maximumWidth: Math.max(icon.width, label.x + label.implicitWidth)
4446 Layout.fillWidth: true
47+ height: implicitHeight || units.gu(2)
4548 StatusIcon {
4649 id: icon
4750 height: units.gu(2)
plugins/Dash/CardCreator.js+1
@@ -274,6 +274,7 @@ var kAttributesRowCode = 'CardAttributes { \n\
274274 objectName: "attributesRow"; \n\
275275 anchors { %1 } \n\
276276 color: %2; \n\
277+ fontScale: root.fontScale; \n\
277278 model: cardData && cardData["attributes"]; \n\
278279 }\n';
279280
tests/plugins/Dash/tst_CardAttributes.qml+4−1
@@ -26,7 +26,8 @@ Item {
2626 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}],
2727 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3"}],
2828 [{"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"}],
3031 ]
3132
3233 CardAttributes {
@@ -49,6 +50,8 @@ Item {
4950 function test_columns(data) {
5051 cardAttributes.model = data;
5152 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);
5255 }
5356 }
5457}