on 7bb0169 help sign in
unity8/Dash/CardHeader.qml
96 lines 3.0 kB history raw
1import QtQuick 2.0
2import Ubuntu.Components 0.1
4Item {
5 id: root
6 property alias mascot: mascotImage.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: mascotImage.status === Image.Ready || title || price
14 height: row.height > 0 ? row.height + row.spacing * 2 : 0
16 Row {
17 id: row
18 objectName: "outerRow"
20 anchors { top: parent.top; left: parent.left; right: parent.right; margins: spacing }
21 spacing: units.gu(1)
23 UbuntuShape {
24 id: mascotShape
25 objectName: "mascotShape"
27 width: units.gu(8)
28 height: units.gu(8)
29 visible: image.status === Image.Ready
31 image: Image {
32 id: mascotImage
33 sourceSize { width: mascotShape.width; height: mascotShape.height }
34 }
35 }
37 Column {
38 objectName: "column"
39 width: parent.width - x
41 Label {
42 id: titleLabel
43 anchors { left: parent.left; right: parent.right }
44 elide: Text.ElideRight
45 objectName: "titleLabel"
46 font.weight: Font.DemiBold
47 wrapMode: Text.Wrap
48 maximumLineCount: 2
49 }
51 Label {
52 id: subtitleLabel
53 anchors { left: parent.left; right: parent.right }
54 elide: Text.ElideRight
55 visible: titleLabel.text && text
56 }
58 Row {
59 id: prices
60 objectName: "prices"
61 anchors { left: parent.left; right: parent.right }
63 property int labels: {
64 var labels = 1; // price always visible
65 if (oldPriceLabel.text !== "") labels += 1;
66 if (altPriceLabel.text !== "") labels += 1;
67 return labels;
68 }
69 property real labelWidth: width / labels
71 Label {
72 id: priceLabel
73 width: parent.labelWidth
74 elide: Text.ElideRight
75 font.weight: Font.DemiBold
76 color: Theme.palette.selected.foreground
77 }
79 Label {
80 id: oldPriceLabel
81 objectName: "oldPriceLabel"
82 width: parent.labelWidth
83 elide: Text.ElideRight
84 horizontalAlignment: parent.labels === 3 ? Text.AlignHCenter : Text.AlignRight
85 }
87 Label {
88 id: altPriceLabel
89 width: parent.labelWidth
90 elide: Text.ElideRight
91 horizontalAlignment: Text.AlignRight
92 }
93 }
94 }
95 }