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