@@ -1,140 +1,140 @@
1−AbstractButton {
2− id: root;
3− property var template;
4− property var components;
5− property var cardData;
6− property var artShapeBorderSource: undefined;
7− property real fontScale: 1.0;
8− property var scopeStyle: null;
9− property int headerAlignment: Text.AlignLeft;
10− property int fixedHeaderHeight: -1;
11− property size fixedArtShapeSize: Qt.size(-1, -1);
12− readonly property string title: cardData && cardData["title"] || "";
13− property bool asynchronous: true;
14− property bool showHeader: true;
15− implicitWidth: childrenRect.width;
1+AbstractButton {
2+ id: root;
3+ property var template;
4+ property var components;
5+ property var cardData;
6+ property var artShapeBorderSource: undefined;
7+ property real fontScale: 1.0;
8+ property var scopeStyle: null;
9+ property int headerAlignment: Text.AlignLeft;
10+ property int fixedHeaderHeight: -1;
11+ property size fixedArtShapeSize: Qt.size(-1, -1);
12+ readonly property string title: cardData && cardData["title"] || "";
13+ property bool asynchronous: true;
14+ property bool showHeader: true;
15+ implicitWidth: childrenRect.width;
1616Loader {
17− id: backgroundLoader;
18− objectName: "backgroundLoader";
19− anchors.fill: parent;
20− asynchronous: root.asynchronous;
21− visible: status == Loader.Ready;
22− sourceComponent: UbuntuShape {
23− objectName: "background";
24− radius: "medium";
25− color: getColor(0) || "white";
26− gradientColor: getColor(1) || color;
27− anchors.fill: parent;
28− image: backgroundImage.source ? backgroundImage : null;
29− property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30− property Image backgroundImage: Image {
31− objectName: "backgroundImage";
32− source: {
33− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34− else if (template && typeof template["card-background"] === "string") return template["card-background"];
35− else return "";
36− }
37− }
38− function getColor(index) {
39− if (cardData && typeof cardData["background"] === "object"
40− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41− return cardData["background"]["elements"][index];
42− } else if (template && typeof template["card-background"] === "object"
43− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44− return template["card-background"]["elements"][index];
45− } else return undefined;
46− }
47− }
17+ id: backgroundLoader;
18+ objectName: "backgroundLoader";
19+ anchors.fill: parent;
20+ asynchronous: root.asynchronous;
21+ visible: status == Loader.Ready;
22+ sourceComponent: UbuntuShape {
23+ objectName: "background";
24+ radius: "medium";
25+ color: getColor(0) || "white";
26+ gradientColor: getColor(1) || color;
27+ anchors.fill: parent;
28+ image: backgroundImage.source ? backgroundImage : null;
29+ property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30+ property Image backgroundImage: Image {
31+ objectName: "backgroundImage";
32+ source: {
33+ if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34+ else if (template && typeof template["card-background"] === "string") return template["card-background"];
35+ else return "";
36+ }
37+ }
38+ function getColor(index) {
39+ if (cardData && typeof cardData["background"] === "object"
40+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41+ return cardData["background"]["elements"][index];
42+ } else if (template && typeof template["card-background"] === "object"
43+ && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44+ return template["card-background"]["elements"][index];
45+ } else return undefined;
46+ }
47+ }
4848 }
4949readonly property size artShapeSize: Qt.size(-1, -1);
5050readonly property int headerHeight: row.height;
51−Row {
52− id: row;
53− objectName: "outerRow";
54− property real margins: units.gu(1);
55− spacing: margins;
56− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
57− anchors { top: parent.top;
51+Row {
52+ id: row;
53+ objectName: "outerRow";
54+ property real margins: units.gu(1);
55+ spacing: margins;
56+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
57+ anchors { top: parent.top;
5858 topMargin: units.gu(1);
5959 left: parent.left;
60− }
61− anchors.right: parent.right;
60+ }
61+ anchors.right: parent.right;
6262 anchors.margins: margins;
6363 anchors.rightMargin: 0;
64− data: [
65−Image {
66− id: mascotImage;
67− objectName: "mascotImage";
68− anchors { verticalCenter: parent.verticalCenter; }
69− readonly property int maxSize: Math.max(width, height) * 4;
70− source: cardData && cardData["mascot"] || "";
71− width: units.gu(6);
72− height: units.gu(5.625);
73− sourceSize { width: maxSize; height: maxSize }
74− fillMode: Image.PreserveAspectCrop;
75− horizontalAlignment: Image.AlignHCenter;
76− verticalAlignment: Image.AlignVCenter;
77− visible: showHeader;
64+ data: [
65+Image {
66+ id: mascotImage;
67+ objectName: "mascotImage";
68+ anchors { verticalCenter: parent.verticalCenter; }
69+ readonly property int maxSize: Math.max(width, height) * 4;
70+ source: cardData && cardData["mascot"] || "";
71+ width: units.gu(6);
72+ height: units.gu(5.625);
73+ sourceSize { width: maxSize; height: maxSize }
74+ fillMode: Image.PreserveAspectCrop;
75+ horizontalAlignment: Image.AlignHCenter;
76+ verticalAlignment: Image.AlignVCenter;
77+ visible: showHeader;
7878 }
7979
80−,Item {
81− id: headerTitleContainer;
82− anchors { verticalCenter: parent.verticalCenter; }
83− width: parent.width - x;
84− implicitHeight: titleLabel.height + subtitleLabel.height + attributesRow.height;
85− data: [
86− Label {
87− id: titleLabel;
88− objectName: "titleLabel";
89− anchors { right: parent.right;
90− rightMargin: units.gu(1);
91− left: parent.left;
92− top: parent.top; }
93− elide: Text.ElideRight;
94− fontSize: "small";
95− wrapMode: Text.Wrap;
96− maximumLineCount: 2;
97− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
98− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
99− visible: showHeader ;
100− text: root.title;
101− font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
102− horizontalAlignment: root.headerAlignment;
80+,Item {
81+ id: headerTitleContainer;
82+ anchors { verticalCenter: parent.verticalCenter; }
83+ width: parent.width - x;
84+ implicitHeight: titleLabel.height + subtitleLabel.height + attributesRow.height;
85+ data: [
86+ Label {
87+ id: titleLabel;
88+ objectName: "titleLabel";
89+ anchors { right: parent.right;
90+ rightMargin: units.gu(1);
91+ left: parent.left;
92+ top: parent.top; }
93+ elide: Text.ElideRight;
94+ fontSize: "small";
95+ wrapMode: Text.Wrap;
96+ maximumLineCount: 2;
97+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
98+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
99+ visible: showHeader ;
100+ text: root.title;
101+ font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
102+ horizontalAlignment: root.headerAlignment;
103103 }
104−,Label {
105− id: subtitleLabel;
106− objectName: "subtitleLabel";
107− anchors { right: parent.right;
108− left: parent.left;
109− rightMargin: units.gu(1);
110− top: titleLabel.bottom;
111− }
112− anchors.topMargin: units.dp(2);
113− elide: Text.ElideRight;
114− fontSize: "small";
115− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
117− visible: titleLabel.visible && titleLabel.text;
118− text: cardData && cardData["subtitle"] || "";
119− font.weight: Font.Light;
120− horizontalAlignment: root.headerAlignment;
104+,Label {
105+ id: subtitleLabel;
106+ objectName: "subtitleLabel";
107+ anchors { right: parent.right;
108+ left: parent.left;
109+ rightMargin: units.gu(1);
110+ top: titleLabel.bottom;
111+ }
112+ anchors.topMargin: units.dp(2);
113+ elide: Text.ElideRight;
114+ fontSize: "small";
115+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
117+ visible: titleLabel.visible && titleLabel.text;
118+ text: cardData && cardData["subtitle"] || "";
119+ font.weight: Font.Light;
120+ horizontalAlignment: root.headerAlignment;
121121 }
122−,CardAttributes {
123− id: attributesRow;
124− objectName: "attributesRow";
122+,CardAttributes {
123+ id: attributesRow;
124+ objectName: "attributesRow";
125125 anchors { right: parent.right;
126126 left: parent.left;
127127 rightMargin: units.gu(1);
128− top: subtitleLabel.bottom;
129− }
130− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
131− model: cardData && cardData["attributes"];
128+ top: subtitleLabel.bottom;
129+ }
130+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
131+ model: cardData && cardData["attributes"];
132132 }
133−
133+
134134 ]
135135 }
136−
137− ]
136+
137+ ]
138138 }
139139UbuntuShape {
140140 id: touchdown;