@@ -0,0 +1,102 @@
1+AbstractButton {
2+ id: root;
3+ property var components;
4+ property var cardData;
5+ property var artShapeBorderSource: undefined;
6+ property real fontScale: 1.0;
7+ property var scopeStyle: null;
8+ property int titleAlignment: Text.AlignLeft;
9+ property int fixedHeaderHeight: -1;
10+ property size fixedArtShapeSize: Qt.size(-1, -1);
11+ readonly property string title: cardData && cardData["title"] || "";
12+ property bool asynchronous: true;
13+ property bool showHeader: true;
14+ implicitWidth: childrenRect.width;
15+ enabled: true;
16+
17+Loader {
18+ id: backgroundLoader;
19+ objectName: "backgroundLoader";
20+ anchors.fill: parent;
21+ asynchronous: root.asynchronous;
22+ visible: status == Loader.Ready;
23+ sourceComponent: UbuntuShape {
24+ objectName: "background";
25+ radius: "medium";
26+ color: getColor(0) || "white";
27+ gradientColor: getColor(1) || color;
28+ anchors.fill: parent;
29+ image: backgroundImage.source ? backgroundImage : null;
30+ property real luminance: Style.luminance(color);
31+ property Image backgroundImage: Image {
32+ objectName: "backgroundImage";
33+ source: {
34+ if (cardData && typeof cardData["background"] === "string") return cardData["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 return index === 0 ? "#E9E9E9" : "#E9AAE9";
43+ }
44+ }
45+ }
46+readonly property size artShapeSize: Qt.size(-1, -1);
47+readonly property int headerHeight: row.height;
48+Row {
49+ id: row;
50+ objectName: "outerRow";
51+ property real margins: units.gu(1);
52+ spacing: margins;
53+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
54+ anchors { top: parent.top;
55+ topMargin: units.gu(1);
56+left: parent.left;
57+ }
58+ anchors.right: parent.right;
59+ anchors.margins: margins;
60+ anchors.rightMargin: 0;
61+ data: [
62+ CroppedImageMinimumSourceSize {
63+ id: mascotImage;
64+ objectName: "mascotImage";
65+ anchors { verticalCenter: parent.verticalCenter; }
66+ source: cardData && cardData["mascot"] || "";
67+ width: units.gu(6);
68+ height: units.gu(5.625);
69+ horizontalAlignment: Image.AlignHCenter;
70+ verticalAlignment: Image.AlignVCenter;
71+ visible: showHeader;
72+ }
73+,Label {
74+ id: titleLabel;
75+ objectName: "titleLabel";
76+ anchors { verticalCenter: parent.verticalCenter;
77+ }
78+ elide: Text.ElideRight;
79+ fontSize: "small";
80+ wrapMode: Text.Wrap;
81+ maximumLineCount: 2;
82+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
83+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
84+ visible: showHeader ;
85+ width: parent.width - x;
86+ text: root.title;
87+ font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
88+ horizontalAlignment: root.titleAlignment;
89+ }
90+
91+ ]
92+ }
93+UbuntuShape {
94+ id: touchdown;
95+ objectName: "touchdown";
96+ anchors { fill: backgroundLoader }
97+ visible: root.pressed;
98+ radius: "medium";
99+ borderSource: "radius_pressed.sci"
100+ }
101+implicitHeight: row.y + row.height + units.gu(1);
102+}