@@ -78,52 +78,40 @@ var kArtProportionalShapeCode = 'ProportionalShape { \n\
78// %2 is used as image width
78// %2 is used as image width
79// %3 is used as image height
79// %3 is used as image height
80// %4 is whether the image should be visible
80// %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
81+// %5 is whether the loader should be asynchronous or not
83−// %7 is the shape code we want to use
82+// %6 is the shape code we want to use
84−// %8 is injected as code to artImage
83+// %7 is injected as code to artImage
85−// %9 is used as image fallback
84+// %8 is used as image fallback
86var kArtShapeHolderCode = 'Item { \n\
85var kArtShapeHolderCode = 'Item { \n\
87 id: artShapeHolder; \n\
86 id: artShapeHolder; \n\
88− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
87+ height: root.fixedArtShapeSize.height; \n\
89− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
88+ width: root.fixedArtShapeSize.width; \n\
90 anchors { %1 } \n\
89 anchors { %1 } \n\
91 Loader { \n\
90 Loader { \n\
92 id: artShapeLoader; \n\
91 id: artShapeLoader; \n\
93 objectName: "artShapeLoader"; \n\
92 objectName: "artShapeLoader"; \n\
94− readonly property string cardArt: cardData && cardData["art"] || %9; \n\
93+ readonly property string cardArt: cardData && cardData["art"] || %8; \n\
95 onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
94 onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
96 active: cardArt != ""; \n\
95 active: cardArt != ""; \n\
97− asynchronous: %6; \n\
96+ asynchronous: %5; \n\
98 visible: status == Loader.Ready; \n\
97 visible: status == Loader.Ready; \n\
99 sourceComponent: Item { \n\
98 sourceComponent: Item { \n\
100 id: artShape; \n\
99 id: artShape; \n\
101 objectName: "artShape"; \n\
100 objectName: "artShape"; \n\
102 visible: image.status == Image.Ready; \n\
101 visible: image.status == Image.Ready; \n\
103 readonly property alias image: artImage; \n\
102 readonly property alias image: artImage; \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\
104+ width: root.fixedArtShapeSize.width; \n\
111− width = root.fixedArtShapeSize.width; \n\
112− height = root.fixedArtShapeSize.height; \n\
105+ height: root.fixedArtShapeSize.height; \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\
118 CroppedImageMinimumSourceSize { \n\
106 CroppedImageMinimumSourceSize { \n\
119 id: artImage; \n\
107 id: artImage; \n\
120 objectName: "artImage"; \n\
108 objectName: "artImage"; \n\
121 source: artShapeLoader.cardArt; \n\
109 source: artShapeLoader.cardArt; \n\
122− asynchronous: %6; \n\
110+ asynchronous: %5; \n\
123 visible: %4; \n\
111 visible: %4; \n\
124 width: %2; \n\
112 width: %2; \n\
125 height: %3; \n\
113 height: %3; \n\
@@ -133,11 +121,10 @@ var kArtShapeHolderCode = 'Item { \n\
133// %2 is used as image width
121// %2 is used as image width
134// %3 is used as image height
122// %3 is used as image height
135// %4 is whether the image should be visible
123// %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
124+// %5 is whether the loader should be asynchronous or not
138−// %7 is the shape code we want to use
125+// %6 is the shape code we want to use
139−// %8 is injected as code to artImage
126+// %7 is injected as code to artImage
140−// %9 is used as image fallback
127+// %8 is used as image fallback
141var kArtShapeHolderCodeCardToolCard = 'Item { \n\
128var kArtShapeHolderCodeCardToolCard = 'Item { \n\
142 id: artShapeHolder; \n\
129 id: artShapeHolder; \n\
143 height: artShapeLoader.height; \n\
130 height: artShapeLoader.height; \n\
@@ -146,29 +133,28 @@ var kArtShapeHolderCodeCardToolCard = 'Item { \n\
146 Loader { \n\
133 Loader { \n\
147 id: artShapeLoader; \n\
134 id: artShapeLoader; \n\
148 objectName: "artShapeLoader"; \n\
135 objectName: "artShapeLoader"; \n\
149− readonly property string cardArt: cardData && cardData["art"] || %9; \n\
136+ readonly property string cardArt: cardData && cardData["art"] || %8; \n\
150 onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
137 onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
151 active: cardArt != ""; \n\
138 active: cardArt != ""; \n\
152− asynchronous: %6; \n\
139+ asynchronous: %5; \n\
153 visible: status == Loader.Ready; \n\
140 visible: status == Loader.Ready; \n\
154 sourceComponent: Item { \n\
141 sourceComponent: Item { \n\
155 id: artShape; \n\
142 id: artShape; \n\
156 objectName: "artShape"; \n\
143 objectName: "artShape"; \n\
157 visible: image.status == Image.Ready; \n\
144 visible: image.status == Image.Ready; \n\
158 readonly property alias image: artImage; \n\
145 readonly property alias image: artImage; \n\
160− readonly property real aspect: %5; \n\
161 width: image.status !== Image.Ready ? 0 : image.width; \n\
147 width: image.status !== Image.Ready ? 0 : image.width; \n\
162 height: image.status !== Image.Ready ? 0 : image.height; \n\
148 height: image.status !== Image.Ready ? 0 : image.height; \n\
163 CroppedImageMinimumSourceSize { \n\
149 CroppedImageMinimumSourceSize { \n\
164 id: artImage; \n\
150 id: artImage; \n\
165 objectName: "artImage"; \n\
151 objectName: "artImage"; \n\
166 source: artShapeLoader.cardArt; \n\
152 source: artShapeLoader.cardArt; \n\
167− asynchronous: %6; \n\
153+ asynchronous: %5; \n\
168 visible: %4; \n\
154 visible: %4; \n\
169 width: %2; \n\
155 width: %2; \n\
170 height: %3; \n\
156 height: %3; \n\
@@ -529,37 +515,43 @@ function cardString(template, components, isCardTool, artShapeStyle) {
529 if (hasArt) {
515 if (hasArt) {
530 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
516 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
520+ var artShapeAspect = components["art"] && components["art"]["aspect-ratio"] || 1;
521+ if (isNaN(artShapeAspect)) {
525+ artShapeAspect = "(root.fixedArtShapeSize.width / root.fixedArtShapeSize.height)";
532 var widthCode, heightCode;
528 var widthCode, heightCode;
533 var artAnchors;
529 var artAnchors;
534 if (isHorizontal) {
530 if (isHorizontal) {
535 artAnchors = 'left: parent.left';
531 artAnchors = 'left: parent.left';
536 if (hasMascot || hasTitle) {
532 if (hasMascot || hasTitle) {
537− widthCode = 'height * artShape.aspect'
533+ widthCode = 'height * ' + artShapeAspect;
538 heightCode = 'headerHeight + 2 * units.gu(1)';
534 heightCode = 'headerHeight + 2 * units.gu(1)';
540 // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
536 // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
541 // So we define a "random" height of the image height + 2 gu for the margins
537 // So we define a "random" height of the image height + 2 gu for the margins
542− widthCode = 'height * artShape.aspect'
538+ widthCode = 'height * ' + artShapeAspect
543 heightCode = 'units.gu(7.625)';
539 heightCode = 'units.gu(7.625)';
546 artAnchors = 'horizontalCenter: parent.horizontalCenter;';
542 artAnchors = 'horizontalCenter: parent.horizontalCenter;';
547 widthCode = 'root.width'
543 widthCode = 'root.width'
548− heightCode = 'width / artShape.aspect';
544+ heightCode = 'width / ' + artShapeAspect;
551− var aspectRatio = components["art"] && components["art"]["aspect-ratio"] || 1;
552− if (isNaN(aspectRatio)) {
555 var fallback = !isCardTool && components["art"] && components["art"]["fallback"] || "";
547 var fallback = !isCardTool && components["art"] && components["art"]["fallback"] || "";
556 fallback = encodeURI(fallback);
548 fallback = encodeURI(fallback);
557 var fallbackStatusCode = "";
549 var fallbackStatusCode = "";
558 var fallbackURICode = '""';
550 var fallbackURICode = '""';
559 if (fallback !== "") {
551 if (fallback !== "") {
560− // fallbackStatusCode has %9 in it because we want to substitute it for fallbackURICode
552+ // fallbackStatusCode has %8 in it because we want to substitute it for fallbackURICode
561− // which in kArtShapeHolderCode is %9
553+ // which in kArtShapeHolderCode is %8
562− fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %9;';
554+ fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %8;';
563 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
555 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
565 var artShapeHolderShapeCode;
557 var artShapeHolderShapeCode;
@@ -584,7 +576,6 @@ function cardString(template, components, isCardTool, artShapeStyle) {
584 .arg(widthCode)
576 .arg(widthCode)
585 .arg(heightCode)
577 .arg(heightCode)
586 .arg(isConciergeMode ? "true" : "false")
578 .arg(isConciergeMode ? "true" : "false")
588 .arg(asynchronous)
579 .arg(asynchronous)
589 .arg(artShapeHolderShapeCode)
580 .arg(artShapeHolderShapeCode)
590 .arg(fallbackStatusCode)
581 .arg(fallbackStatusCode)
@@ -911,10 +902,6 @@ function cardString(template, components, isCardTool, artShapeStyle) {
911 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
902 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
915−// if (artShapeStyle != "shadow" && artShapeStyle != "icon") {
916−// var touchdownAnchors;
918 if (hasSocialActions) {
905 if (hasSocialActions) {
919 var socialAnchors;
906 var socialAnchors;
920 var socialTopAnchor;
907 var socialTopAnchor;