on xenial help sign in
Simplify the code since fixedArtSize code is mandatory for regular cards
c138cabAlbert Astals Cid
plugins/Dash/CardCreator.js+38−51
@@ -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\
104− %7 \n\
103+ %6 \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\
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\
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\
126− %8 \n\
114+ %7 \n\
127 } \n\
115 } \n\
128 } \n\
116 } \n\
129 } \n\
117 } \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\
159− %7 \n\
146+ %6 \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\
171− %8 \n\
157+ %7 \n\
172 } \n\
158 } \n\
173 } \n\
159 } \n\
174 } \n\
160 } \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';
531
517
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+
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)';
539 } else {
535 } else {
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)';
544 }
540 }
545 } else {
541 } else {
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;
549 }
545 }
550
546
551− var aspectRatio = components["art"] && components["art"]["aspect-ratio"] || 1;
552− if (isNaN(aspectRatio)) {
553− aspectRatio = 1;
554− }
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);
564 }
556 }
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")
587− .arg(aspectRatio)
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);
912 }
903 }
913
904
914−// <<<<<<< TREE
915−// if (artShapeStyle != "shadow" && artShapeStyle != "icon") {
916−// var touchdownAnchors;
917−// =======
918 if (hasSocialActions) {
905 if (hasSocialActions) {
919 var socialAnchors;
906 var socialAnchors;
920 var socialTopAnchor;
907 var socialTopAnchor;
qml/Dash/CardCarousel.qml+1
@@ -62,6 +62,7 @@ DashRenderer {
62 asynchronous: true
62 asynchronous: true
63 onLoaded: {
63 onLoaded: {
64 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
64 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
65+ item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
65 item.height = Qt.binding(function() { return cardTool.cardHeight; });
66 item.height = Qt.binding(function() { return cardTool.cardHeight; });
66 item.cardData = Qt.binding(function() { return model; });
67 item.cardData = Qt.binding(function() { return model; });
67 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
68 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
tests/plugins/Dash/cardcreator/1.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
16 id: artShapeHolder;
16 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17+ height: root.fixedArtShapeSize.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
18+ width: root.fixedArtShapeSize.width;
19 anchors { horizontalCenter: parent.horizontalCenter; }
19 anchors { horizontalCenter: parent.horizontalCenter; }
20 Loader {
20 Loader {
21 id: artShapeLoader;
21 id: artShapeLoader;
@@ -37,19 +37,8 @@ Item {
37 radius: "medium";
37 radius: "medium";
38 aspect: UbuntuShape.Inset;
38 aspect: UbuntuShape.Inset;
39 }
39 }
40− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
40+ width: root.fixedArtShapeSize.width;
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;
41+ 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− }
53 CroppedImageMinimumSourceSize {
42 CroppedImageMinimumSourceSize {
54 id: artImage;
43 id: artImage;
55 objectName: "artImage";
44 objectName: "artImage";
@@ -57,7 +46,7 @@ Item {
57 asynchronous: true;
46 asynchronous: true;
58 visible: false;
47 visible: false;
59 width: root.width;
48 width: root.width;
60− height: width / artShape.aspect;
49+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
61 }
50 }
62 }
51 }
63 }
52 }
tests/plugins/Dash/cardcreator/1.res.cardcreator+1−2
@@ -35,7 +35,6 @@ Item {
35 radius: "medium";
35 radius: "medium";
36 aspect: UbuntuShape.Inset;
36 aspect: UbuntuShape.Inset;
37 }
37 }
38− readonly property real aspect: 1.6;
39 width: image.status !== Image.Ready ? 0 : image.width;
38 width: image.status !== Image.Ready ? 0 : image.width;
40 height: image.status !== Image.Ready ? 0 : image.height;
39 height: image.status !== Image.Ready ? 0 : image.height;
41 CroppedImageMinimumSourceSize {
40 CroppedImageMinimumSourceSize {
@@ -45,7 +44,7 @@ Item {
45 asynchronous: false;
44 asynchronous: false;
46 visible: false;
45 visible: false;
47 width: root.width;
46 width: root.width;
48− height: width / artShape.aspect;
47+ height: width / 1.6;
49 }
48 }
50 }
49 }
51 }
50 }
tests/plugins/Dash/cardcreator/11.res+6−17
@@ -52,8 +52,8 @@ Loader {
52readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
52readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
53Item {
53Item {
54 id: artShapeHolder;
54 id: artShapeHolder;
55− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
55+ height: root.fixedArtShapeSize.height;
56− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
56+ width: root.fixedArtShapeSize.width;
57 anchors { horizontalCenter: parent.horizontalCenter; }
57 anchors { horizontalCenter: parent.horizontalCenter; }
58 Loader {
58 Loader {
59 id: artShapeLoader;
59 id: artShapeLoader;
@@ -75,27 +75,16 @@ Item {
75 radius: "medium";
75 radius: "medium";
76 aspect: UbuntuShape.Flat;
76 aspect: UbuntuShape.Flat;
77 }
77 }
78− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
78+ width: root.fixedArtShapeSize.width;
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;
79+ 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 {
80+ CroppedImageMinimumSourceSize {
92 id: artImage;
81 id: artImage;
93 objectName: "artImage";
82 objectName: "artImage";
94 source: artShapeLoader.cardArt;
83 source: artShapeLoader.cardArt;
95 asynchronous: true;
84 asynchronous: true;
96 visible: false;
85 visible: false;
97 width: root.width;
86 width: root.width;
98− height: width / artShape.aspect;
87+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
99 onStatusChanged: if (status === Image.Error) source = decodeURI("%5C");
88 onStatusChanged: if (status === Image.Error) source = decodeURI("%5C");
100 }
89 }
101 }
90 }
tests/plugins/Dash/cardcreator/11.res.cardcreator+1−2
@@ -73,7 +73,6 @@ Item {
73 radius: "medium";
73 radius: "medium";
74 aspect: UbuntuShape.Flat;
74 aspect: UbuntuShape.Flat;
75 }
75 }
76− readonly property real aspect: 1;
77 width: image.status !== Image.Ready ? 0 : image.width;
76 width: image.status !== Image.Ready ? 0 : image.width;
78 height: image.status !== Image.Ready ? 0 : image.height;
77 height: image.status !== Image.Ready ? 0 : image.height;
79 CroppedImageMinimumSourceSize {
78 CroppedImageMinimumSourceSize {
@@ -83,7 +82,7 @@ Item {
83 asynchronous: false;
82 asynchronous: false;
84 visible: false;
83 visible: false;
85 width: root.width;
84 width: root.width;
86− height: width / artShape.aspect;
85+ height: width / 1;
87 }
86 }
88 }
87 }
89 }
88 }
tests/plugins/Dash/cardcreator/12.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
16 id: artShapeHolder;
16 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17+ height: root.fixedArtShapeSize.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
18+ width: root.fixedArtShapeSize.width;
19 anchors { horizontalCenter: parent.horizontalCenter; }
19 anchors { horizontalCenter: parent.horizontalCenter; }
20 Loader {
20 Loader {
21 id: artShapeLoader;
21 id: artShapeLoader;
@@ -37,19 +37,8 @@ Item {
37 radius: "medium";
37 radius: "medium";
38 aspect: UbuntuShape.Flat;
38 aspect: UbuntuShape.Flat;
39 }
39 }
40− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
40+ width: root.fixedArtShapeSize.width;
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) {
41+ height: root.fixedArtShapeSize.height;
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− }
53 CroppedImageMinimumSourceSize {
42 CroppedImageMinimumSourceSize {
54 id: artImage;
43 id: artImage;
55 objectName: "artImage";
44 objectName: "artImage";
@@ -57,7 +46,7 @@ Item {
57 asynchronous: true;
46 asynchronous: true;
58 visible: false;
47 visible: false;
59 width: root.width;
48 width: root.width;
60− height: width / artShape.aspect;
49+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
61 }
50 }
62 }
51 }
63 }
52 }
tests/plugins/Dash/cardcreator/12.res.cardcreator+1−2
@@ -35,7 +35,6 @@ Item {
35 radius: "medium";
35 radius: "medium";
36 aspect: UbuntuShape.Flat;
36 aspect: UbuntuShape.Flat;
37 }
37 }
38− readonly property real aspect: 0.75;
39 width: image.status !== Image.Ready ? 0 : image.width;
38 width: image.status !== Image.Ready ? 0 : image.width;
40 height: image.status !== Image.Ready ? 0 : image.height;
39 height: image.status !== Image.Ready ? 0 : image.height;
41 CroppedImageMinimumSourceSize {
40 CroppedImageMinimumSourceSize {
@@ -45,7 +44,7 @@ Item {
45 asynchronous: false;
44 asynchronous: false;
46 visible: false;
45 visible: false;
47 width: root.width;
46 width: root.width;
48− height: width / artShape.aspect;
47+ height: width / 0.75;
49 }
48 }
50 }
49 }
51 }
50 }
tests/plugins/Dash/cardcreator/3.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
16 id: artShapeHolder;
16 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17+ height: root.fixedArtShapeSize.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
18+ width: root.fixedArtShapeSize.width;
19 anchors { horizontalCenter: parent.horizontalCenter; }
19 anchors { horizontalCenter: parent.horizontalCenter; }
20 Loader {
20 Loader {
21 id: artShapeLoader;
21 id: artShapeLoader;
@@ -35,19 +35,8 @@ Item {
35 source: artImage;
35 source: artImage;
36 aspect: UbuntuShape.DropShadow;
36 aspect: UbuntuShape.DropShadow;
37 }
37 }
38− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
38+ width: root.fixedArtShapeSize.width;
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) {
39+ height: root.fixedArtShapeSize.height;
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− }
51 CroppedImageMinimumSourceSize {
40 CroppedImageMinimumSourceSize {
52 id: artImage;
41 id: artImage;
53 objectName: "artImage";
42 objectName: "artImage";
@@ -55,7 +44,7 @@ Item {
55 asynchronous: true;
44 asynchronous: true;
56 visible: false;
45 visible: false;
57 width: root.width;
46 width: root.width;
58− height: width / artShape.aspect;
47+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
59 onStatusChanged: if (status === Image.Error) source = decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22");
48 onStatusChanged: if (status === Image.Error) source = decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22");
60 }
49 }
61 }
50 }
tests/plugins/Dash/cardcreator/3.res.cardcreator+1−2
@@ -33,7 +33,6 @@ Item {
33 source: artImage;
33 source: artImage;
34 aspect: UbuntuShape.DropShadow;
34 aspect: UbuntuShape.DropShadow;
35 }
35 }
36− readonly property real aspect: 0.75;
37 width: image.status !== Image.Ready ? 0 : image.width;
36 width: image.status !== Image.Ready ? 0 : image.width;
38 height: image.status !== Image.Ready ? 0 : image.height;
37 height: image.status !== Image.Ready ? 0 : image.height;
39 CroppedImageMinimumSourceSize {
38 CroppedImageMinimumSourceSize {
@@ -43,7 +42,7 @@ Item {
43 asynchronous: false;
42 asynchronous: false;
44 visible: false;
43 visible: false;
45 width: root.width;
44 width: root.width;
46− height: width / artShape.aspect;
45+ height: width / 0.75;
47 }
46 }
48 }
47 }
49 }
48 }
tests/plugins/Dash/cardcreator/5.res+5−16
@@ -14,8 +14,8 @@ signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
16 id: artShapeHolder;
16 id: artShapeHolder;
17− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17+ height: root.fixedArtShapeSize.height;
18− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
18+ width: root.fixedArtShapeSize.width;
19 anchors { horizontalCenter: parent.horizontalCenter; }
19 anchors { horizontalCenter: parent.horizontalCenter; }
20 Loader {
20 Loader {
21 id: artShapeLoader;
21 id: artShapeLoader;
@@ -30,19 +30,8 @@ Item {
30 objectName: "artShape";
30 objectName: "artShape";
31 visible: image.status == Image.Ready;
31 visible: image.status == Image.Ready;
32 readonly property alias image: artImage;
32 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;
33+ width: root.fixedArtShapeSize.width;
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;
34+ 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− }
46 CroppedImageMinimumSourceSize {
35 CroppedImageMinimumSourceSize {
47 id: artImage;
36 id: artImage;
48 objectName: "artImage";
37 objectName: "artImage";
@@ -50,7 +39,7 @@ Item {
50 asynchronous: true;
39 asynchronous: true;
51 visible: true;
40 visible: true;
52 width: root.width;
41 width: root.width;
53− height: width / artShape.aspect;
42+ height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
54 }
43 }
55 }
44 }
56 }
45 }
tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2
@@ -28,7 +28,6 @@ Item {
28 objectName: "artShape";
28 objectName: "artShape";
29 visible: image.status == Image.Ready;
29 visible: image.status == Image.Ready;
30 readonly property alias image: artImage;
30 readonly property alias image: artImage;
31− readonly property real aspect: 1;
32 width: image.status !== Image.Ready ? 0 : image.width;
31 width: image.status !== Image.Ready ? 0 : image.width;
33 height: image.status !== Image.Ready ? 0 : image.height;
32 height: image.status !== Image.Ready ? 0 : image.height;
34 CroppedImageMinimumSourceSize {
33 CroppedImageMinimumSourceSize {
@@ -38,7 +37,7 @@ Item {
38 asynchronous: false;
37 asynchronous: false;
39 visible: true;
38 visible: true;
40 width: root.width;
39 width: root.width;
41− height: width / artShape.aspect;
40+ height: width / 1;
42 }
41 }
43 }
42 }
44 }
43 }
tests/qmltests/Dash/tst_Card.qml+1−1
@@ -362,7 +362,7 @@ Rectangle {
362 waitForRendering(card);
362 waitForRendering(card);
363 tryCompare(art, "width", units.gu(8));
363 tryCompare(art, "width", units.gu(8));
364 tryCompare(art, "height", units.gu(4));
364 tryCompare(art, "height", units.gu(4));
365− tryCompare(art, "fixedArtShapeSizeAspect", 2);
365+ tryCompare(artImage, "width", artImage.height * 2);
366 }
366 }
367
367
368 function test_art_layout_data() {
368 function test_art_layout_data() {