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;
13
signal action(var actionId);
14
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
17
height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
18
width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
19
anchors { horizontalCenter: parent.horizontalCenter; }
22
objectName: "artShapeLoader";
23
readonly property string cardArt: cardData && cardData["art"] || "";
24
active: cardArt != "";
26
visible: status == Loader.Ready;
27
sourceComponent: Item {
29
objectName: "artShape";
30
visible: image.status == Image.Ready;
31
readonly property alias image: artImage;
35
sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
37
id: artShapeShapeComponent;
40
sourceFillMode: UbuntuShape.PreserveAspectCrop;
43
switch (root.artShapeStyle) {
44
case "inset": return UbuntuShape.Inset;
45
case "shadow": return UbuntuShape.DropShadow;
47
case "flat": return UbuntuShape.Flat;
53
id: artShapeIconComponent;
54
ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
57
readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
58
readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75;
59
Component.onCompleted: { updateWidthHeightBindings(); }
60
Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
61
function updateWidthHeightBindings() {
62
if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
63
width = root.fixedArtShapeSize.width;
64
height = root.fixedArtShapeSize.height;
66
width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
67
height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
70
CroppedImageMinimumSourceSize {
72
objectName: "artImage";
73
source: artShapeLoader.cardArt;
77
height: width / artShape.aspect;
82
readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
85
objectName: "titleLabel";
86
anchors { right: parent.right;
88
top: artShapeHolder.bottom;
89
topMargin: units.gu(1);
91
elide: Text.ElideRight;
95
font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
96
color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
100
font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
101
horizontalAlignment: Text.AlignLeft;
105
objectName: "subtitleLabel";
106
anchors { left: titleLabel.left;
107
leftMargin: titleLabel.leftMargin;
108
right: titleLabel.right;
109
top: titleLabel.bottom;
111
anchors.topMargin: units.dp(2);
112
elide: Text.ElideRight;
115
font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116
color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
117
visible: titleLabel.visible && titleLabel.text;
118
text: cardData && cardData["subtitle"] || "";
119
font.weight: Font.Light;
122
id: socialActionsRow;
123
objectName: "socialActionsRow";
124
anchors { top: subtitleLabel.bottom; left: parent.left; right: parent.right; topMargin: units.gu(1); }
125
color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
126
model: cardData && cardData["socialActions"];
127
onClicked: root.action(actionId);
131
objectName: "touchdown";
132
anchors { fill: artShapeHolder }
133
visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
135
borderSource: "radius_pressed.sci"
137
implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);