4
property string artShapeStyle: "inset";
5
property string backgroundShapeStyle: "inset";
6
property real fontScale: 1.0;
7
property var scopeStyle: null;
8
property size fixedArtShapeSize: Qt.size(-1, -1);
9
readonly property string title: cardData && cardData["title"] || "";
10
property bool showHeader: true;
11
implicitWidth: childrenRect.width;
16
objectName: "backgroundLoader";
19
visible: status == Loader.Ready;
20
sourceComponent: UbuntuShape {
21
objectName: "background";
24
switch (root.backgroundShapeStyle) {
25
case "inset": return UbuntuShape.Inset;
26
case "shadow": return UbuntuShape.DropShadow;
28
case "flat": return UbuntuShape.Flat;
31
backgroundColor: getColor(0) || "white";
32
secondaryBackgroundColor: getColor(1) || backgroundColor;
33
backgroundMode: UbuntuShape.VerticalGradient;
35
source: backgroundImage.source ? backgroundImage : null;
36
property real luminance: Style.luminance(backgroundColor);
37
property Image backgroundImage: Image {
38
objectName: "backgroundImage";
40
if (cardData && typeof cardData["background"] === "string") return cardData["background"];
44
function getColor(index) {
45
if (cardData && typeof cardData["background"] === "object"
46
&& (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
47
return cardData["background"]["elements"][index];
48
} else return index === 0 ? "#E9E9E9" : undefined;
52
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
55
height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
56
width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
57
anchors { horizontalCenter: parent.horizontalCenter; }
60
objectName: "artShapeLoader";
61
readonly property string cardArt: cardData && cardData["art"] || "";
62
active: cardArt != "";
64
visible: status == Loader.Ready;
65
sourceComponent: Item {
67
objectName: "artShape";
68
visible: image.status == Image.Ready;
69
readonly property alias image: artImage;
73
anchors.centerIn: parent;
81
sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
83
id: artShapeShapeComponent;
85
source: artShapeSource;
86
sourceFillMode: UbuntuShape.PreserveAspectCrop;
89
switch (root.artShapeStyle) {
90
case "inset": return UbuntuShape.Inset;
91
case "shadow": return UbuntuShape.DropShadow;
93
case "flat": return UbuntuShape.Flat;
99
id: artShapeIconComponent;
100
ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; }
103
readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
104
readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
105
Component.onCompleted: { updateWidthHeightBindings(); }
106
Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
107
function updateWidthHeightBindings() {
108
if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
109
width = root.fixedArtShapeSize.width;
110
height = root.fixedArtShapeSize.height;
112
width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
113
height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
116
CroppedImageMinimumSourceSize {
118
objectName: "artImage";
119
source: artShapeLoader.cardArt;
122
height: width / artShape.aspect;
127
readonly property int headerHeight: row.height;
130
objectName: "outerRow";
131
property real margins: units.gu(1);
133
anchors { top: artShapeHolder.bottom;
134
topMargin: units.gu(1);
137
anchors.right: parent.right;
138
anchors.margins: margins;
139
anchors.rightMargin: 0;
141
CroppedImageMinimumSourceSize {
143
objectName: "mascotImage";
144
anchors { verticalCenter: parent.verticalCenter; }
145
source: cardData && cardData["mascot"] || "";
147
height: units.gu(5.625);
148
horizontalAlignment: Image.AlignHCenter;
149
verticalAlignment: Image.AlignVCenter;
153
id: headerTitleContainer;
154
anchors { verticalCenter: parent.verticalCenter; }
155
width: parent.width - x;
156
implicitHeight: titleLabel.height + subtitleLabel.height;
160
objectName: "titleLabel";
161
anchors { right: parent.right;
162
rightMargin: units.gu(1);
165
elide: Text.ElideRight;
169
font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
170
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");
171
visible: showHeader ;
174
font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
175
horizontalAlignment: Text.AlignLeft;
179
objectName: "subtitleLabel";
180
anchors { right: parent.right;
182
rightMargin: units.gu(1);
183
top: titleLabel.bottom;
185
anchors.topMargin: units.dp(2);
186
elide: Text.ElideRight;
189
font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
190
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");
191
visible: titleLabel.visible && titleLabel.text;
192
text: cardData && cardData["subtitle"] || "";
193
font.weight: Font.Light;
203
objectName: "touchdown";
204
anchors { fill: backgroundLoader }
205
visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
207
borderSource: "radius_pressed.sci"
209
implicitHeight: row.y + row.height + units.gu(1);