on df73bd5 help sign in
unity8/qml/Dash/CardHeader.qml
112 lines 3.6 kB history raw
1/*
2 * Copyright (C) 2013 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.0
18import Ubuntu.Components 0.1
20Item {
21 id: root
22 property alias mascot: mascotImage.source
23 property alias title: titleLabel.text
24 property alias subtitle: subtitleLabel.text
25 property alias price: priceLabel.text
26 property alias oldPrice: oldPriceLabel.text
27 property alias altPrice: altPriceLabel.text
29 visible: mascotImage.status === Image.Ready || title || price
30 height: row.height > 0 ? row.height + row.spacing * 2 : 0
32 Row {
33 id: row
34 objectName: "outerRow"
36 anchors { top: parent.top; left: parent.left; right: parent.right; margins: spacing }
37 spacing: units.gu(1)
39 UbuntuShape {
40 id: mascotShape
41 objectName: "mascotShape"
43 width: units.gu(8)
44 height: units.gu(8)
45 visible: image.status === Image.Ready
47 image: Image {
48 id: mascotImage
49 sourceSize { width: mascotShape.width; height: mascotShape.height }
50 }
51 }
53 Column {
54 objectName: "column"
55 width: parent.width - x
57 Label {
58 id: titleLabel
59 anchors { left: parent.left; right: parent.right }
60 elide: Text.ElideRight
61 objectName: "titleLabel"
62 font.weight: Font.DemiBold
63 wrapMode: Text.Wrap
64 maximumLineCount: 2
65 }
67 Label {
68 id: subtitleLabel
69 anchors { left: parent.left; right: parent.right }
70 elide: Text.ElideRight
71 visible: titleLabel.text && text
72 }
74 Row {
75 id: prices
76 objectName: "prices"
77 anchors { left: parent.left; right: parent.right }
79 property int labels: {
80 var labels = 1; // price always visible
81 if (oldPriceLabel.text !== "") labels += 1;
82 if (altPriceLabel.text !== "") labels += 1;
83 return labels;
84 }
85 property real labelWidth: width / labels
87 Label {
88 id: priceLabel
89 width: parent.labelWidth
90 elide: Text.ElideRight
91 font.weight: Font.DemiBold
92 color: Theme.palette.selected.foreground
93 }
95 Label {
96 id: oldPriceLabel
97 objectName: "oldPriceLabel"
98 width: parent.labelWidth
99 elide: Text.ElideRight
100 horizontalAlignment: parent.labels === 3 ? Text.AlignHCenter : Text.AlignRight
101 }
103 Label {
104 id: altPriceLabel
105 width: parent.labelWidth
106 elide: Text.ElideRight
107 horizontalAlignment: Text.AlignRight
108 }
109 }
110 }
111 }