on xenial help sign in
Fix the bindings
commitd75641d5847abd8d33d2d2bd5415dd0fcdc88297 authorAlbert Astals <albert.astals@canonical.com> dateMon 31 Mar 2014, 13:59 (13 years ago) parent7080a5b
1 file changed+6−6
qml/Dash/Card.qml+6−6
qml/Dash/Card.qml+6−6
@@ -76,17 +76,17 @@ AbstractButton {
7676 visible: cardData && cardData["art"] || false
7777
7878 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
79− readonly property bool useImageWidthForWidth: image.fillMode === Image.PreserveAspectCrop || aspect < image.aspect
79+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect
8080
8181 Component.onCompleted: updateWidthHeightBindings();
82− onUseImageWidthForWidthChanged: updateWidthHeightBindings();
82+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
8383
8484 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 });
85+ if (aspectSmallerThanImageAspect) {
86+ width = Qt.binding(function() { return !visible ? 0 : image.width });
87+ height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
8888 } else {
89− width = Qt.binding(function() { return visible ? height * image.aspect : 0 });
89+ width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
9090 height = Qt.binding(function() { return visible ? image.height : 0 });
9191 }
9292 }