on xenial help sign in
Resolve cardArtStyle on compile time

Allow us to not create Components and Shapes that we're not going to use

commit71cdedb51c3f9b1adebf3edf832c26fbeede6a24 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 4 Mar 2016, 14:57 (11 years ago) parent05f351d
41 files changed+155−370
plugins/Dash/CardCreator.js+60−48 plugins/Dash/CardCreatorCache.qml+2−2 qml/Dash/CardCarousel.qml−1 qml/Dash/CardGrid.qml−2 qml/Dash/CardTool.qml+6−2 qml/Dash/GenericScopeView.qml+2−2 tests/plugins/Dash/cardcreator/1.res+7−25 tests/plugins/Dash/cardcreator/1.res.cardcreator+7−25 tests/plugins/Dash/cardcreator/1.tst+1 tests/plugins/Dash/cardcreator/10.res−9 tests/plugins/Dash/cardcreator/10.res.cardcreator−9 tests/plugins/Dash/cardcreator/10.tst+1 tests/plugins/Dash/cardcreator/11.res+10−28 tests/plugins/Dash/cardcreator/11.res.cardcreator+9−27 tests/plugins/Dash/cardcreator/11.tst+1 tests/plugins/Dash/cardcreator/2.res−9 tests/plugins/Dash/cardcreator/2.res.cardcreator−9 tests/plugins/Dash/cardcreator/2.tst+1 tests/plugins/Dash/cardcreator/3.res+4−32 tests/plugins/Dash/cardcreator/3.res.cardcreator+4−32 tests/plugins/Dash/cardcreator/3.tst+1 tests/plugins/Dash/cardcreator/4.res+1−2 tests/plugins/Dash/cardcreator/4.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/4.tst+1 tests/plugins/Dash/cardcreator/5.res+6−32 tests/plugins/Dash/cardcreator/5.res.cardcreator+6−32 tests/plugins/Dash/cardcreator/5.tst+1 tests/plugins/Dash/cardcreator/6.res+1−2 tests/plugins/Dash/cardcreator/6.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/6.tst+1 tests/plugins/Dash/cardcreator/7.res−9 tests/plugins/Dash/cardcreator/7.res.cardcreator−9 tests/plugins/Dash/cardcreator/7.tst+1 tests/plugins/Dash/cardcreator/8.res+1−2 tests/plugins/Dash/cardcreator/8.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/8.tst+1 tests/plugins/Dash/cardcreator/9.res+1−2 tests/plugins/Dash/cardcreator/9.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/9.tst+1 tests/plugins/Dash/cardcreatortest.cpp+9−6 tests/plugins/Dash/cardcreatortest.qml+4−4
plugins/Dash/CardCreator.js+60−48
@@ -59,14 +59,34 @@ var kBackgroundLoaderCode = 'Loader {\n\
5959 } \n\
6060 }\n';
6161
62+// %1 is the visible code
63+// %2 is the aspect of the UbuntuShape
64+var kArtUbuntuShapeCode = 'UbuntuShape { \n\
65+ anchors.fill: parent; \n\
66+ visible: %1; \n\
67+ source: artImage; \n\
68+ sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
69+ radius: "medium"; \n\
70+ aspect: %2; \n\
71+ }';
72+
73+// %1 is the visible code
74+var kArtProportionalShapeCode = 'ProportionalShape { \n\
75+ anchors.fill: parent; \n\
76+ visible: %1; \n\
77+ source: artImage; \n\
78+ aspect: UbuntuShape.DropShadow; \n\
79+ }';
80+
6281// %1 is used as anchors of artShapeHolder
6382// %2 is used as image width
6483// %3 is used as image height
65−// %4 is whether the image or the Loader with the UbuntuShape/ProportionalShape should be visible
84+// %4 is whether the image should be visible
6685// %5 is used as aspect ratio fallback
6786// %6 is whether the loader should be asynchronous or not
68−// %7 is injected as code to artImage
69−// %8 is used as image fallback
87+// %7 is the shape code we want to use
88+// %8 is injected as code to artImage
89+// %9 is used as image fallback
7090var kArtShapeHolderCode = 'Item { \n\
7191 id: artShapeHolder; \n\
7292 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
@@ -75,7 +95,7 @@ var kArtShapeHolderCode = 'Item { \n\
7595 Loader { \n\
7696 id: artShapeLoader; \n\
7797 objectName: "artShapeLoader"; \n\
78− readonly property string cardArt: cardData && cardData["art"] || %8; \n\
98+ readonly property string cardArt: cardData && cardData["art"] || %9; \n\
7999 active: cardArt != ""; \n\
80100 asynchronous: %6; \n\
81101 visible: status == Loader.Ready; \n\
@@ -84,31 +104,7 @@ var kArtShapeHolderCode = 'Item { \n\
84104 objectName: "artShape"; \n\
85105 visible: image.status == Image.Ready; \n\
86106 readonly property alias image: artImage; \n\
87− Loader { \n\
88− anchors.fill: parent; \n\
89− visible: %4; \n\
90− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; \n\
91− Component { \n\
92− id: artShapeShapeComponent; \n\
93− UbuntuShape { \n\
94− source: artImage; \n\
95− sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
96− radius: "medium"; \n\
97− aspect: { \n\
98− switch (root.artShapeStyle) { \n\
99− case "inset": return UbuntuShape.Inset; \n\
100− case "shadow": return UbuntuShape.DropShadow; \n\
101− default: \n\
102− case "flat": return UbuntuShape.Flat; \n\
103− } \n\
104− } \n\
105− } \n\
106− } \n\
107− Component { \n\
108− id: artShapeIconComponent; \n\
109− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; } \n\
110− } \n\
111− } \n\
107+ %7 \n\
112108 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
113109 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : %5; \n\
114110 Component.onCompleted: { updateWidthHeightBindings(); } \n\
@@ -127,10 +123,10 @@ var kArtShapeHolderCode = 'Item { \n\
127123 objectName: "artImage"; \n\
128124 source: artShapeLoader.cardArt; \n\
129125 asynchronous: %6; \n\
130− visible: !%4; \n\
126+ visible: %4; \n\
131127 width: %2; \n\
132128 height: %3; \n\
133− %7 \n\
129+ %8 \n\
134130 } \n\
135131 } \n\
136132 } \n\
@@ -316,7 +312,7 @@ var kTouchdownCode = 'UbuntuShape { \n\
316312 id: touchdown; \n\
317313 objectName: "touchdown"; \n\
318314 anchors { %1 } \n\
319− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; \n\
315+ visible: root.pressed; \n\
320316 radius: "medium"; \n\
321317 borderSource: "radius_pressed.sci" \n\
322318 }\n';
@@ -399,7 +395,7 @@ function sanitizeColor(colorString) {
399395 return colorString;
400396}
401397
402−function cardString(template, components, isCardTool) {
398+function cardString(template, components, isCardTool, artShapeStyle) {
403399 var code;
404400
405401 var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
@@ -407,7 +403,6 @@ function cardString(template, components, isCardTool) {
407403 code = 'AbstractButton { \n\
408404 id: root; \n\
409405 property var cardData; \n\
410− property string artShapeStyle: "inset"; \n\
411406 property string backgroundShapeStyle: "inset"; \n\
412407 property real fontScale: 1.0; \n\
413408 property var scopeStyle: null; \n\
@@ -504,17 +499,32 @@ function cardString(template, components, isCardTool) {
504499 var fallbackStatusCode = "";
505500 var fallbackURICode = '""';
506501 if (fallback !== "") {
507− // fallbackStatusCode has %6 in it because we want to substitute it for fallbackURICode
508− // which in kArtShapeHolderCode is %8
509− fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %8;';
502+ // fallbackStatusCode has %9 in it because we want to substitute it for fallbackURICode
503+ // which in kArtShapeHolderCode is %9
504+ fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %9;';
510505 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
511506 }
507+ var artShapeHolderShapeCode;
508+ if (artShapeStyle === "icon") {
509+ artShapeHolderShapeCode = kArtProportionalShapeCode.arg(isConciergeMode ? "false" : "true");
510+ } else {
511+ var artShapeHolderShapeAspect;
512+ switch (artShapeStyle) {
513+ case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
514+ case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
515+ default:
516+ case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
517+ }
518+ artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(isConciergeMode ? "false" : "true")
519+ .arg(artShapeHolderShapeAspect);
520+ }
512521 code += kArtShapeHolderCode.arg(artAnchors)
513522 .arg(widthCode)
514523 .arg(heightCode)
515− .arg(isConciergeMode ? "false" : "true")
524+ .arg(isConciergeMode ? "true" : "false")
516525 .arg(aspectRatio)
517526 .arg(asynchronous)
527+ .arg(artShapeHolderShapeCode)
518528 .arg(fallbackStatusCode)
519529 .arg(fallbackURICode);
520530 } else {
@@ -839,15 +849,17 @@ function cardString(template, components, isCardTool) {
839849 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
840850 }
841851
842− var touchdownAnchors;
843− if (hasBackground) {
844− touchdownAnchors = 'fill: backgroundLoader';
845− } else if (touchdownOnArtShape) {
846− touchdownAnchors = 'fill: artShapeHolder';
847− } else {
848− touchdownAnchors = 'fill: root'
852+ if (artShapeStyle != "shadow" && artShapeStyle != "icon") {
853+ var touchdownAnchors;
854+ if (hasBackground) {
855+ touchdownAnchors = 'fill: backgroundLoader';
856+ } else if (touchdownOnArtShape) {
857+ touchdownAnchors = 'fill: artShapeHolder';
858+ } else {
859+ touchdownAnchors = 'fill: root'
860+ }
861+ code += kTouchdownCode.arg(touchdownAnchors);
849862 }
850− code += kTouchdownCode.arg(touchdownAnchors);
851863
852864 var implicitHeight = 'implicitHeight: ';
853865 if (hasSummary) {
@@ -880,13 +892,13 @@ function cardString(template, components, isCardTool) {
880892 return code;
881893}
882894
883−function createCardComponent(parent, template, components, isCardTool, identifier) {
895+function createCardComponent(parent, template, components, isCardTool, artShapeStyle, identifier) {
884896 var imports = 'import QtQuick 2.4; \n\
885897 import Ubuntu.Components 1.3; \n\
886898 import Ubuntu.Settings.Components 0.1; \n\
887899 import Dash 0.1;\n\
888900 import Utils 0.1;\n';
889− var card = cardString(template, components, isCardTool);
901+ var card = cardString(template, components, isCardTool, artShapeStyle);
890902 var code = imports + 'Component {\n' + card + '}\n';
891903
892904 try {
plugins/Dash/CardCreatorCache.qml+2−2
@@ -23,7 +23,7 @@ QtObject {
2323
2424 property var cache: new Object();
2525
26− function getCardComponent(template, components, isCardTool) {
26+ function getCardComponent(template, components, isCardTool, artShapeStyle) {
2727 if (template === undefined || components === undefined)
2828 return undefined;
2929
@@ -32,7 +32,7 @@ QtObject {
3232 var allString = tString + cString + isCardTool;
3333 var component = cache[allString];
3434 if (component === undefined) {
35− component = CardCreator.createCardComponent(root, template, components, isCardTool, allString);
35+ component = CardCreator.createCardComponent(root, template, components, isCardTool, artShapeStyle, allString);
3636 cache[allString] = component;
3737 }
3838 return component;
qml/Dash/CardCarousel.qml−1
@@ -66,7 +66,6 @@ DashRenderer {
6666 item.cardData = Qt.binding(function() { return model; });
6767 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
6868 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
69− item.artShapeStyle = "shadow";
7069 item.scopeStyle = cardCarousel.scopeStyle;
7170 }
7271 }
qml/Dash/CardGrid.qml−2
@@ -25,7 +25,6 @@ DashRenderer {
2525 if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2;
2626 return cardTool.template["collapsed-rows"];
2727 }
28− property string artShapeStyle: "inset";
2928 property string backgroundShapeStyle: "inset";
3029 property alias minimumHorizontalSpacing: grid.minimumHorizontalSpacing
3130
@@ -71,7 +70,6 @@ DashRenderer {
7170 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
7271 item.cardData = Qt.binding(function() { return model; });
7372 item.scopeStyle = root.scopeStyle;
74− item.artShapeStyle = root.artShapeStyle;
7573 item.backgroundShapeStyle = root.backgroundShapeStyle;
7674 }
7775 Connections {
qml/Dash/CardTool.qml+6−2
@@ -66,7 +66,11 @@ Item {
6666 return layout;
6767 }
6868
69− property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false);
69+
70+ // Not readonly because gets overwritten from GenericScopeView in some cases
71+ property string artShapeStyle: categoryLayout === "carousel" ? "shadow" : "inset"
72+
73+ property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, artShapeStyle);
7074
7175 // FIXME: Saviq
7276 // Only way for the card below to actually be laid out completely.
@@ -193,7 +197,7 @@ Item {
193197 "summary": "—\n—\n—\n—\n—",
194198 "attributes": attributesModel.model
195199 }
196− sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true);
200+ sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true, artShapeStyle);
197201 onLoaded: {
198202 item.objectName = "cardToolCard";
199203 item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });
qml/Dash/GenericScopeView.qml+2−2
@@ -364,10 +364,10 @@ FocusScope {
364364 if (scope && scope.id === "clickscope") {
365365 if (categoryId === "predefined" || categoryId === "local") {
366366 cardTool.artShapeSize = Qt.binding(function() { return Qt.size(units.gu(8), units.gu(7.5)) });
367− item.artShapeStyle = "icon";
367+ cardTool.artShapeStyle = "icon";
368368 } else {
369369 // Should be ubuntu store icon
370− item.artShapeStyle = "flat";
370+ cardTool.artShapeStyle = "flat";
371371 item.backgroundShapeStyle = "shadow";
372372 }
373373 }
tests/plugins/Dash/cardcreator/1.res+7−25
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -30,30 +29,13 @@ Item {
3029 objectName: "artShape";
3130 visible: image.status == Image.Ready;
3231 readonly property alias image: artImage;
33− Loader {
32+ UbuntuShape {
3433 anchors.fill: parent;
3534 visible: true;
36− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
37− Component {
38− id: artShapeShapeComponent;
39− UbuntuShape {
40− source: artImage;
41− sourceFillMode: UbuntuShape.PreserveAspectCrop;
42− radius: "medium";
43− aspect: {
44− switch (root.artShapeStyle) {
45− case "inset": return UbuntuShape.Inset;
46− case "shadow": return UbuntuShape.DropShadow;
47− default:
48− case "flat": return UbuntuShape.Flat;
49− }
50− }
51− }
52− }
53− Component {
54− id: artShapeIconComponent;
55− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
56− }
35+ source: artImage;
36+ sourceFillMode: UbuntuShape.PreserveAspectCrop;
37+ radius: "medium";
38+ aspect: UbuntuShape.Inset;
5739 }
5840 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5941 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1.6;
@@ -73,7 +55,7 @@ Item {
7355 objectName: "artImage";
7456 source: artShapeLoader.cardArt;
7557 asynchronous: true;
76− visible: !true;
58+ visible: false;
7759 width: root.width;
7860 height: width / artShape.aspect;
7961 }
@@ -105,7 +87,7 @@ UbuntuShape {
10587 id: touchdown;
10688 objectName: "touchdown";
10789 anchors { fill: artShapeHolder }
108− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
90+ visible: root.pressed;
10991 radius: "medium";
11092 borderSource: "radius_pressed.sci"
11193}
tests/plugins/Dash/cardcreator/1.res.cardcreator+7−25
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -29,30 +28,13 @@ Item {
2928 objectName: "artShape";
3029 visible: image.status == Image.Ready;
3130 readonly property alias image: artImage;
32− Loader {
31+ UbuntuShape {
3332 anchors.fill: parent;
3433 visible: true;
35− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
36− Component {
37− id: artShapeShapeComponent;
38− UbuntuShape {
39− source: artImage;
40− sourceFillMode: UbuntuShape.PreserveAspectCrop;
41− radius: "medium";
42− aspect: {
43− switch (root.artShapeStyle) {
44− case "inset": return UbuntuShape.Inset;
45− case "shadow": return UbuntuShape.DropShadow;
46− default:
47− case "flat": return UbuntuShape.Flat;
48− }
49− }
50− }
51− }
52− Component {
53− id: artShapeIconComponent;
54− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
55− }
34+ source: artImage;
35+ sourceFillMode: UbuntuShape.PreserveAspectCrop;
36+ radius: "medium";
37+ aspect: UbuntuShape.Inset;
5638 }
5739 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5840 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1.6;
@@ -72,7 +54,7 @@ Item {
7254 objectName: "artImage";
7355 source: artShapeLoader.cardArt;
7456 asynchronous: false;
75− visible: !true;
57+ visible: false;
7658 width: root.width;
7759 height: width / artShape.aspect;
7860 }
@@ -104,7 +86,7 @@ UbuntuShape {
10486 id: touchdown;
10587 objectName: "touchdown";
10688 anchors { fill: artShapeHolder }
107− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
89+ visible: root.pressed;
10890 radius: "medium";
10991 borderSource: "radius_pressed.sci"
11092}
tests/plugins/Dash/cardcreator/1.tst+1
@@ -1,3 +1,4 @@
11template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":1.6,"field":"art"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: inset
34result: 1.res
tests/plugins/Dash/cardcreator/10.res−9
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -127,13 +126,5 @@ top: titleLabel.bottom;
127126
128127 ]
129128 }
130−UbuntuShape {
131− id: touchdown;
132− objectName: "touchdown";
133− anchors { fill: backgroundLoader }
134− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
135− radius: "medium";
136− borderSource: "radius_pressed.sci"
137− }
138129implicitHeight: row.y + row.height + units.gu(1);
139130}
tests/plugins/Dash/cardcreator/10.res.cardcreator−9
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -125,13 +124,5 @@ top: titleLabel.bottom;
125124
126125 ]
127126 }
128−UbuntuShape {
129− id: touchdown;
130− objectName: "touchdown";
131− anchors { fill: backgroundLoader }
132− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
133− radius: "medium";
134− borderSource: "radius_pressed.sci"
135− }
136127implicitHeight: row.y + row.height + units.gu(1);
137128}
tests/plugins/Dash/cardcreator/10.tst+1
@@ -1,3 +1,4 @@
11template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2, "card-background": { "type": "color", "elements": [ "\\", ": 3; } Item { } function moo () { \"" ] } }
22components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: shadow
34result: 10.res
tests/plugins/Dash/cardcreator/11.res+10−28
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -68,32 +67,15 @@ Item {
6867 objectName: "artShape";
6968 visible: image.status == Image.Ready;
7069 readonly property alias image: artImage;
71− Loader {
72− anchors.fill: parent;
70+ UbuntuShape {
71+ anchors.fill: parent;
7372 visible: true;
74− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
75− Component {
76− id: artShapeShapeComponent;
77− UbuntuShape {
78− source: artImage;
79− sourceFillMode: UbuntuShape.PreserveAspectCrop;
80− radius: "medium";
81− aspect: {
82− switch (root.artShapeStyle) {
83− case "inset": return UbuntuShape.Inset;
84− case "shadow": return UbuntuShape.DropShadow;
85− default:
86− case "flat": return UbuntuShape.Flat;
87− }
88− }
89− }
90− }
91− Component {
92− id: artShapeIconComponent;
93− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
94− }
95− }
96− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
73+ source: artImage;
74+ sourceFillMode: UbuntuShape.PreserveAspectCrop;
75+ radius: "medium";
76+ aspect: UbuntuShape.Flat;
77+ }
78+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
9779 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
9880 Component.onCompleted: { updateWidthHeightBindings(); }
9981 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
@@ -111,7 +93,7 @@ Item {
11193 objectName: "artImage";
11294 source: artShapeLoader.cardArt;
11395 asynchronous: true;
114− visible: !true;
96+ visible: false;
11597 width: root.width;
11698 height: width / artShape.aspect;
11799 onStatusChanged: if (status === Image.Error) source = decodeURI("%5C");
@@ -199,7 +181,7 @@ UbuntuShape {
199181 id: touchdown;
200182 objectName: "touchdown";
201183 anchors { fill: backgroundLoader }
202− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
184+ visible: root.pressed;
203185 radius: "medium";
204186 borderSource: "radius_pressed.sci"
205187 }
tests/plugins/Dash/cardcreator/11.res.cardcreator+9−27
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -67,31 +66,14 @@ Item {
6766 objectName: "artShape";
6867 visible: image.status == Image.Ready;
6968 readonly property alias image: artImage;
70− Loader {
71− anchors.fill: parent;
69+ UbuntuShape {
70+ anchors.fill: parent;
7271 visible: true;
73− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
74− Component {
75− id: artShapeShapeComponent;
76− UbuntuShape {
77− source: artImage;
78− sourceFillMode: UbuntuShape.PreserveAspectCrop;
79− radius: "medium";
80− aspect: {
81− switch (root.artShapeStyle) {
82− case "inset": return UbuntuShape.Inset;
83− case "shadow": return UbuntuShape.DropShadow;
84− default:
85− case "flat": return UbuntuShape.Flat;
86− }
87− }
88− }
89− }
90− Component {
91− id: artShapeIconComponent;
92− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
93− }
94− }
72+ source: artImage;
73+ sourceFillMode: UbuntuShape.PreserveAspectCrop;
74+ radius: "medium";
75+ aspect: UbuntuShape.Flat;
76+ }
9577 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
9678 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
9779 Component.onCompleted: { updateWidthHeightBindings(); }
@@ -110,7 +92,7 @@ Item {
11092 objectName: "artImage";
11193 source: artShapeLoader.cardArt;
11294 asynchronous: false;
113− visible: !true;
95+ visible: false;
11496 width: root.width;
11597 height: width / artShape.aspect;
11698 }
@@ -195,7 +177,7 @@ UbuntuShape {
195177 id: touchdown;
196178 objectName: "touchdown";
197179 anchors { fill: backgroundLoader }
198− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
180+ visible: root.pressed;
199181 radius: "medium";
200182 borderSource: "radius_pressed.sci"
201183 }
tests/plugins/Dash/cardcreator/11.tst+1
@@ -1,3 +1,4 @@
11template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2 }
22components: {"art":{"aspect-ratio":1,"field":"art","fallback":"\\"},"background":{"field":"background"},"mascot":{"field":"icon","fallback":"\""},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: flat
34result: 11.res
tests/plugins/Dash/cardcreator/2.res−9
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -126,13 +125,5 @@ CroppedImageMinimumSourceSize {
126125
127126 ]
128127 }
129−UbuntuShape {
130− id: touchdown;
131− objectName: "touchdown";
132− anchors { fill: backgroundLoader }
133− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
134− radius: "medium";
135− borderSource: "radius_pressed.sci"
136−}
137128implicitHeight: row.y + row.height + units.gu(1);
138129}
tests/plugins/Dash/cardcreator/2.res.cardcreator−9
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -124,13 +123,5 @@ CroppedImageMinimumSourceSize {
124123
125124 ]
126125 }
127−UbuntuShape {
128− id: touchdown;
129− objectName: "touchdown";
130− anchors { fill: backgroundLoader }
131− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
132− radius: "medium";
133− borderSource: "radius_pressed.sci"
134−}
135126implicitHeight: row.y + row.height + units.gu(1);
136127}
tests/plugins/Dash/cardcreator/2.tst+1
@@ -1,3 +1,4 @@
11template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: icon
34result: 2.res
tests/plugins/Dash/cardcreator/3.res+4−32
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -30,30 +29,11 @@ Item {
3029 objectName: "artShape";
3130 visible: image.status == Image.Ready;
3231 readonly property alias image: artImage;
33− Loader {
32+ ProportionalShape {
3433 anchors.fill: parent;
3534 visible: true;
36− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
37− Component {
38− id: artShapeShapeComponent;
39− UbuntuShape {
40− source: artImage;
41− sourceFillMode: UbuntuShape.PreserveAspectCrop;
42− radius: "medium";
43− aspect: {
44− switch (root.artShapeStyle) {
45− case "inset": return UbuntuShape.Inset;
46− case "shadow": return UbuntuShape.DropShadow;
47− default:
48− case "flat": return UbuntuShape.Flat;
49− }
50− }
51− }
52− }
53− Component {
54− id: artShapeIconComponent;
55− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
56− }
35+ source: artImage;
36+ aspect: UbuntuShape.DropShadow;
5737 }
5838 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5939 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75;
@@ -73,7 +53,7 @@ Item {
7353 objectName: "artImage";
7454 source: artShapeLoader.cardArt;
7555 asynchronous: true;
76− visible: !true;
56+ visible: false;
7757 width: root.width;
7858 height: width / artShape.aspect;
7959 onStatusChanged: if (status === Image.Error) source = decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22");
@@ -120,13 +100,5 @@ Label {
120100 text: cardData && cardData["subtitle"] || "";
121101 font.weight: Font.Light;
122102 }
123−UbuntuShape {
124− id: touchdown;
125− objectName: "touchdown";
126− anchors { fill: artShapeHolder }
127− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
128− radius: "medium";
129− borderSource: "radius_pressed.sci"
130−}
131103implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
132104}
tests/plugins/Dash/cardcreator/3.res.cardcreator+4−32
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -29,30 +28,11 @@ Item {
2928 objectName: "artShape";
3029 visible: image.status == Image.Ready;
3130 readonly property alias image: artImage;
32− Loader {
31+ ProportionalShape {
3332 anchors.fill: parent;
3433 visible: true;
35− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
36− Component {
37− id: artShapeShapeComponent;
38− UbuntuShape {
39− source: artImage;
40− sourceFillMode: UbuntuShape.PreserveAspectCrop;
41− radius: "medium";
42− aspect: {
43− switch (root.artShapeStyle) {
44− case "inset": return UbuntuShape.Inset;
45− case "shadow": return UbuntuShape.DropShadow;
46− default:
47− case "flat": return UbuntuShape.Flat;
48− }
49− }
50− }
51− }
52− Component {
53− id: artShapeIconComponent;
54− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
55− }
34+ source: artImage;
35+ aspect: UbuntuShape.DropShadow;
5636 }
5737 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5838 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75;
@@ -72,7 +52,7 @@ Item {
7252 objectName: "artImage";
7353 source: artShapeLoader.cardArt;
7454 asynchronous: false;
75− visible: !true;
55+ visible: false;
7656 width: root.width;
7757 height: width / artShape.aspect;
7858 }
@@ -118,13 +98,5 @@ Label {
11898 text: cardData && cardData["subtitle"] || "";
11999 font.weight: Font.Light;
120100 }
121−UbuntuShape {
122− id: touchdown;
123− objectName: "touchdown";
124− anchors { fill: artShapeHolder }
125− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
126− radius: "medium";
127− borderSource: "radius_pressed.sci"
128−}
129101implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
130102}
tests/plugins/Dash/cardcreator/3.tst+1
@@ -1,3 +1,4 @@
11template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":0.75,"field":"art","fallback":"IHAVE\\\"ESCAPED\\\"QUOTES\\\""},"subtitle":{"field":"price"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: icon
34result: 3.res
tests/plugins/Dash/cardcreator/4.res+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -103,7 +102,7 @@ UbuntuShape {
103102 id: touchdown;
104103 objectName: "touchdown";
105104 anchors { fill: root }
106− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
105+ visible: root.pressed;
107106 radius: "medium";
108107 borderSource: "radius_pressed.sci"
109108}
tests/plugins/Dash/cardcreator/4.res.cardcreator+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -101,7 +100,7 @@ UbuntuShape {
101100 id: touchdown;
102101 objectName: "touchdown";
103102 anchors { fill: root }
104− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
103+ visible: root.pressed;
105104 radius: "medium";
106105 borderSource: "radius_pressed.sci"
107106}
tests/plugins/Dash/cardcreator/4.tst+1
@@ -1,3 +1,4 @@
11template: {"card-layout":"horizontal","card-size":"large","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":1},"mascot":{"field":"mascot"},"subtitle":{"field":"domain"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: flat
34result: 4.res
tests/plugins/Dash/cardcreator/5.res+6−32
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -30,30 +29,13 @@ Item {
3029 objectName: "artShape";
3130 visible: image.status == Image.Ready;
3231 readonly property alias image: artImage;
33− Loader {
32+ UbuntuShape {
3433 anchors.fill: parent;
3534 visible: false;
36− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
37− Component {
38− id: artShapeShapeComponent;
39− UbuntuShape {
40− source: artImage;
41− sourceFillMode: UbuntuShape.PreserveAspectCrop;
42− radius: "medium";
43− aspect: {
44− switch (root.artShapeStyle) {
45− case "inset": return UbuntuShape.Inset;
46− case "shadow": return UbuntuShape.DropShadow;
47− default:
48− case "flat": return UbuntuShape.Flat;
49− }
50− }
51− }
52− }
53− Component {
54− id: artShapeIconComponent;
55− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
56− }
35+ source: artImage;
36+ sourceFillMode: UbuntuShape.PreserveAspectCrop;
37+ radius: "medium";
38+ aspect: UbuntuShape.DropShadow;
5739 }
5840 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5941 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
@@ -73,7 +55,7 @@ Item {
7355 objectName: "artImage";
7456 source: artShapeLoader.cardArt;
7557 asynchronous: true;
76− visible: !false;
58+ visible: true;
7759 width: root.width;
7860 height: width / artShape.aspect;
7961 }
@@ -138,13 +120,5 @@ Label {
138120 text: cardData && cardData["subtitle"] || "";
139121 font.weight: Font.Light;
140122 }
141−UbuntuShape {
142− id: touchdown;
143− objectName: "touchdown";
144− anchors { fill: artShapeHolder }
145− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
146− radius: "medium";
147− borderSource: "radius_pressed.sci"
148−}
149123implicitHeight: artShapeHolder.height;
150124}
tests/plugins/Dash/cardcreator/5.res.cardcreator+6−32
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -29,30 +28,13 @@ Item {
2928 objectName: "artShape";
3029 visible: image.status == Image.Ready;
3130 readonly property alias image: artImage;
32− Loader {
31+ UbuntuShape {
3332 anchors.fill: parent;
3433 visible: false;
35− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
36− Component {
37− id: artShapeShapeComponent;
38− UbuntuShape {
39− source: artImage;
40− sourceFillMode: UbuntuShape.PreserveAspectCrop;
41− radius: "medium";
42− aspect: {
43− switch (root.artShapeStyle) {
44− case "inset": return UbuntuShape.Inset;
45− case "shadow": return UbuntuShape.DropShadow;
46− default:
47− case "flat": return UbuntuShape.Flat;
48− }
49− }
50− }
51− }
52− Component {
53− id: artShapeIconComponent;
54− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
55− }
34+ source: artImage;
35+ sourceFillMode: UbuntuShape.PreserveAspectCrop;
36+ radius: "medium";
37+ aspect: UbuntuShape.DropShadow;
5638 }
5739 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5840 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
@@ -72,7 +54,7 @@ Item {
7254 objectName: "artImage";
7355 source: artShapeLoader.cardArt;
7456 asynchronous: false;
75− visible: !false;
57+ visible: true;
7658 width: root.width;
7759 height: width / artShape.aspect;
7860 }
@@ -137,13 +119,5 @@ Label {
137119 text: cardData && cardData["subtitle"] || "";
138120 font.weight: Font.Light;
139121 }
140−UbuntuShape {
141− id: touchdown;
142− objectName: "touchdown";
143− anchors { fill: artShapeHolder }
144− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
145− radius: "medium";
146− borderSource: "radius_pressed.sci"
147−}
148122implicitHeight: artShapeHolder.height;
149123}
tests/plugins/Dash/cardcreator/5.tst+1
@@ -1,3 +1,4 @@
11template: {"non-interactive":true,"card-layout":"vertical","card-size":"medium","category-layout":"carousel","collapsed-rows":2,"overlay":true}
22components: {"art":{"aspect-ratio":1,"field":"art","conciergeMode":true},"subtitle":{"field":"artist"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: shadow
34result: 5.res
tests/plugins/Dash/cardcreator/6.res+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -119,7 +118,7 @@ UbuntuShape {
119118 id: touchdown;
120119 objectName: "touchdown";
121120 anchors { fill: backgroundLoader }
122− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
121+ visible: root.pressed;
123122 radius: "medium";
124123 borderSource: "radius_pressed.sci"
125124}
tests/plugins/Dash/cardcreator/6.res.cardcreator+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -118,7 +117,7 @@ UbuntuShape {
118117 id: touchdown;
119118 objectName: "touchdown";
120119 anchors { fill: backgroundLoader }
121− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
120+ visible: root.pressed;
122121 radius: "medium";
123122 borderSource: "radius_pressed.sci"
124123}
tests/plugins/Dash/cardcreator/6.tst+1
@@ -1,3 +1,4 @@
11template: {"card-background":"http://assets.ubuntu.com/sites/ubuntu/latest/u/img/logos/logo-ubuntu-grey.png","card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"subtitle":{"field":"author"},"title":{"field":"title"},"emblem":{"field":"source"},"attributes":{}}
3+artShapeStyle: inset
34result: 6.res
tests/plugins/Dash/cardcreator/7.res−9
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -139,13 +138,5 @@ CroppedImageMinimumSourceSize {
139138
140139 ]
141140 }
142−UbuntuShape {
143− id: touchdown;
144− objectName: "touchdown";
145− anchors { fill: backgroundLoader }
146− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
147− radius: "medium";
148− borderSource: "radius_pressed.sci"
149−}
150141implicitHeight: row.y + row.height + units.gu(1);
151142}
tests/plugins/Dash/cardcreator/7.res.cardcreator−9
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -137,13 +136,5 @@ CroppedImageMinimumSourceSize {
137136
138137 ]
139138 }
140−UbuntuShape {
141− id: touchdown;
142− objectName: "touchdown";
143− anchors { fill: backgroundLoader }
144− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
145− radius: "medium";
146− borderSource: "radius_pressed.sci"
147−}
148139implicitHeight: row.y + row.height + units.gu(1);
149140}
tests/plugins/Dash/cardcreator/7.tst+1
@@ -1,3 +1,4 @@
11template: {"card-background":{"elements":["#E9E9E9","#E9AAE9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{"field":"attributes","max-count":2}}
3+artShapeStyle: icon
34result: 7.res
tests/plugins/Dash/cardcreator/8.res+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -101,7 +100,7 @@ UbuntuShape {
101100 id: touchdown;
102101 objectName: "touchdown";
103102 anchors { fill: backgroundLoader }
104− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
103+ visible: root.pressed;
105104 radius: "medium";
106105 borderSource: "radius_pressed.sci"
107106}
tests/plugins/Dash/cardcreator/8.res.cardcreator+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -99,7 +98,7 @@ UbuntuShape {
9998 id: touchdown;
10099 objectName: "touchdown";
101100 anchors { fill: backgroundLoader }
102− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
101+ visible: root.pressed;
103102 radius: "medium";
104103 borderSource: "radius_pressed.sci"
105104}
tests/plugins/Dash/cardcreator/8.tst+1
@@ -1,3 +1,4 @@
11template: {"card-background":{"elements":["#E9E9E9","#E9AAE9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
22components: {"background":{"field":"background"},"mascot":{"field":"icon"},"title":{"field":"title"},"attributes":{}}
3+artShapeStyle: inset
34result: 8.res
tests/plugins/Dash/cardcreator/9.res+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -111,7 +110,7 @@ CardAudioProgress {
111110 id: touchdown;
112111 objectName: "touchdown";
113112 anchors { fill: root }
114− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
113+ visible: root.pressed;
115114 radius: "medium";
116115 borderSource: "radius_pressed.sci"
117116 }
tests/plugins/Dash/cardcreator/9.res.cardcreator+1−2
@@ -1,7 +1,6 @@
11AbstractButton {
22 id: root;
33 property var cardData;
4− property string artShapeStyle: "inset";
54 property string backgroundShapeStyle: "inset";
65 property real fontScale: 1.0;
76 property var scopeStyle: null;
@@ -110,7 +109,7 @@ CardAudioProgress {
110109 id: touchdown;
111110 objectName: "touchdown";
112111 anchors { fill: root }
113− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
112+ visible: root.pressed;
114113 radius: "medium";
115114 borderSource: "radius_pressed.sci"
116115 }
tests/plugins/Dash/cardcreator/9.tst+1
@@ -1,3 +1,4 @@
11template: {"card-layout":"horizontal","card-size":"medium","category-layout":"grid","collapsed-rows":2,"quick-preview-type": "audio"}
22components: {"art":{"aspect-ratio":1},"subtitle":{"field":"author"},"title":{"field":"title"}, "quickPreviewData": "quickPreviewData"}
3+artShapeStyle: inset
34result: 9.res
tests/plugins/Dash/cardcreatortest.cpp+9−6
@@ -73,6 +73,7 @@ private Q_SLOTS:
7373 {
7474 const QString templateString("template: ");
7575 const QString componentsString("components: ");
76+ const QString artShapeStyleString("artShapeStyle: ");
7677 const QString resultString("result: ");
7778
7879 const QString testDirPath = DASHVIEWSTEST_FOLDER "/cardcreator/";
@@ -87,24 +88,26 @@ private Q_SLOTS:
8788
8889 QVERIFY(lines[0].startsWith(templateString));
8990 QVERIFY(lines[1].startsWith(componentsString));
90− QVERIFY(lines[2].startsWith(resultString));
91+ QVERIFY(lines[2].startsWith(artShapeStyleString));
92+ QVERIFY(lines[3].startsWith(resultString));
9193
9294 const QString templateJSON = lines[0].mid(templateString.length());
9395 const QString componentsJSON = lines[1].mid(componentsString.length());
94− const QString resultFileName = lines[2].mid(resultString.length());
96+ const QString artShapeStyle = lines[2].mid(artShapeStyleString.length());
97+ const QString resultFileName = lines[3].mid(resultString.length());
9598 QVariant cardStringResult;
9699 QVariant createCardComponentResult;
97100
98− QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, false));
101+ QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, false), Q_ARG(QVariant, artShapeStyle));
99102 compareFileContents(testDirPath + resultFileName, cardStringResult.toString());
100103
101− QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, true));
104+ QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, true), Q_ARG(QVariant, artShapeStyle));
102105 compareFileContents(testDirPath + resultFileName + ".cardcreator", cardStringResult.toString());
103106
104− QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, false));
107+ QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, false), Q_ARG(QVariant, artShapeStyle));
105108 QVERIFY(createCardComponentResult.toBool());
106109
107− QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, true));
110+ QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, true), Q_ARG(QVariant, artShapeStyle));
108111 QVERIFY(createCardComponentResult.toBool());
109112 }
110113 }
tests/plugins/Dash/cardcreatortest.qml+4−4
@@ -19,11 +19,11 @@ import "../../../plugins/Dash/CardCreator.js" as CardCreator
1919
2020Item {
2121 id: root
22− function cardString(template, components, isCardCreator) {
23− return CardCreator.cardString(JSON.parse(template), JSON.parse(components), isCardCreator);
22+ function cardString(template, components, isCardCreator, artShapeStyle) {
23+ return CardCreator.cardString(JSON.parse(template), JSON.parse(components), isCardCreator, artShapeStyle);
2424 }
2525
26− function createCardComponent(template, components, isCardCreator) {
27− return CardCreator.createCardComponent(root, JSON.parse(template), JSON.parse(components), isCardCreator) !== null;
26+ function createCardComponent(template, components, isCardCreator, artShapeStyle) {
27+ return CardCreator.createCardComponent(root, JSON.parse(template), JSON.parse(components), isCardCreator, artShapeStyle) !== null;
2828 }
2929}