@@ -0,0 +1,217 @@
3+ property var components;
4+ property var cardData;
5+ property string artShapeStyle: "inset";
6+ property string backgroundShapeStyle: "inset";
7+ property real fontScale: 1.0;
8+ property var scopeStyle: null;
9+ property int titleAlignment: 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;
19+ id: backgroundLoader;
20+ objectName: "backgroundLoader";
21+ anchors.fill: parent;
22+ asynchronous: root.asynchronous;
23+ visible: status == Loader.Ready;
24+ sourceComponent: UbuntuShape {
25+ objectName: "background";
28+ switch (root.backgroundShapeStyle) {
29+ case "inset": return UbuntuShape.Inset;
30+ case "shadow": return UbuntuShape.DropShadow;
32+ case "flat": return UbuntuShape.Flat;
35+ backgroundColor: getColor(0) || "white";
36+ secondaryBackgroundColor: getColor(1) || backgroundColor;
37+ backgroundMode: UbuntuShape.VerticalGradient;
38+ anchors.fill: parent;
39+ source: backgroundImage.source ? backgroundImage : null;
40+ property real luminance: Style.luminance(backgroundColor);
41+ property Image backgroundImage: Image {
42+ objectName: "backgroundImage";
44+ if (cardData && typeof cardData["background"] === "string") return cardData["background"];
48+ function getColor(index) {
49+ if (cardData && typeof cardData["background"] === "object"
50+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
51+ return cardData["background"]["elements"][index];
52+ } else return index === 0 ? "#E9E9E9" : undefined;
56+readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
59+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
60+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
61+ anchors { horizontalCenter: parent.horizontalCenter; }
64+ objectName: "artShapeLoader";
65+ active: cardData && cardData["art"] || false;
66+ asynchronous: root.asynchronous;
67+ visible: status == Loader.Ready;
68+ sourceComponent: Item {
70+ objectName: "artShape";
71+ readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true;
72+ visible: image.status == Image.Ready;
73+ readonly property alias image: artImage;
76+ sourceItem: artImage;
77+ anchors.centerIn: parent;
80+ hideSource: doShapeItem;
83+ anchors.fill: parent;
84+ visible: artShape.doShapeItem;
85+ sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
87+ id: artShapeShapeComponent;
89+ source: artShapeSource;
90+ sourceFillMode: UbuntuShape.PreserveAspectCrop;
93+ switch (root.artShapeStyle) {
94+ case "inset": return UbuntuShape.Inset;
95+ case "shadow": return UbuntuShape.DropShadow;
97+ case "flat": return UbuntuShape.Flat;
103+ id: artShapeIconComponent;
104+ ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; }
107+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
108+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
109+ Component.onCompleted: { updateWidthHeightBindings(); }
110+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
111+ function updateWidthHeightBindings() {
112+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
113+ width = root.fixedArtShapeSize.width;
114+ height = root.fixedArtShapeSize.height;
116+ width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
117+ height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
120+ CroppedImageMinimumSourceSize {
122+ objectName: "artImage";
123+ source: cardData && cardData["art"] || "";
124+ asynchronous: root.asynchronous;
126+ height: width / artShape.aspect;
127+ onStatusChanged: if (status === Image.Error) source = decodeURI("%5C");
132+readonly property int headerHeight: row.height;
135+ objectName: "outerRow";
136+ property real margins: units.gu(1);
138+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
139+ anchors { top: artShapeHolder.bottom;
140+ topMargin: units.gu(1);
143+ anchors.right: parent.right;
144+ anchors.margins: margins;
145+ anchors.rightMargin: 0;
147+ CroppedImageMinimumSourceSize {
149+ objectName: "mascotImage";
150+ anchors { verticalCenter: parent.verticalCenter; }
151+ source: cardData && cardData["mascot"] || "";
153+ height: units.gu(5.625);
154+ horizontalAlignment: Image.AlignHCenter;
155+ verticalAlignment: Image.AlignVCenter;
156+ visible: showHeader;
157+ onStatusChanged: if (status === Image.Error) source = decodeURI("%22");
160+ id: headerTitleContainer;
161+ anchors { verticalCenter: parent.verticalCenter; }
162+ width: parent.width - x;
163+ implicitHeight: titleLabel.height + subtitleLabel.height;
167+ objectName: "titleLabel";
168+ anchors { right: parent.right;
169+rightMargin: units.gu(1);
172+ elide: Text.ElideRight;
174+ wrapMode: Text.Wrap;
175+ maximumLineCount: 2;
176+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
177+ 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");
178+ visible: showHeader ;
181+ font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
182+ horizontalAlignment: root.titleAlignment;
186+ objectName: "subtitleLabel";
187+ anchors { right: parent.right;
189+rightMargin: units.gu(1);
190+top: titleLabel.bottom;
192+ anchors.topMargin: units.dp(2);
193+ elide: Text.ElideRight;
194+ maximumLineCount: 1;
195+ fontSize: "x-small";
196+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
197+ 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");
198+ visible: titleLabel.visible && titleLabel.text;
199+ text: cardData && cardData["subtitle"] || "";
200+ font.weight: Font.Light;
210+ objectName: "touchdown";
211+ anchors { fill: backgroundLoader }
212+ visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
214+ borderSource: "radius_pressed.sci"
216+implicitHeight: row.y + row.height + units.gu(1);