on 3bbd428 help sign in
unity8/Dash/CardHeader.qml
94 lines 3.0 kB history raw
1import QtQuick 2.0
2import Ubuntu.Components 0.1
4Item {
5 id: root
6 property alias mascot: avatarImage.source
7 property alias title: titleLabel.text
8 property alias subtitle: subtitleLabel.text
9 property alias price: priceLabel.text
10 property alias oldPrice: oldPriceLabel.text
11 property alias altPrice: altPriceLabel.text
13 visible: avatarImage.status === Image.Ready || title || price
14 height: row.height > 0 ? row.height + row.spacing * 2 : 0
16 Row {
17 id: row
19 anchors { top: parent.top; left: parent.left; right: parent.right; margins: spacing }
20 spacing: units.gu(1)
22 UbuntuShape {
23 id: avatarShape
24 objectName: "avatarShape"
26 width: units.gu(8)
27 height: units.gu(8)
28 visible: image.status === Image.Ready
30 image: Image {
31 id: avatarImage
32 sourceSize { width: avatarShape.width; height: avatarShape.height }
33 }
34 }
36 Column {
37 width: parent.width - x - row.spacing
39 Label {
40 id: titleLabel
41 anchors { left: parent.left; right: parent.right }
42 elide: Text.ElideRight
43 objectName: "titleLabel"
44 font.weight: Font.DemiBold
45 wrapMode: Text.Wrap
46 maximumLineCount: 2
47 }
49 Label {
50 id: subtitleLabel
51 anchors { left: parent.left; right: parent.right }
52 elide: Text.ElideRight
53 visible: titleLabel.text && text
54 }
56 Row {
57 id: prices
58 objectName: "prices"
59 anchors { left: parent.left; right: parent.right }
61 property int labels: {
62 var labels = 1; // price always visible
63 if (oldPriceLabel.text !== "") labels += 1;
64 if (altPriceLabel.text !== "") labels += 1;
65 return labels;
66 }
67 property real labelWidth: width / labels
69 Label {
70 id: priceLabel
71 width: parent.labelWidth;
72 elide: Text.ElideRight
73 font.weight: Font.DemiBold
74 color: Theme.palette.selected.foreground
75 }
77 Label {
78 id: oldPriceLabel
79 objectName: "oldPriceLabel"
80 width: parent.labelWidth;
81 elide: Text.ElideRight
82 horizontalAlignment: parent.labels === 3 ? Text.AlignHCenter : Text.AlignRight
83 }
85 Label {
86 id: altPriceLabel
87 width: parent.labelWidth;
88 elide: Text.ElideRight
89 horizontalAlignment: Text.AlignRight
90 }
91 }
92 }
93 }