on xenial help sign in
Conditionally toggle mascot shape.
5ca5084Michał Karnicki
qml/Dash/CardHeader.qml+16−9
@@ -30,6 +30,7 @@ Item {
30 property real fontScale: 1.0
30 property real fontScale: 1.0
31
31
32 property alias headerAlignment: titleLabel.horizontalAlignment
32 property alias headerAlignment: titleLabel.horizontalAlignment
33+ property bool hasBackground: template && template["card-background"] !== undefined
33
34
34 visible: mascotImage.status === Image.Ready || title || price
35 visible: mascotImage.status === Image.Ready || title || price
35 height: row.height > 0 ? row.height + row.margins * 2 : 0
36 height: row.height > 0 ? row.height + row.margins * 2 : 0
@@ -40,13 +41,13 @@ Item {
40
41
41 property real margins: units.gu(1)
42 property real margins: units.gu(1)
42
43
44+ spacing: mascotShape.visible || mascotImage.visible || inOverlay ? units.gu(0.5) : 0
43 anchors {
45 anchors {
44 top: parent.top; left: parent.left; right: parent.right
46 top: parent.top; left: parent.left; right: parent.right
45 margins: margins
47 margins: margins
46 leftMargin: spacing
48 leftMargin: spacing
47 rightMargin: spacing
49 rightMargin: spacing
48 }
50 }
49− spacing: mascotShape.visible || (template && template["overlay"]) ? margins : 0
50
51
51 UbuntuShape {
52 UbuntuShape {
52 id: mascotShape
53 id: mascotShape
@@ -55,17 +56,23 @@ Item {
55 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
56 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
56 width: units.gu(6)
57 width: units.gu(6)
57 height: units.gu(5.625)
58 height: units.gu(5.625)
58− visible: image.status === Image.Ready
59+ visible: !hasBackground && image && image.status === Image.Ready
59 readonly property int maxSize: Math.max(width, height)
60 readonly property int maxSize: Math.max(width, height)
60
61
61− image: Image {
62− id: mascotImage
62+ image: hasBackground ? null : mascotImage
63+ }
63
64
65+ Image {
66+ id: mascotImage
67+
68+ width: source ? mascotShape.width : 0
69+ height: mascotShape.height
70+ visible: hasBackground && status === Image.Ready
71+
64− sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
72+ sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
65− fillMode: Image.PreserveAspectCrop
73+ fillMode: Image.PreserveAspectCrop
66− horizontalAlignment: Image.AlignHCenter
74+ horizontalAlignment: Image.AlignHCenter
67− verticalAlignment: Image.AlignVCenter
75+ verticalAlignment: Image.AlignVCenter
68− }
69 }
76 }
70
77
71 Column {
78 Column {