@@ -73,23 +73,27 @@ AbstractButton {
73 id: artShape
73 id: artShape
74 radius: "medium"
74 radius: "medium"
75 objectName: "artShape"
75 objectName: "artShape"
77− if (!visible) return 0
78− return image.fillMode === Image.PreserveAspectCrop || aspect < image.aspect ? image.width : height * image.aspect
81− if (!visible) return 0
82− return image.fillMode === Image.PreserveAspectCrop || aspect > image.aspect ? image.height : width / image.aspect
84 anchors.horizontalCenter: template && template["card-layout"] === "horizontal" ? undefined : parent.horizontalCenter
76 anchors.horizontalCenter: template && template["card-layout"] === "horizontal" ? undefined : parent.horizontalCenter
85 anchors.left: template && template["card-layout"] === "horizontal" ? parent.left : undefined
77 anchors.left: template && template["card-layout"] === "horizontal" ? parent.left : undefined
86 visible: cardData && cardData["art"] || false
78 visible: cardData && cardData["art"] || false
88− property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
80+ readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
81+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect
83+ Component.onCompleted: updateWidthHeightBindings();
84+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
86+ function updateWidthHeightBindings() {
87+ if (aspectSmallerThanImageAspect) {
88+ width = Qt.binding(function() { return !visible ? 0 : image.width });
89+ height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
91+ width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
92+ height = Qt.binding(function() { return !visible ? 0 : image.height });
90 image: Image {
96 image: Image {
91− width: template && template["card-layout"] === "horizontal" ? height * artShape.aspect : root.width
92− height: template && template["card-layout"] === "horizontal" ? header.height : width / artShape.aspect
93 objectName: "artImage"
97 objectName: "artImage"
94 source: cardData && cardData["art"] || ""
98 source: cardData && cardData["art"] || ""
95 cache: true
99 cache: true
@@ -98,7 +102,21 @@ AbstractButton {
98 //sourceSize.height: height > width ? height : 0
102 //sourceSize.height: height > width ? height : 0
99 fillMode: components && components["art"]["fill-mode"] === "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop
103 fillMode: components && components["art"]["fill-mode"] === "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop
101− property real aspect: implicitWidth / implicitHeight
105+ readonly property real aspect: implicitWidth / implicitHeight
106+ readonly property bool isHorizontal: template && template["card-layout"] === "horizontal"
108+ Component.onCompleted: updateWidthHeightBindings();
109+ onIsHorizontalChanged: updateWidthHeightBindings();
111+ function updateWidthHeightBindings() {
113+ width = Qt.binding(function() { return height * artShape.aspect });
114+ height = Qt.binding(function() { return header.height });
116+ width = Qt.binding(function() { return root.width });
117+ height = Qt.binding(function() { return width / artShape.aspect });