on xenial help sign in
Simplify the code since fixedArtSize code is mandatory for regular cards
commitc138cabed4d1fab4ffc577d92a0bdf77fad5c2be authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 17 Jun 2016, 01:13 (10 years ago) parentc453027f1b4b15
13 files changed+71−143
plugins/Dash/CardCreator.js+38−51 qml/Dash/CardCarousel.qml+1 tests/plugins/Dash/cardcreator/1.res+5−16 tests/plugins/Dash/cardcreator/1.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/11.res+6−17 tests/plugins/Dash/cardcreator/11.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/12.res+5−16 tests/plugins/Dash/cardcreator/12.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/3.res+5−16 tests/plugins/Dash/cardcreator/3.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/5.res+5−16 tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2 tests/qmltests/Dash/tst_Card.qml+1−1
plugins/Dash/CardCreator.js+38−51
@@ -78,52 +78,40 @@ var kArtProportionalShapeCode = 'ProportionalShape { \n\
7878// %2 is used as image width
7979// %3 is used as image height
8080// %4 is whether the image should be visible
81−// %5 is used as aspect ratio fallback
82−// %6 is whether the loader should be asynchronous or not
83−// %7 is the shape code we want to use
84−// %8 is injected as code to artImage
85−// %9 is used as image fallback
81+// %5 is whether the loader should be asynchronous or not
82+// %6 is the shape code we want to use
83+// %7 is injected as code to artImage
84+// %8 is used as image fallback
8685var kArtShapeHolderCode = 'Item { \n\
8786 id: artShapeHolder; \n\
88− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
89− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
87+ height: root.fixedArtShapeSize.height; \n\
88+ width: root.fixedArtShapeSize.width; \n\
9089 anchors { %1 } \n\
9190 Loader { \n\
9291 id: artShapeLoader; \n\
9392 objectName: "artShapeLoader"; \n\
94− readonly property string cardArt: cardData && cardData["art"] || %9; \n\
93+ readonly property string cardArt: cardData && cardData["art"] || %8; \n\
9594 onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
9695 active: cardArt != ""; \n\
97− asynchronous: %6; \n\
96+ asynchronous: %5; \n\
9897 visible: status == Loader.Ready; \n\
9998 sourceComponent: Item { \n\
10099 id: artShape; \n\
101100 objectName: "artShape"; \n\
102101 visible: image.status == Image.Ready; \n\
103102 readonly property alias image: artImage; \n\
104− %7 \n\
105− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
106− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : %5; \n\
107− Component.onCompleted: { updateWidthHeightBindings(); } \n\
108− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
109− function updateWidthHeightBindings() { \n\
110− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
111− width = root.fixedArtShapeSize.width; \n\
112− height = root.fixedArtShapeSize.height; \n\
113− } else { \n\
114− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); \n\
115− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); \n\
116− } \n\
117− } \n\
103+ %6 \n\
104+ width: root.fixedArtShapeSize.width; \n\
105+ height: root.fixedArtShapeSize.height; \n\
118106 CroppedImageMinimumSourceSize { \n\
119107 id: artImage; \n\
120108 objectName: "artImage"; \n\
121109 source: artShapeLoader.cardArt; \n\
122− asynchronous: %6; \n\
110+ asynchronous: %5; \n\
123111 visible: %4; \n\
124112 width: %2; \n\
125113 height: %3; \n\
126− %8 \n\
114+ %7 \n\
127115 } \n\
128116 } \n\
129117 } \n\
@@ -133,11 +121,10 @@ var kArtShapeHolderCode = 'Item { \n\
133121// %2 is used as image width
134122// %3 is used as image height
135123// %4 is whether the image should be visible
136−// %5 is used as aspect ratio
137−// %6 is whether the loader should be asynchronous or not
138−// %7 is the shape code we want to use
139−// %8 is injected as code to artImage
140−// %9 is used as image fallback
124+// %5 is whether the loader should be asynchronous or not
125+// %6 is the shape code we want to use
126+// %7 is injected as code to artImage
127+// %8 is used as image fallback
141128var kArtShapeHolderCodeCardToolCard = 'Item { \n\
142129 id: artShapeHolder; \n\
143130 height: artShapeLoader.height; \n\
@@ -146,29 +133,28 @@ var kArtShapeHolderCodeCardToolCard = 'Item { \n\
146133 Loader { \n\
147134 id: artShapeLoader; \n\
148135 objectName: "artShapeLoader"; \n\
149− readonly property string cardArt: cardData && cardData["art"] || %9; \n\
136+ readonly property string cardArt: cardData && cardData["art"] || %8; \n\
150137 onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
151138 active: cardArt != ""; \n\
152− asynchronous: %6; \n\
139+ asynchronous: %5; \n\
153140 visible: status == Loader.Ready; \n\
154141 sourceComponent: Item { \n\
155142 id: artShape; \n\
156143 objectName: "artShape"; \n\
157144 visible: image.status == Image.Ready; \n\
158145 readonly property alias image: artImage; \n\
159− %7 \n\
160− readonly property real aspect: %5; \n\
146+ %6 \n\
161147 width: image.status !== Image.Ready ? 0 : image.width; \n\
162148 height: image.status !== Image.Ready ? 0 : image.height; \n\
163149 CroppedImageMinimumSourceSize { \n\
164150 id: artImage; \n\
165151 objectName: "artImage"; \n\
166152 source: artShapeLoader.cardArt; \n\
167− asynchronous: %6; \n\
153+ asynchronous: %5; \n\
168154 visible: %4; \n\
169155 width: %2; \n\
170156 height: %3; \n\
171− %8 \n\
157+ %7 \n\
172158 } \n\
173159 } \n\
174160 } \n\
@@ -529,37 +515,43 @@ function cardString(template, components, isCardTool, artShapeStyle) {
529515 if (hasArt) {
530516 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
531517
518+ var artShapeAspect;
519+ if (isCardTool) {
520+ var artShapeAspect = components["art"] && components["art"]["aspect-ratio"] || 1;
521+ if (isNaN(artShapeAspect)) {
522+ artShapeAspect = 1;
523+ }
524+ } else {
525+ artShapeAspect = "(root.fixedArtShapeSize.width / root.fixedArtShapeSize.height)";
526+ }
527+
532528 var widthCode, heightCode;
533529 var artAnchors;
534530 if (isHorizontal) {
535531 artAnchors = 'left: parent.left';
536532 if (hasMascot || hasTitle) {
537− widthCode = 'height * artShape.aspect'
533+ widthCode = 'height * ' + artShapeAspect;
538534 heightCode = 'headerHeight + 2 * units.gu(1)';
539535 } else {
540536 // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
541537 // So we define a "random" height of the image height + 2 gu for the margins
542− widthCode = 'height * artShape.aspect'
538+ widthCode = 'height * ' + artShapeAspect
543539 heightCode = 'units.gu(7.625)';
544540 }
545541 } else {
546542 artAnchors = 'horizontalCenter: parent.horizontalCenter;';
547543 widthCode = 'root.width'
548− heightCode = 'width / artShape.aspect';
544+ heightCode = 'width / ' + artShapeAspect;
549545 }
550546
551− var aspectRatio = components["art"] && components["art"]["aspect-ratio"] || 1;
552− if (isNaN(aspectRatio)) {
553− aspectRatio = 1;
554− }
555547 var fallback = !isCardTool && components["art"] && components["art"]["fallback"] || "";
556548 fallback = encodeURI(fallback);
557549 var fallbackStatusCode = "";
558550 var fallbackURICode = '""';
559551 if (fallback !== "") {
560− // fallbackStatusCode has %9 in it because we want to substitute it for fallbackURICode
561− // which in kArtShapeHolderCode is %9
562− fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %9;';
552+ // fallbackStatusCode has %8 in it because we want to substitute it for fallbackURICode
553+ // which in kArtShapeHolderCode is %8
554+ fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %8;';
563555 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
564556 }
565557 var artShapeHolderShapeCode;
@@ -584,7 +576,6 @@ function cardString(template, components, isCardTool, artShapeStyle) {
584576 .arg(widthCode)
585577 .arg(heightCode)
586578 .arg(isConciergeMode ? "true" : "false")
587− .arg(aspectRatio)
588579 .arg(asynchronous)
589580 .arg(artShapeHolderShapeCode)
590581 .arg(fallbackStatusCode)
@@ -911,10 +902,6 @@ function cardString(template, components, isCardTool, artShapeStyle) {
911902 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
912903 }
913904
914−// <<<<<<< TREE
915−// if (artShapeStyle != "shadow" && artShapeStyle != "icon") {
916−// var touchdownAnchors;
917−// =======
918905 if (hasSocialActions) {
919906 var socialAnchors;
920907 var socialTopAnchor;
qml/Dash/CardCarousel.qml+1
@@ -62,6 +62,7 @@ DashRenderer {
6262 asynchronous: true
6363 onLoaded: {
6464 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
65+ item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
6566 item.height = Qt.binding(function() { return cardTool.cardHeight; });
6667 item.cardData = Qt.binding(function() { return model; });
6768 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
tests/plugins/Dash/cardcreator/1.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
1616 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
17+ height: root.fixedArtShapeSize.height;
18+ width: root.fixedArtShapeSize.width;
1919 anchors { horizontalCenter: parent.horizontalCenter; }
2020 Loader {
2121 id: artShapeLoader;
@@ -37,19 +37,8 @@ Item {
3737 radius: "medium";
3838 aspect: UbuntuShape.Inset;
3939 }
40− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
41− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1.6;
42− Component.onCompleted: { updateWidthHeightBindings(); }
43− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
44− function updateWidthHeightBindings() {
45− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
46− width = root.fixedArtShapeSize.width;
47− height = root.fixedArtShapeSize.height;
48− } else {
49− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
50− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
51− }
52− }
40+ width: root.fixedArtShapeSize.width;
41+ height: root.fixedArtShapeSize.height;
5342 CroppedImageMinimumSourceSize {
5443 id: artImage;
5544 objectName: "artImage";
@@ -57,7 +46,7 @@ Item {
5746 asynchronous: true;
5847 visible: false;
5948 width: root.width;
60− height: width / artShape.aspect;
49+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
6150 }
6251 }
6352 }
tests/plugins/Dash/cardcreator/1.res.cardcreator+1−2
@@ -35,7 +35,6 @@ Item {
3535 radius: "medium";
3636 aspect: UbuntuShape.Inset;
3737 }
38− readonly property real aspect: 1.6;
3938 width: image.status !== Image.Ready ? 0 : image.width;
4039 height: image.status !== Image.Ready ? 0 : image.height;
4140 CroppedImageMinimumSourceSize {
@@ -45,7 +44,7 @@ Item {
4544 asynchronous: false;
4645 visible: false;
4746 width: root.width;
48− height: width / artShape.aspect;
47+ height: width / 1.6;
4948 }
5049 }
5150 }
tests/plugins/Dash/cardcreator/11.res+6−17
@@ -52,8 +52,8 @@ Loader {
5252readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
5353Item {
5454 id: artShapeHolder;
55− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
56− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
55+ height: root.fixedArtShapeSize.height;
56+ width: root.fixedArtShapeSize.width;
5757 anchors { horizontalCenter: parent.horizontalCenter; }
5858 Loader {
5959 id: artShapeLoader;
@@ -75,27 +75,16 @@ Item {
7575 radius: "medium";
7676 aspect: UbuntuShape.Flat;
7777 }
78− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
79− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
80− Component.onCompleted: { updateWidthHeightBindings(); }
81− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
82− function updateWidthHeightBindings() {
83− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
84− width = root.fixedArtShapeSize.width;
85− height = root.fixedArtShapeSize.height;
86− } else {
87− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
88− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
89− }
90− }
91− CroppedImageMinimumSourceSize {
78+ width: root.fixedArtShapeSize.width;
79+ height: root.fixedArtShapeSize.height;
80+ CroppedImageMinimumSourceSize {
9281 id: artImage;
9382 objectName: "artImage";
9483 source: artShapeLoader.cardArt;
9584 asynchronous: true;
9685 visible: false;
9786 width: root.width;
98− height: width / artShape.aspect;
87+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
9988 onStatusChanged: if (status === Image.Error) source = decodeURI("%5C");
10089 }
10190 }
tests/plugins/Dash/cardcreator/11.res.cardcreator+1−2
@@ -73,7 +73,6 @@ Item {
7373 radius: "medium";
7474 aspect: UbuntuShape.Flat;
7575 }
76− readonly property real aspect: 1;
7776 width: image.status !== Image.Ready ? 0 : image.width;
7877 height: image.status !== Image.Ready ? 0 : image.height;
7978 CroppedImageMinimumSourceSize {
@@ -83,7 +82,7 @@ Item {
8382 asynchronous: false;
8483 visible: false;
8584 width: root.width;
86− height: width / artShape.aspect;
85+ height: width / 1;
8786 }
8887 }
8988 }
tests/plugins/Dash/cardcreator/12.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
1616 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
17+ height: root.fixedArtShapeSize.height;
18+ width: root.fixedArtShapeSize.width;
1919 anchors { horizontalCenter: parent.horizontalCenter; }
2020 Loader {
2121 id: artShapeLoader;
@@ -37,19 +37,8 @@ Item {
3737 radius: "medium";
3838 aspect: UbuntuShape.Flat;
3939 }
40− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
41− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75;
42− Component.onCompleted: { updateWidthHeightBindings(); }
43− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
44− function updateWidthHeightBindings() {
45− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
46− width = root.fixedArtShapeSize.width;
47− height = root.fixedArtShapeSize.height;
48− } else {
49− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
50− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
51− }
52− }
40+ width: root.fixedArtShapeSize.width;
41+ height: root.fixedArtShapeSize.height;
5342 CroppedImageMinimumSourceSize {
5443 id: artImage;
5544 objectName: "artImage";
@@ -57,7 +46,7 @@ Item {
5746 asynchronous: true;
5847 visible: false;
5948 width: root.width;
60− height: width / artShape.aspect;
49+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
6150 }
6251 }
6352 }
tests/plugins/Dash/cardcreator/12.res.cardcreator+1−2
@@ -35,7 +35,6 @@ Item {
3535 radius: "medium";
3636 aspect: UbuntuShape.Flat;
3737 }
38− readonly property real aspect: 0.75;
3938 width: image.status !== Image.Ready ? 0 : image.width;
4039 height: image.status !== Image.Ready ? 0 : image.height;
4140 CroppedImageMinimumSourceSize {
@@ -45,7 +44,7 @@ Item {
4544 asynchronous: false;
4645 visible: false;
4746 width: root.width;
48− height: width / artShape.aspect;
47+ height: width / 0.75;
4948 }
5049 }
5150 }
tests/plugins/Dash/cardcreator/3.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
1616 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
17+ height: root.fixedArtShapeSize.height;
18+ width: root.fixedArtShapeSize.width;
1919 anchors { horizontalCenter: parent.horizontalCenter; }
2020 Loader {
2121 id: artShapeLoader;
@@ -35,19 +35,8 @@ Item {
3535 source: artImage;
3636 aspect: UbuntuShape.DropShadow;
3737 }
38− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
39− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75;
40− Component.onCompleted: { updateWidthHeightBindings(); }
41− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
42− function updateWidthHeightBindings() {
43− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
44− width = root.fixedArtShapeSize.width;
45− height = root.fixedArtShapeSize.height;
46− } else {
47− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
48− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
49− }
50− }
38+ width: root.fixedArtShapeSize.width;
39+ height: root.fixedArtShapeSize.height;
5140 CroppedImageMinimumSourceSize {
5241 id: artImage;
5342 objectName: "artImage";
@@ -55,7 +44,7 @@ Item {
5544 asynchronous: true;
5645 visible: false;
5746 width: root.width;
58− height: width / artShape.aspect;
47+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
5948 onStatusChanged: if (status === Image.Error) source = decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22");
6049 }
6150 }
tests/plugins/Dash/cardcreator/3.res.cardcreator+1−2
@@ -33,7 +33,6 @@ Item {
3333 source: artImage;
3434 aspect: UbuntuShape.DropShadow;
3535 }
36− readonly property real aspect: 0.75;
3736 width: image.status !== Image.Ready ? 0 : image.width;
3837 height: image.status !== Image.Ready ? 0 : image.height;
3938 CroppedImageMinimumSourceSize {
@@ -43,7 +42,7 @@ Item {
4342 asynchronous: false;
4443 visible: false;
4544 width: root.width;
46− height: width / artShape.aspect;
45+ height: width / 0.75;
4746 }
4847 }
4948 }
tests/plugins/Dash/cardcreator/5.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
1616 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
17+ height: root.fixedArtShapeSize.height;
18+ width: root.fixedArtShapeSize.width;
1919 anchors { horizontalCenter: parent.horizontalCenter; }
2020 Loader {
2121 id: artShapeLoader;
@@ -30,19 +30,8 @@ Item {
3030 objectName: "artShape";
3131 visible: image.status == Image.Ready;
3232 readonly property alias image: artImage;
33− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
34− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
35− Component.onCompleted: { updateWidthHeightBindings(); }
36− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
37− function updateWidthHeightBindings() {
38− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
39− width = root.fixedArtShapeSize.width;
40− height = root.fixedArtShapeSize.height;
41− } else {
42− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
43− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
44− }
45− }
33+ width: root.fixedArtShapeSize.width;
34+ height: root.fixedArtShapeSize.height;
4635 CroppedImageMinimumSourceSize {
4736 id: artImage;
4837 objectName: "artImage";
@@ -50,7 +39,7 @@ Item {
5039 asynchronous: true;
5140 visible: true;
5241 width: root.width;
53− height: width / artShape.aspect;
42+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
5443 }
5544 }
5645 }
tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2
@@ -28,7 +28,6 @@ Item {
2828 objectName: "artShape";
2929 visible: image.status == Image.Ready;
3030 readonly property alias image: artImage;
31− readonly property real aspect: 1;
3231 width: image.status !== Image.Ready ? 0 : image.width;
3332 height: image.status !== Image.Ready ? 0 : image.height;
3433 CroppedImageMinimumSourceSize {
@@ -38,7 +37,7 @@ Item {
3837 asynchronous: false;
3938 visible: true;
4039 width: root.width;
41− height: width / artShape.aspect;
40+ height: width / 1;
4241 }
4342 }
4443 }
tests/qmltests/Dash/tst_Card.qml+1−1
@@ -362,7 +362,7 @@ Rectangle {
362362 waitForRendering(card);
363363 tryCompare(art, "width", units.gu(8));
364364 tryCompare(art, "height", units.gu(4));
365− tryCompare(art, "fixedArtShapeSizeAspect", 2);
365+ tryCompare(artImage, "width", artImage.height * 2);
366366 }
367367
368368 function test_art_layout_data() {