on fd86d64 help sign in
unity8/plugins/Dash/CardAttributes.qml
69 lines 2.6 kB history raw
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.2
18import QtQuick.Layouts 1.1
19import Ubuntu.Components 1.1
20import Ubuntu.Settings.Components 0.1
22GridLayout {
23 id: grid
24 anchors {
25 left: parent.left;
26 right: parent.right;
27 }
28 columns: 2 + repeater.count % 2
29 rowSpacing: units.gu(.5)
30 property alias model: repeater.model
31 property color color: Theme.palette.normal.baseText
32 property real fontScale: 1.0
34 Repeater {
35 id: repeater
36 delegate: Row {
37 spacing: units.gu(0.5)
38 readonly property int column: index % grid.columns;
39 Layout.alignment: {
40 if (column == 0) return Qt.AlignLeft;
41 if (column == grid.columns - 1 || index == repeater.count - 1) return Qt.AlignRight;
42 if (column == 1) return Qt.AlignHCenter;
43 }
44 Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
45 Layout.maximumWidth: Math.max(icon.width, label.x + label.implicitWidth)
46 Layout.fillWidth: true
47 height: units.gu(2)
48 StatusIcon {
49 id: icon
50 height: units.gu(2)
51 sets: ["actions", "status", "apps"]
52 source: "icon" in modelData && modelData["icon"] || ""
53 color: grid.color
54 }
55 Label {
56 id: label
57 width: parent.width - x
58 anchors.verticalCenter: parent.verticalCenter
59 text: "value" in modelData && modelData["value"] || "";
60 elide: Text.ElideRight
61 maximumLineCount: 1
62 font.weight: "style" in modelData && modelData["style"] == "highlighted" ? Font.DemiBold : Font.Light
63 fontSize: "small"
64 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
65 color: grid.color
66 }
67 }
68 }