@@ -31,39 +31,44 @@ AbstractButton {
31 property bool showHeader: true
31 property bool showHeader: true
33 implicitWidth: childrenRect.width
33 implicitWidth: childrenRect.width
34− implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
34+ implicitHeight: summary.y + summary.height + (summary.text && backgroundLoader.active ? units.gu(1) : 0)
36− UbuntuShape {
36+ Loader {
37− id: background
37+ id: backgroundLoader
38− objectName: "background"
38+ objectName: "backgroundLoader"
40− visible: template["card-layout"] !== "horizontal" && (template["card-background"] || components["background"]
42− property bool artAndSummary: components["art"]["field"] && components["summary"] || false
43− color: getColor(0) || "white"
44− gradientColor: getColor(1) || color
46− image: backgroundImage.source ? backgroundImage : null
48− property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
40+ readonly property bool artAndSummary: components["art"]["field"] && components["summary"] || false
41+ active: template["card-layout"] !== "horizontal" && (template["card-background"] || components["background"] || artAndSummary)
44+ sourceComponent: UbuntuShape {
45+ objectName: "background"
47+ color: getColor(0) || "white"
48+ gradientColor: getColor(1) || color
50+ image: backgroundImage.source ? backgroundImage : null
52+ property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
50− property Image backgroundImage: Image {
54+ property Image backgroundImage: Image {
51− objectName: "backgroundImage"
55+ objectName: "backgroundImage"
52− source: {
56+ source: {
53− if (cardData && typeof cardData["background"] === "string") return cardData["background"]
57+ if (cardData && typeof cardData["background"] === "string") return cardData["background"]
54− else if (template && typeof template["card-background"] === "string") return template["card-background"]
58+ else if (template && typeof template["card-background"] === "string") return template["card-background"]
55− else return ""
59+ else return ""
59− function getColor(index) {
63+ function getColor(index) {
60− if (cardData && typeof cardData["background"] === "object"
64+ if (cardData && typeof cardData["background"] === "object"
61− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
65+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
62− return cardData["background"]["elements"][index];
66+ return cardData["background"]["elements"][index];
63− } else if (template && typeof template["card-background"] === "object"
67+ } else if (template && typeof template["card-background"] === "object"
64− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
68+ && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
65− return template["card-background"]["elements"][index];
69+ return template["card-background"]["elements"][index];
66− } else return undefined;
70+ } else return undefined;
@@ -187,7 +192,7 @@ AbstractButton {
187 opacity: showHeader ? 1 : 0
192 opacity: showHeader ? 1 : 0
188 inOverlay: root.template && root.template["overlay"] === true
193 inOverlay: root.template && root.template["overlay"] === true
189 fontColor: inOverlay ? "white" : summary.color
194 fontColor: inOverlay ? "white" : summary.color
190− useMascotShape: !background.visible && !inOverlay
195+ useMascotShape: !backgroundLoader.active && !inOverlay
192 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
197 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
@@ -199,7 +204,7 @@ AbstractButton {
199 top: header.visible ? header.bottom : artShape.bottom
204 top: header.visible ? header.bottom : artShape.bottom
200 left: parent.left
205 left: parent.left
201 right: parent.right
206 right: parent.right
202− margins: background.visible ? units.gu(1) : 0
207+ margins: backgroundLoader.active ? units.gu(1) : 0
203 topMargin: 0
208 topMargin: 0
205 wrapMode: Text.Wrap
210 wrapMode: Text.Wrap
@@ -209,6 +214,6 @@ AbstractButton {
209 height: text ? implicitHeight : 0
214 height: text ? implicitHeight : 0
210 fontSize: "small"
215 fontSize: "small"
211 // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
216 // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
212− color: background.visible && background.luminance < 0.7 ? "white" : "grey"
217+ color: backgroundLoader.active && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"