on xenial help sign in
Merge lp:~aacid/unity8/recoverArtIfChanges
commit43c9818f95ee54687a74c35dd856d48f1bed20e3 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 23 May 2016, 10:05 (10 years ago) parenta651c560f8dd90
45 files changed+188−436
plugins/Dash/CardCreator.js+64−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+8−26 tests/plugins/Dash/cardcreator/1.res.cardcreator+8−26 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+11−29 tests/plugins/Dash/cardcreator/11.res.cardcreator+10−28 tests/plugins/Dash/cardcreator/11.tst+1 tests/plugins/Dash/cardcreator/12.res+8−26 tests/plugins/Dash/cardcreator/12.res.cardcreator+10−28 tests/plugins/Dash/cardcreator/12.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+5−33 tests/plugins/Dash/cardcreator/3.res.cardcreator+5−33 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+2−35 tests/plugins/Dash/cardcreator/5.res.cardcreator+2−35 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 tests/qmltests/Dash/tst_Card.qml+12
plugins/Dash/CardCreator.js+64−48
@@ -59,14 +59,30 @@ var kBackgroundLoaderCode = 'Loader {\n\
5959 } \n\
6060 }\n';
6161
62+// %1 is the aspect of the UbuntuShape
63+var kArtUbuntuShapeCode = 'UbuntuShape { \n\
64+ anchors.fill: parent; \n\
65+ source: artImage; \n\
66+ sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
67+ radius: "medium"; \n\
68+ aspect: %1; \n\
69+ }';
70+
71+var kArtProportionalShapeCode = 'ProportionalShape { \n\
72+ anchors.fill: parent; \n\
73+ source: artImage; \n\
74+ aspect: UbuntuShape.DropShadow; \n\
75+ }';
76+
6277// %1 is used as anchors of artShapeHolder
6378// %2 is used as image width
6479// %3 is used as image height
65−// %4 is whether the image or the Loader with the UbuntuShape/ProportionalShape should be visible
80+// %4 is whether the image should be visible
6681// %5 is used as aspect ratio fallback
6782// %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
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
7086var kArtShapeHolderCode = 'Item { \n\
7187 id: artShapeHolder; \n\
7288 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
@@ -75,7 +91,8 @@ var kArtShapeHolderCode = 'Item { \n\
7591 Loader { \n\
7692 id: artShapeLoader; \n\
7793 objectName: "artShapeLoader"; \n\
78− readonly property string cardArt: cardData && cardData["art"] || %8; \n\
94+ readonly property string cardArt: cardData && cardData["art"] || %9; \n\
95+ onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
7996 active: cardArt != ""; \n\
8097 asynchronous: %6; \n\
8198 visible: status == Loader.Ready; \n\
@@ -84,31 +101,7 @@ var kArtShapeHolderCode = 'Item { \n\
84101 objectName: "artShape"; \n\
85102 visible: image.status == Image.Ready; \n\
86103 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\
104+ %7 \n\
112105 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
113106 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : %5; \n\
114107 Component.onCompleted: { updateWidthHeightBindings(); } \n\
@@ -127,10 +120,10 @@ var kArtShapeHolderCode = 'Item { \n\
127120 objectName: "artImage"; \n\
128121 source: artShapeLoader.cardArt; \n\
129122 asynchronous: %6; \n\
130− visible: !%4; \n\
123+ visible: %4; \n\
131124 width: %2; \n\
132125 height: %3; \n\
133− %7 \n\
126+ %8 \n\
134127 } \n\
135128 } \n\
136129 } \n\
@@ -318,7 +311,7 @@ var kTouchdownCode = 'UbuntuShape { \n\
318311 id: touchdown; \n\
319312 objectName: "touchdown"; \n\
320313 anchors { %1 } \n\
321− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; \n\
314+ visible: root.pressed; \n\
322315 radius: "medium"; \n\
323316 borderSource: "radius_pressed.sci" \n\
324317 }\n';
@@ -412,7 +405,7 @@ function sanitizeColor(colorString) {
412405 return colorString;
413406}
414407
415−function cardString(template, components, isCardTool) {
408+function cardString(template, components, isCardTool, artShapeStyle) {
416409 var code;
417410
418411 var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
@@ -420,7 +413,6 @@ function cardString(template, components, isCardTool) {
420413 code = 'AbstractButton { \n\
421414 id: root; \n\
422415 property var cardData; \n\
423− property string artShapeStyle: "inset"; \n\
424416 property string backgroundShapeStyle: "inset"; \n\
425417 property real fontScale: 1.0; \n\
426418 property var scopeStyle: null; \n\
@@ -519,17 +511,35 @@ function cardString(template, components, isCardTool) {
519511 var fallbackStatusCode = "";
520512 var fallbackURICode = '""';
521513 if (fallback !== "") {
522− // fallbackStatusCode has %6 in it because we want to substitute it for fallbackURICode
523− // which in kArtShapeHolderCode is %8
524− fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %8;';
514+ // fallbackStatusCode has %9 in it because we want to substitute it for fallbackURICode
515+ // which in kArtShapeHolderCode is %9
516+ fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %9;';
525517 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
526518 }
519+ var artShapeHolderShapeCode;
520+ if (!isConciergeMode) {
521+ if (artShapeStyle === "icon") {
522+ artShapeHolderShapeCode = kArtProportionalShapeCode;
523+ } else {
524+ var artShapeHolderShapeAspect;
525+ switch (artShapeStyle) {
526+ case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
527+ case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
528+ default:
529+ case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
530+ }
531+ artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(artShapeHolderShapeAspect);
532+ }
533+ } else {
534+ artShapeHolderShapeCode = "";
535+ }
527536 code += kArtShapeHolderCode.arg(artAnchors)
528537 .arg(widthCode)
529538 .arg(heightCode)
530− .arg(isConciergeMode ? "false" : "true")
539+ .arg(isConciergeMode ? "true" : "false")
531540 .arg(aspectRatio)
532541 .arg(asynchronous)
542+ .arg(artShapeHolderShapeCode)
533543 .arg(fallbackStatusCode)
534544 .arg(fallbackURICode);
535545 } else {
@@ -854,6 +864,10 @@ function cardString(template, components, isCardTool) {
854864 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
855865 }
856866
867+// <<<<<<< TREE
868+// if (artShapeStyle != "shadow" && artShapeStyle != "icon") {
869+// var touchdownAnchors;
870+// =======
857871 if (hasSocialActions) {
858872 var socialAnchors;
859873 var socialTopAnchor;
@@ -882,15 +896,17 @@ function cardString(template, components, isCardTool) {
882896 code += kSocialActionsRowCode.arg(socialAnchors).arg(socialColor);
883897 }
884898
885− var touchdownAnchors;
886− if (hasBackground) {
887− touchdownAnchors = 'fill: backgroundLoader';
888− } else if (touchdownOnArtShape) {
889− touchdownAnchors = 'fill: artShapeHolder';
890− } else {
891− touchdownAnchors = 'fill: root'
899+ if (artShapeStyle != "shadow" && artShapeStyle != "icon") {
900+ var touchdownAnchors;
901+ if (hasBackground) {
902+ touchdownAnchors = 'fill: backgroundLoader';
903+ } else if (touchdownOnArtShape) {
904+ touchdownAnchors = 'fill: artShapeHolder';
905+ } else {
906+ touchdownAnchors = 'fill: root'
907+ }
908+ code += kTouchdownCode.arg(touchdownAnchors);
892909 }
893− code += kTouchdownCode.arg(touchdownAnchors);
894910
895911 var implicitHeight = 'implicitHeight: ';
896912 if (hasSocialActions) {
@@ -925,13 +941,13 @@ function cardString(template, components, isCardTool) {
925941 return code;
926942}
927943
928−function createCardComponent(parent, template, components, isCardTool, identifier) {
944+function createCardComponent(parent, template, components, isCardTool, artShapeStyle, identifier) {
929945 var imports = 'import QtQuick 2.4; \n\
930946 import Ubuntu.Components 1.3; \n\
931947 import Ubuntu.Settings.Components 0.1; \n\
932948 import Dash 0.1;\n\
933949 import Utils 0.1;\n';
934− var card = cardString(template, components, isCardTool);
950+ var card = cardString(template, components, isCardTool, artShapeStyle);
935951 var code = imports + 'Component {\n' + card + '}\n';
936952
937953 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.
@@ -208,7 +212,7 @@ Item {
208212 "attributes": attributesModel.model,
209213 "socialActions": socialActionsModel.model
210214 }
211− sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true);
215+ sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true, artShapeStyle);
212216 onLoaded: {
213217 item.objectName = "cardToolCard";
214218 item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });
qml/Dash/GenericScopeView.qml+2−2
@@ -345,10 +345,10 @@ FocusScope {
345345 if (scope && scope.id === "clickscope") {
346346 if (categoryId === "predefined" || categoryId === "local") {
347347 cardTool.artShapeSize = Qt.binding(function() { return Qt.size(units.gu(8), units.gu(7.5)) });
348− item.artShapeStyle = "icon";
348+ cardTool.artShapeStyle = "icon";
349349 } else {
350350 // Should be ubuntu store icon
351− item.artShapeStyle = "flat";
351+ cardTool.artShapeStyle = "flat";
352352 item.backgroundShapeStyle = "shadow";
353353 }
354354 }
tests/plugins/Dash/cardcreator/1.res+8−26
@@ -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;
@@ -22,6 +21,7 @@ Item {
2221 id: artShapeLoader;
2322 objectName: "artShapeLoader";
2423 readonly property string cardArt: cardData && cardData["art"] || "";
24+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2525 active: cardArt != "";
2626 asynchronous: true;
2727 visible: status == Loader.Ready;
@@ -30,30 +30,12 @@ Item {
3030 objectName: "artShape";
3131 visible: image.status == Image.Ready;
3232 readonly property alias image: artImage;
33− Loader {
33+ UbuntuShape {
3434 anchors.fill: parent;
35− 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+8−26
@@ -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;
@@ -21,6 +20,7 @@ Item {
2120 id: artShapeLoader;
2221 objectName: "artShapeLoader";
2322 readonly property string cardArt: cardData && cardData["art"] || "";
23+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2424 active: cardArt != "";
2525 asynchronous: false;
2626 visible: status == Loader.Ready;
@@ -29,30 +29,12 @@ Item {
2929 objectName: "artShape";
3030 visible: image.status == Image.Ready;
3131 readonly property alias image: artImage;
32− Loader {
32+ UbuntuShape {
3333 anchors.fill: parent;
34− 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+11−29
@@ -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;
@@ -60,6 +59,7 @@ Item {
6059 id: artShapeLoader;
6160 objectName: "artShapeLoader";
6261 readonly property string cardArt: cardData && cardData["art"] || decodeURI("%5C");
62+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
6363 active: cardArt != "";
6464 asynchronous: true;
6565 visible: status == Loader.Ready;
@@ -68,32 +68,14 @@ Item {
6868 objectName: "artShape";
6969 visible: image.status == Image.Ready;
7070 readonly property alias image: artImage;
71− Loader {
72− anchors.fill: parent;
73− 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;
71+ UbuntuShape {
72+ anchors.fill: parent;
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+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;
@@ -59,6 +58,7 @@ Item {
5958 id: artShapeLoader;
6059 objectName: "artShapeLoader";
6160 readonly property string cardArt: cardData && cardData["art"] || "";
61+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
6262 active: cardArt != "";
6363 asynchronous: false;
6464 visible: status == Loader.Ready;
@@ -67,31 +67,13 @@ Item {
6767 objectName: "artShape";
6868 visible: image.status == Image.Ready;
6969 readonly property alias image: artImage;
70− Loader {
71− anchors.fill: parent;
72− 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− }
70+ UbuntuShape {
71+ anchors.fill: parent;
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/12.res+8−26
@@ -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;
@@ -22,6 +21,7 @@ Item {
2221 id: artShapeLoader;
2322 objectName: "artShapeLoader";
2423 readonly property string cardArt: cardData && cardData["art"] || "";
24+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2525 active: cardArt != "";
2626 asynchronous: true;
2727 visible: status == Loader.Ready;
@@ -30,30 +30,12 @@ Item {
3030 objectName: "artShape";
3131 visible: image.status == Image.Ready;
3232 readonly property alias image: artImage;
33− Loader {
33+ UbuntuShape {
3434 anchors.fill: parent;
35− 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.Flat;
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 : 0.75;
@@ -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 }
@@ -131,7 +113,7 @@ UbuntuShape {
131113 id: touchdown;
132114 objectName: "touchdown";
133115 anchors { fill: artShapeHolder }
134− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
116+ visible: root.pressed;
135117 radius: "medium";
136118 borderSource: "radius_pressed.sci"
137119}
tests/plugins/Dash/cardcreator/12.res.cardcreator+10−28
@@ -1,7 +1,6 @@
1−AbstractButton {
1+AbstractButton {
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;
@@ -17,10 +16,11 @@ Item {
1716 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
1817 width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
1918 anchors { horizontalCenter: parent.horizontalCenter; }
20− Loader {
19+ Loader {
2120 id: artShapeLoader;
2221 objectName: "artShapeLoader";
2322 readonly property string cardArt: cardData && cardData["art"] || "";
23+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2424 active: cardArt != "";
2525 asynchronous: false;
2626 visible: status == Loader.Ready;
@@ -29,30 +29,12 @@ Item {
2929 objectName: "artShape";
3030 visible: image.status == Image.Ready;
3131 readonly property alias image: artImage;
32− Loader {
32+ UbuntuShape {
3333 anchors.fill: parent;
34− 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.Flat;
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 : 0.75;
@@ -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 }
@@ -130,7 +112,7 @@ UbuntuShape {
130112 id: touchdown;
131113 objectName: "touchdown";
132114 anchors { fill: artShapeHolder }
133− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
115+ visible: root.pressed;
134116 radius: "medium";
135117 borderSource: "radius_pressed.sci"
136118}
tests/plugins/Dash/cardcreator/12.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"},"subtitle":{"field":"price"},"title":{"field":"title"},"attributes":{},"social-actions":{}}
3+artShapeStyle: flat
34result: 12.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+5−33
@@ -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;
@@ -22,6 +21,7 @@ Item {
2221 id: artShapeLoader;
2322 objectName: "artShapeLoader";
2423 readonly property string cardArt: cardData && cardData["art"] || decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22");
24+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2525 active: cardArt != "";
2626 asynchronous: true;
2727 visible: status == Loader.Ready;
@@ -30,30 +30,10 @@ Item {
3030 objectName: "artShape";
3131 visible: image.status == Image.Ready;
3232 readonly property alias image: artImage;
33− Loader {
33+ ProportionalShape {
3434 anchors.fill: parent;
35− 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+5−33
@@ -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;
@@ -21,6 +20,7 @@ Item {
2120 id: artShapeLoader;
2221 objectName: "artShapeLoader";
2322 readonly property string cardArt: cardData && cardData["art"] || "";
23+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2424 active: cardArt != "";
2525 asynchronous: false;
2626 visible: status == Loader.Ready;
@@ -29,30 +29,10 @@ Item {
2929 objectName: "artShape";
3030 visible: image.status == Image.Ready;
3131 readonly property alias image: artImage;
32− Loader {
32+ ProportionalShape {
3333 anchors.fill: parent;
34− 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+2−35
@@ -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;
@@ -22,6 +21,7 @@ Item {
2221 id: artShapeLoader;
2322 objectName: "artShapeLoader";
2423 readonly property string cardArt: cardData && cardData["art"] || "";
24+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2525 active: cardArt != "";
2626 asynchronous: true;
2727 visible: status == Loader.Ready;
@@ -30,31 +30,6 @@ Item {
3030 objectName: "artShape";
3131 visible: image.status == Image.Ready;
3232 readonly property alias image: artImage;
33− Loader {
34− anchors.fill: parent;
35− 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− }
57− }
5833 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5934 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
6035 Component.onCompleted: { updateWidthHeightBindings(); }
@@ -73,7 +48,7 @@ Item {
7348 objectName: "artImage";
7449 source: artShapeLoader.cardArt;
7550 asynchronous: true;
76− visible: !false;
51+ visible: true;
7752 width: root.width;
7853 height: width / artShape.aspect;
7954 }
@@ -138,13 +113,5 @@ Label {
138113 text: cardData && cardData["subtitle"] || "";
139114 font.weight: Font.Light;
140115 }
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−}
149116implicitHeight: artShapeHolder.height;
150117}
tests/plugins/Dash/cardcreator/5.res.cardcreator+2−35
@@ -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;
@@ -21,6 +20,7 @@ Item {
2120 id: artShapeLoader;
2221 objectName: "artShapeLoader";
2322 readonly property string cardArt: cardData && cardData["art"] || "";
23+ onCardArtChanged: { if (item) { item.image.source = cardArt; } }
2424 active: cardArt != "";
2525 asynchronous: false;
2626 visible: status == Loader.Ready;
@@ -29,31 +29,6 @@ Item {
2929 objectName: "artShape";
3030 visible: image.status == Image.Ready;
3131 readonly property alias image: artImage;
32− Loader {
33− anchors.fill: parent;
34− 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− }
56− }
5732 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5833 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
5934 Component.onCompleted: { updateWidthHeightBindings(); }
@@ -72,7 +47,7 @@ Item {
7247 objectName: "artImage";
7348 source: artShapeLoader.cardArt;
7449 asynchronous: false;
75− visible: !false;
50+ visible: true;
7651 width: root.width;
7752 height: width / artShape.aspect;
7853 }
@@ -137,13 +112,5 @@ Label {
137112 text: cardData && cardData["subtitle"] || "";
138113 font.weight: Font.Light;
139114 }
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−}
148115implicitHeight: artShapeHolder.height;
149116}
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;
@@ -112,7 +111,7 @@ CardAudioProgress {
112111 id: touchdown;
113112 objectName: "touchdown";
114113 anchors { fill: root }
115− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
114+ visible: root.pressed;
116115 radius: "medium";
117116 borderSource: "radius_pressed.sci"
118117 }
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;
@@ -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.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}
tests/qmltests/Dash/tst_Card.qml+12
@@ -496,6 +496,18 @@ Rectangle {
496496 tryCompare(art, "visible", true);
497497 compare(artImage.source, Qt.resolvedUrl("artwork/checkers.png"));
498498
499+ card.cardData["art"] = "somethingbroken";
500+ card.cardDataChanged();
501+ waitForRendering(card);
502+ tryCompare(art, "visible", true);
503+ compare(artImage.source, Qt.resolvedUrl("artwork/checkers.png"));
504+
505+ card.cardData["art"] = Qt.resolvedUrl("artwork/music-player-design.png");
506+ card.cardDataChanged();
507+ waitForRendering(card);
508+ tryCompare(art, "visible", true);
509+ compare(artImage.source, Qt.resolvedUrl("artwork/music-player-design.png"));
510+
499511 card.cardData["mascot"] = "somethingbroken2";
500512 card.cardDataChanged();
501513 compare(mascotImage.status, Image.Error);