@@ -59,14 +59,34 @@ var kBackgroundLoaderCode = 'Loader {\n\
62+// %1 is the visible code
63+// %2 is the aspect of the UbuntuShape
64+var kArtUbuntuShapeCode = 'UbuntuShape { \n\
65+ anchors.fill: parent; \n\
67+ source: artImage; \n\
68+ sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
69+ radius: "medium"; \n\
73+// %1 is the visible code
74+var kArtProportionalShapeCode = 'ProportionalShape { \n\
75+ anchors.fill: parent; \n\
77+ source: artImage; \n\
78+ aspect: UbuntuShape.DropShadow; \n\
62// %1 is used as anchors of artShapeHolder
81// %1 is used as anchors of artShapeHolder
63// %2 is used as image width
82// %2 is used as image width
64// %3 is used as image height
83// %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
66// %5 is used as aspect ratio fallback
85// %5 is used as aspect ratio fallback
67// %6 is whether the loader should be asynchronous or not
86// %6 is whether the loader should be asynchronous or not
87+// %7 is the shape code we want to use
68−// %7 is injected as code to artImage
88+// %8 is injected as code to artImage
69−// %8 is used as image fallback
89+// %9 is used as image fallback
70var kArtShapeHolderCode = 'Item { \n\
90var kArtShapeHolderCode = 'Item { \n\
71 id: artShapeHolder; \n\
91 id: artShapeHolder; \n\
72 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
92 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
@@ -75,7 +95,7 @@ var kArtShapeHolderCode = 'Item { \n\
75 Loader { \n\
95 Loader { \n\
76 id: artShapeLoader; \n\
96 id: artShapeLoader; \n\
77 objectName: "artShapeLoader"; \n\
97 objectName: "artShapeLoader"; \n\
78− readonly property string cardArt: cardData && cardData["art"] || %8; \n\
98+ readonly property string cardArt: cardData && cardData["art"] || %9; \n\
79 active: cardArt != ""; \n\
99 active: cardArt != ""; \n\
80 asynchronous: %6; \n\
100 asynchronous: %6; \n\
81 visible: status == Loader.Ready; \n\
101 visible: status == Loader.Ready; \n\
@@ -84,31 +104,7 @@ var kArtShapeHolderCode = 'Item { \n\
84 objectName: "artShape"; \n\
104 objectName: "artShape"; \n\
85 visible: image.status == Image.Ready; \n\
105 visible: image.status == Image.Ready; \n\
86 readonly property alias image: artImage; \n\
106 readonly property alias image: artImage; \n\
88− anchors.fill: parent; \n\
90− sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; \n\
92− id: artShapeShapeComponent; \n\
94− source: artImage; \n\
95− sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
96− radius: "medium"; \n\
98− switch (root.artShapeStyle) { \n\
99− case "inset": return UbuntuShape.Inset; \n\
100− case "shadow": return UbuntuShape.DropShadow; \n\
102− case "flat": return UbuntuShape.Flat; \n\
108− id: artShapeIconComponent; \n\
109− ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; } \n\
112 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
108 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
113 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : %5; \n\
109 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : %5; \n\
114 Component.onCompleted: { updateWidthHeightBindings(); } \n\
110 Component.onCompleted: { updateWidthHeightBindings(); } \n\
@@ -127,10 +123,10 @@ var kArtShapeHolderCode = 'Item { \n\
127 objectName: "artImage"; \n\
123 objectName: "artImage"; \n\
128 source: artShapeLoader.cardArt; \n\
124 source: artShapeLoader.cardArt; \n\
129 asynchronous: %6; \n\
125 asynchronous: %6; \n\
130− visible: !%4; \n\
126+ visible: %4; \n\
131 width: %2; \n\
127 width: %2; \n\
132 height: %3; \n\
128 height: %3; \n\
@@ -316,7 +312,7 @@ var kTouchdownCode = 'UbuntuShape { \n\
316 id: touchdown; \n\
312 id: touchdown; \n\
317 objectName: "touchdown"; \n\
313 objectName: "touchdown"; \n\
318 anchors { %1 } \n\
314 anchors { %1 } \n\
319− visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; \n\
315+ visible: root.pressed; \n\
320 radius: "medium"; \n\
316 radius: "medium"; \n\
321 borderSource: "radius_pressed.sci" \n\
317 borderSource: "radius_pressed.sci" \n\
@@ -399,7 +395,7 @@ function sanitizeColor(colorString) {
399 return colorString;
395 return colorString;
402−function cardString(template, components, isCardTool) {
398+function cardString(template, components, isCardTool, artShapeStyle) {
403 var code;
399 var code;
405 var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
401 var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
@@ -407,7 +403,6 @@ function cardString(template, components, isCardTool) {
407 code = 'AbstractButton { \n\
403 code = 'AbstractButton { \n\
408 id: root; \n\
404 id: root; \n\
409 property var cardData; \n\
405 property var cardData; \n\
410− property string artShapeStyle: "inset"; \n\
411 property string backgroundShapeStyle: "inset"; \n\
406 property string backgroundShapeStyle: "inset"; \n\
412 property real fontScale: 1.0; \n\
407 property real fontScale: 1.0; \n\
413 property var scopeStyle: null; \n\
408 property var scopeStyle: null; \n\
@@ -504,17 +499,32 @@ function cardString(template, components, isCardTool) {
504 var fallbackStatusCode = "";
499 var fallbackStatusCode = "";
505 var fallbackURICode = '""';
500 var fallbackURICode = '""';
506 if (fallback !== "") {
501 if (fallback !== "") {
507− // fallbackStatusCode has %6 in it because we want to substitute it for fallbackURICode
502+ // fallbackStatusCode has %9 in it because we want to substitute it for fallbackURICode
508− // which in kArtShapeHolderCode is %8
503+ // which in kArtShapeHolderCode is %9
509− fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %8;';
504+ fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %9;';
510 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
505 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
507+ var artShapeHolderShapeCode;
508+ if (artShapeStyle === "icon") {
509+ artShapeHolderShapeCode = kArtProportionalShapeCode.arg(isConciergeMode ? "false" : "true");
511+ var artShapeHolderShapeAspect;
512+ switch (artShapeStyle) {
513+ case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
514+ case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
516+ case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
518+ artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(isConciergeMode ? "false" : "true")
519+ .arg(artShapeHolderShapeAspect);
512 code += kArtShapeHolderCode.arg(artAnchors)
521 code += kArtShapeHolderCode.arg(artAnchors)
513 .arg(widthCode)
522 .arg(widthCode)
514 .arg(heightCode)
523 .arg(heightCode)
515− .arg(isConciergeMode ? "false" : "true")
524+ .arg(isConciergeMode ? "true" : "false")
516 .arg(aspectRatio)
525 .arg(aspectRatio)
517 .arg(asynchronous)
526 .arg(asynchronous)
527+ .arg(artShapeHolderShapeCode)
518 .arg(fallbackStatusCode)
528 .arg(fallbackStatusCode)
519 .arg(fallbackURICode);
529 .arg(fallbackURICode);
@@ -839,15 +849,17 @@ function cardString(template, components, isCardTool) {
839 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
849 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
852+ if (artShapeStyle != "shadow" && artShapeStyle != "icon") {
842− var touchdownAnchors;
853+ var touchdownAnchors;
843− if (hasBackground) {
854+ if (hasBackground) {
844− touchdownAnchors = 'fill: backgroundLoader';
855+ touchdownAnchors = 'fill: backgroundLoader';
845− } else if (touchdownOnArtShape) {
856+ } else if (touchdownOnArtShape) {
846− touchdownAnchors = 'fill: artShapeHolder';
857+ touchdownAnchors = 'fill: artShapeHolder';
847− } else {
858+ } else {
848− touchdownAnchors = 'fill: root'
859+ touchdownAnchors = 'fill: root'
861+ code += kTouchdownCode.arg(touchdownAnchors);
850− code += kTouchdownCode.arg(touchdownAnchors);
852 var implicitHeight = 'implicitHeight: ';
864 var implicitHeight = 'implicitHeight: ';
853 if (hasSummary) {
865 if (hasSummary) {
@@ -880,13 +892,13 @@ function cardString(template, components, isCardTool) {
880 return code;
892 return code;
883−function createCardComponent(parent, template, components, isCardTool, identifier) {
895+function createCardComponent(parent, template, components, isCardTool, artShapeStyle, identifier) {
884 var imports = 'import QtQuick 2.4; \n\
896 var imports = 'import QtQuick 2.4; \n\
885 import Ubuntu.Components 1.3; \n\
897 import Ubuntu.Components 1.3; \n\
886 import Ubuntu.Settings.Components 0.1; \n\
898 import Ubuntu.Settings.Components 0.1; \n\
887 import Dash 0.1;\n\
899 import Dash 0.1;\n\
888 import Utils 0.1;\n';
900 import Utils 0.1;\n';
889− var card = cardString(template, components, isCardTool);
901+ var card = cardString(template, components, isCardTool, artShapeStyle);
890 var code = imports + 'Component {\n' + card + '}\n';
902 var code = imports + 'Component {\n' + card + '}\n';