3
3
property var cardData;
4
property string artShapeStyle: "inset";
5
4
property string backgroundShapeStyle: "inset";
6
5
property real fontScale: 1.0;
7
6
property var scopeStyle: null;
8
property size fixedArtShapeSize: Qt.size(-1, -1);
9
7
readonly property string title: cardData && cardData["title"] || "";
10
8
property bool showHeader: true;
11
9
implicitWidth: childrenRect.width;
14
12
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
16
14
id: artShapeHolder;
17
height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
18
width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
15
height: artShapeLoader.height;
16
width: artShapeLoader.width;
19
17
anchors { horizontalCenter: parent.horizontalCenter; }
21
19
id: artShapeLoader;
22
20
objectName: "artShapeLoader";
23
21
readonly property string cardArt: cardData && cardData["art"] || "";
22
onCardArtChanged: { if (item) { item.image.source = cardArt; } }
24
23
active: cardArt != "";
25
24
asynchronous: false;
26
25
visible: status == Loader.Ready;
29
28
objectName: "artShape";
30
29
visible: image.status == Image.Ready;
31
30
readonly property alias image: artImage;
33
32
anchors.fill: parent;
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; }
34
sourceFillMode: UbuntuShape.PreserveAspectCrop;
36
aspect: UbuntuShape.Inset;
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 : 1.6;
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 });
38
width: image.status !== Image.Ready ? 0 : image.width;
39
height: image.status !== Image.Ready ? 0 : image.height;
70
40
CroppedImageMinimumSourceSize {
72
42
objectName: "artImage";
73
43
source: artShapeLoader.cardArt;
74
44
asynchronous: false;
77
height: width / artShape.aspect;