on xenial help sign in
Do not use template in generated card creator code
3af8283Albert Astals Cid
plugins/Dash/CardCreator.js+22−10
@@ -16,6 +16,9 @@
16
16
17.pragma library
17.pragma library
18
18
19+// %1 is the template["card-background"] string
20+// %2 is the template["card-background"]["elements"][0]
21+// %3 is the template["card-background"]["elements"][1]
19var kBackgroundLoaderCode = 'Loader {\n\
22var kBackgroundLoaderCode = 'Loader {\n\
20 id: backgroundLoader; \n\
23 id: backgroundLoader; \n\
21 objectName: "backgroundLoader"; \n\
24 objectName: "backgroundLoader"; \n\
@@ -34,18 +37,14 @@ var kBackgroundLoaderCode = 'Loader {\n\
34 objectName: "backgroundImage"; \n\
37 objectName: "backgroundImage"; \n\
35 source: { \n\
38 source: { \n\
36 if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\
39 if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\
37− else if (template && typeof template["card-background"] === "string") return template["card-background"]; \n\
40+ else return "%1"; \n\
38− else return ""; \n\
39 } \n\
41 } \n\
40 } \n\
42 } \n\
41 function getColor(index) { \n\
43 function getColor(index) { \n\
42 if (cardData && typeof cardData["background"] === "object" \n\
44 if (cardData && typeof cardData["background"] === "object" \n\
43 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\
45 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\
44 return cardData["background"]["elements"][index]; \n\
46 return cardData["background"]["elements"][index]; \n\
45− } else if (template && typeof template["card-background"] === "object" \n\
47+ } else return index === 0 ? %2 : %3; \n\
46− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) { \n\
47− return template["card-background"]["elements"][index]; \n\
48− } else return undefined; \n\
49 } \n\
48 } \n\
50 } \n\
49 } \n\
51 }\n';
50 }\n';
@@ -315,9 +314,11 @@ var kSummaryLabelCode = 'Label { \n\
315
314
316function cardString(template, components) {
315function cardString(template, components) {
317 var code;
316 var code;
317+
318+ var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
319+
318 code = 'AbstractButton { \n\
320 code = 'AbstractButton { \n\
319 id: root; \n\
321 id: root; \n\
320− property var template; \n\
321 property var components; \n\
322 property var components; \n\
322 property var cardData; \n\
323 property var cardData; \n\
323 property var artShapeBorderSource: undefined; \n\
324 property var artShapeBorderSource: undefined; \n\
@@ -330,8 +331,8 @@ function cardString(template, components) {
330 property bool asynchronous: true; \n\
331 property bool asynchronous: true; \n\
331 property bool showHeader: true; \n\
332 property bool showHeader: true; \n\
332 implicitWidth: childrenRect.width; \n\
333 implicitWidth: childrenRect.width; \n\
333− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true); \n\
334+ enabled: %1; \n\
334− \n';
335+ \n'.arg(templateInteractive);
335
336
336 var hasArt = components["art"] && components["art"]["field"] || false;
337 var hasArt = components["art"] && components["art"]["field"] || false;
337 var hasSummary = components["summary"] || false;
338 var hasSummary = components["summary"] || false;
@@ -348,7 +349,18 @@ function cardString(template, components) {
348 var hasAttributes = hasTitle && components["attributes"]["field"] || false;
349 var hasAttributes = hasTitle && components["attributes"]["field"] || false;
349
350
350 if (hasBackground) {
351 if (hasBackground) {
352+ var templateCardBackground = (template && typeof template["card-background"] === "string") ? template["card-background"] : "";
353+ var backgroundElements0;
354+ var backgroundElements1;
355+ if (template && typeof template["card-background"] === "object" && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
356+ if (template["card-background"]["elements"][0] !== undefined) {
357+ backgroundElements0 = '"%1"'.arg(template["card-background"]["elements"][0]);
358+ }
359+ if (template["card-background"]["elements"][1] !== undefined) {
360+ backgroundElements1 = '"%1"'.arg(template["card-background"]["elements"][1]);
361+ }
362+ }
351− code += kBackgroundLoaderCode;
363+ code += kBackgroundLoaderCode.arg(templateCardBackground).arg(backgroundElements0).arg(backgroundElements1);
352 }
364 }
353
365
354 if (hasArt) {
366 if (hasArt) {
qml/Dash/CardCarousel.qml−1
@@ -61,7 +61,6 @@ DashRenderer {
61 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
61 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
62 item.height = Qt.binding(function() { return cardTool.cardHeight; });
62 item.height = Qt.binding(function() { return cardTool.cardHeight; });
63 item.cardData = Qt.binding(function() { return model; });
63 item.cardData = Qt.binding(function() { return model; });
64− item.template = Qt.binding(function() { return cardTool.template; });
65 item.components = Qt.binding(function() { return cardTool.components; });
64 item.components = Qt.binding(function() { return cardTool.components; });
66 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
65 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
67 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
66 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
qml/Dash/CardGrid.qml−1
@@ -66,7 +66,6 @@ DashRenderer {
66 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
66 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
67 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
67 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
68 item.cardData = Qt.binding(function() { return model; });
68 item.cardData = Qt.binding(function() { return model; });
69− item.template = Qt.binding(function() { return cardTool.template; });
70 item.components = Qt.binding(function() { return cardTool.components; });
69 item.components = Qt.binding(function() { return cardTool.components; });
71 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
70 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
72 item.scopeStyle = root.scopeStyle;
71 item.scopeStyle = root.scopeStyle;
qml/Dash/CardHorizontalList.qml−1
@@ -53,7 +53,6 @@ DashRenderer {
53 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
53 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
54 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
54 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
55 item.cardData = Qt.binding(function() { return model; });
55 item.cardData = Qt.binding(function() { return model; });
56− item.template = Qt.binding(function() { return cardTool.template; });
57 item.components = Qt.binding(function() { return cardTool.components; });
56 item.components = Qt.binding(function() { return cardTool.components; });
58 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
57 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
59 item.scopeStyle = root.scopeStyle;
58 item.scopeStyle = root.scopeStyle;
qml/Dash/CardTool.qml+16−15
@@ -198,8 +198,8 @@ Item {
198
198
199 Loader {
199 Loader {
200 id: cardLoader
200 id: cardLoader
201− property var fields: ["art", "mascot", "title", "subtitle", "summary", "attributes"]
201+ readonly property var fields: ["art", "mascot", "title", "subtitle", "summary", "attributes"]
202− property var maxData: {
202+ readonly property var maxData: {
203 "art": Qt.resolvedUrl("graphics/pixel.png"),
203 "art": Qt.resolvedUrl("graphics/pixel.png"),
204 "mascot": Qt.resolvedUrl("graphics/pixel.png"),
204 "mascot": Qt.resolvedUrl("graphics/pixel.png"),
205 "title": "—\n—",
205 "title": "—\n—",
@@ -211,26 +211,27 @@ Item {
211 onLoaded: {
211 onLoaded: {
212 item.objectName = "cardToolCard";
212 item.objectName = "cardToolCard";
213 item.asynchronous = false;
213 item.asynchronous = false;
214− item.template = Qt.binding(function() { return cardTool.template; });
215 item.components = Qt.binding(function() { return cardTool.components; });
214 item.components = Qt.binding(function() { return cardTool.components; });
216 item.width = Qt.binding(function() { return cardTool.cardWidth || item.implicitWidth; });
215 item.width = Qt.binding(function() { return cardTool.cardWidth || item.implicitWidth; });
217 item.height = Qt.binding(function() { return cardTool.cardHeight || item.implicitHeight; });
216 item.height = Qt.binding(function() { return cardTool.cardHeight || item.implicitHeight; });
218 }
217 }
219 Connections {
218 Connections {
220− target: cardLoader.item
219+ target: cardTool
220+ onTemplateChanged: cardLoader.updateCardData();
221− onComponentsChanged: {
221+ onComponentsChanged: cardLoader.updateCardData();
222+ }
223+ function updateCardData() {
222− var data = {};
224+ var data = {};
223− for (var k in cardLoader.fields) {
225+ for (var k in fields) {
224− var component = cardLoader.item.components[cardLoader.fields[k]];
226+ var component = cardTool.components[fields[k]];
225− var key = cardLoader.fields[k];
227+ var key = fields[k];
226− if ((typeof component === "string" && component.length > 0) ||
228+ if ((typeof component === "string" && component.length > 0) ||
227− (typeof component === "object" && component !== null
229+ (typeof component === "object" && component !== null
228− && typeof component["field"] === "string" && component["field"].length > 0)) {
230+ && typeof component["field"] === "string" && component["field"].length > 0)) {
229− data[key] = cardLoader.maxData[key];
231+ data[key] = maxData[key];
230− }
231 }
232 }
232− cardLoader.item.cardData = data;
233 }
233 }
234+ item.cardData = data;
234 }
235 }
235 }
236 }
236}
237}
qml/Dash/CardVerticalJournal.qml−1
@@ -72,7 +72,6 @@ DashRenderer {
72 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
72 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
73 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
73 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
74 item.cardData = Qt.binding(function() { return model; });
74 item.cardData = Qt.binding(function() { return model; });
75− item.template = Qt.binding(function() { return cardTool.template; });
76 item.components = Qt.binding(function() { return cardTool.components; });
75 item.components = Qt.binding(function() { return cardTool.components; });
77 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
76 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
78 item.scopeStyle = root.scopeStyle;
77 item.scopeStyle = root.scopeStyle;
tests/plugins/Dash/cardcreator/1.res+1−2
@@ -1,6 +1,5 @@
1AbstractButton {
1AbstractButton {
2 id: root;
2 id: root;
3− property var template;
4 property var components;
3 property var components;
5 property var cardData;
4 property var cardData;
6 property var artShapeBorderSource: undefined;
5 property var artShapeBorderSource: undefined;
@@ -13,7 +12,7 @@ AbstractButton {
13 property bool asynchronous: true;
12 property bool asynchronous: true;
14 property bool showHeader: true;
13 property bool showHeader: true;
15 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
16− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true);
15+ enabled: true;
17
16
18onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
17onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
19readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
18readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
tests/plugins/Dash/cardcreator/2.res+3−8
@@ -1,6 +1,5 @@
1AbstractButton {
1AbstractButton {
2 id: root;
2 id: root;
3− property var template;
4 property var components;
3 property var components;
5 property var cardData;
4 property var cardData;
6 property var artShapeBorderSource: undefined;
5 property var artShapeBorderSource: undefined;
@@ -13,7 +12,7 @@ AbstractButton {
13 property bool asynchronous: true;
12 property bool asynchronous: true;
14 property bool showHeader: true;
13 property bool showHeader: true;
15 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
16− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true);
15+ enabled: true;
17
16
18Loader {
17Loader {
19 id: backgroundLoader;
18 id: backgroundLoader;
@@ -33,18 +32,14 @@ Loader {
33 objectName: "backgroundImage";
32 objectName: "backgroundImage";
34 source: {
33 source: {
35 if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34 if (cardData && typeof cardData["background"] === "string") return cardData["background"];
36− else if (template && typeof template["card-background"] === "string") return template["card-background"];
35+ else return "";
37− else return "";
38 }
36 }
39 }
37 }
40 function getColor(index) {
38 function getColor(index) {
41 if (cardData && typeof cardData["background"] === "object"
39 if (cardData && typeof cardData["background"] === "object"
42 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
40 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
43 return cardData["background"]["elements"][index];
41 return cardData["background"]["elements"][index];
44− } else if (template && typeof template["card-background"] === "object"
42+ } else return index === 0 ? "#E9E9E9" : undefined;
45− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
46− return template["card-background"]["elements"][index];
47− } else return undefined;
48 }
43 }
49 }
44 }
50 }
45 }
tests/plugins/Dash/cardcreator/3.res+1−2
@@ -1,6 +1,5 @@
1AbstractButton {
1AbstractButton {
2 id: root;
2 id: root;
3− property var template;
4 property var components;
3 property var components;
5 property var cardData;
4 property var cardData;
6 property var artShapeBorderSource: undefined;
5 property var artShapeBorderSource: undefined;
@@ -13,7 +12,7 @@ AbstractButton {
13 property bool asynchronous: true;
12 property bool asynchronous: true;
14 property bool showHeader: true;
13 property bool showHeader: true;
15 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
16− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true);
15+ enabled: true;
17
16
18onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
17onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
19readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
18readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
tests/plugins/Dash/cardcreator/4.res+1−2
@@ -1,6 +1,5 @@
1AbstractButton {
1AbstractButton {
2 id: root;
2 id: root;
3− property var template;
4 property var components;
3 property var components;
5 property var cardData;
4 property var cardData;
6 property var artShapeBorderSource: undefined;
5 property var artShapeBorderSource: undefined;
@@ -13,7 +12,7 @@ AbstractButton {
13 property bool asynchronous: true;
12 property bool asynchronous: true;
14 property bool showHeader: true;
13 property bool showHeader: true;
15 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
16− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true);
15+ enabled: true;
17
16
18readonly property size artShapeSize: Qt.size(-1, -1);
17readonly property size artShapeSize: Qt.size(-1, -1);
19readonly property int headerHeight: row.height;
18readonly property int headerHeight: row.height;
tests/plugins/Dash/cardcreator/5.res+1−2
@@ -1,6 +1,5 @@
1AbstractButton {
1AbstractButton {
2 id: root;
2 id: root;
3− property var template;
4 property var components;
3 property var components;
5 property var cardData;
4 property var cardData;
6 property var artShapeBorderSource: undefined;
5 property var artShapeBorderSource: undefined;
@@ -13,7 +12,7 @@ AbstractButton {
13 property bool asynchronous: true;
12 property bool asynchronous: true;
14 property bool showHeader: true;
13 property bool showHeader: true;
15 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
16− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true);
15+ enabled: false;
17
16
18onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
17onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
19readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
18readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
tests/plugins/Dash/cardcreator/5.tst+1−1
@@ -1,3 +1,3 @@
1−template: {"card-layout":"vertical","card-size":"medium","category-layout":"carousel","collapsed-rows":2,"overlay":true}
1+template: {"non-interactive":true,"card-layout":"vertical","card-size":"medium","category-layout":"carousel","collapsed-rows":2,"overlay":true}
2components: {"art":{"aspect-ratio":1,"field":"art"},"subtitle":{"field":"artist"},"title":{"field":"title"},"attributes":{}}
2components: {"art":{"aspect-ratio":1,"field":"art"},"subtitle":{"field":"artist"},"title":{"field":"title"},"attributes":{}}
3result: 5.res
3result: 5.res
tests/plugins/Dash/cardcreator/6.res+3−8
@@ -1,6 +1,5 @@
1AbstractButton {
1AbstractButton {
2 id: root;
2 id: root;
3− property var template;
4 property var components;
3 property var components;
5 property var cardData;
4 property var cardData;
6 property var artShapeBorderSource: undefined;
5 property var artShapeBorderSource: undefined;
@@ -13,7 +12,7 @@ AbstractButton {
13 property bool asynchronous: true;
12 property bool asynchronous: true;
14 property bool showHeader: true;
13 property bool showHeader: true;
15 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
16− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true);
15+ enabled: true;
17
16
18Loader {
17Loader {
19 id: backgroundLoader;
18 id: backgroundLoader;
@@ -33,18 +32,14 @@ Loader {
33 objectName: "backgroundImage";
32 objectName: "backgroundImage";
34 source: {
33 source: {
35 if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34 if (cardData && typeof cardData["background"] === "string") return cardData["background"];
36− else if (template && typeof template["card-background"] === "string") return template["card-background"];
35+ else return "http://assets.ubuntu.com/sites/ubuntu/latest/u/img/logos/logo-ubuntu-grey.png";
37− else return "";
38 }
36 }
39 }
37 }
40 function getColor(index) {
38 function getColor(index) {
41 if (cardData && typeof cardData["background"] === "object"
39 if (cardData && typeof cardData["background"] === "object"
42 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
40 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
43 return cardData["background"]["elements"][index];
41 return cardData["background"]["elements"][index];
44− } else if (template && typeof template["card-background"] === "object"
42+ } else return index === 0 ? undefined : undefined;
45− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
46− return template["card-background"]["elements"][index];
47− } else return undefined;
48 }
43 }
49 }
44 }
50 }
45 }
tests/plugins/Dash/cardcreator/6.tst+1−1
@@ -1,3 +1,3 @@
1−template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
1+template: {"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}
2components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"subtitle":{"field":"author"},"title":{"field":"title"},"emblem":{"field":"source"},"attributes":{}}
2components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"subtitle":{"field":"author"},"title":{"field":"title"},"emblem":{"field":"source"},"attributes":{}}
3result: 6.res
3result: 6.res
tests/plugins/Dash/cardcreator/7.res+3−8
@@ -1,6 +1,5 @@
1AbstractButton {
1AbstractButton {
2 id: root;
2 id: root;
3− property var template;
4 property var components;
3 property var components;
5 property var cardData;
4 property var cardData;
6 property var artShapeBorderSource: undefined;
5 property var artShapeBorderSource: undefined;
@@ -13,7 +12,7 @@ AbstractButton {
13 property bool asynchronous: true;
12 property bool asynchronous: true;
14 property bool showHeader: true;
13 property bool showHeader: true;
15 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
16− enabled: root.template == null ? true : (root.template["non-interactive"] !== undefined ? !root.template["non-interactive"] : true);
15+ enabled: true;
17
16
18Loader {
17Loader {
19 id: backgroundLoader;
18 id: backgroundLoader;
@@ -33,18 +32,14 @@ Loader {
33 objectName: "backgroundImage";
32 objectName: "backgroundImage";
34 source: {
33 source: {
35 if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34 if (cardData && typeof cardData["background"] === "string") return cardData["background"];
36− else if (template && typeof template["card-background"] === "string") return template["card-background"];
35+ else return "";
37− else return "";
38 }
36 }
39 }
37 }
40 function getColor(index) {
38 function getColor(index) {
41 if (cardData && typeof cardData["background"] === "object"
39 if (cardData && typeof cardData["background"] === "object"
42 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
40 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
43 return cardData["background"]["elements"][index];
41 return cardData["background"]["elements"][index];
44− } else if (template && typeof template["card-background"] === "object"
42+ } else return index === 0 ? "#E9E9E9" : "#E9AAE9";
45− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
46− return template["card-background"]["elements"][index];
47− } else return undefined;
48 }
43 }
49 }
44 }
50 }
45 }
tests/plugins/Dash/cardcreator/7.tst+1−1
@@ -1,3 +1,3 @@
1−template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
1+template: {"card-background":{"elements":["#E9E9E9","#E9AAE9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
2components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{"field":"attributes","max-count":2}}
2components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{"field":"attributes","max-count":2}}
3result: 7.res
3result: 7.res
tests/qmltests/Dash/tst_Card.qml−1
@@ -124,7 +124,6 @@ Rectangle {
124 sourceComponent: cardTool.cardComponent
124 sourceComponent: cardTool.cardComponent
125 clip: true
125 clip: true
126 onLoaded: {
126 onLoaded: {
127− item.template = Qt.binding(function() { return cardTool.template; });
128 item.components = Qt.binding(function() { return cardTool.components; });
127 item.components = Qt.binding(function() { return cardTool.components; });
129 item.cardData = Qt.binding(function() { return Helpers.mapData(dataArea.text, cardTool.components, dataError); });
128 item.cardData = Qt.binding(function() { return Helpers.mapData(dataArea.text, cardTool.components, dataError); });
130 item.width = Qt.binding(function() { return cardTool.cardWidth || item.implicitWidth; });
129 item.width = Qt.binding(function() { return cardTool.cardWidth || item.implicitWidth; });
tests/qmltests/Dash/tst_GenericScopeView.qml+21−7
@@ -302,6 +302,7 @@ Item {
302 }
302 }
303
303
304 function closePreview() {
304 function closePreview() {
305+ tryCompare(testCase.subPageLoader, "x", 0);
305 var closePreviewMouseArea = findChild(subPageLoader.item, "pageHeader");
306 var closePreviewMouseArea = findChild(subPageLoader.item, "pageHeader");
306 mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
307 mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
307
308
@@ -616,27 +617,40 @@ Item {
616 waitForRendering(category0);
617 waitForRendering(category0);
617
618
618 var cardTool = findChild(category0, "cardTool");
619 var cardTool = findChild(category0, "cardTool");
619− var cardGrid = category0.item;
620−
621 cardTool.template["non-interactive"] = true;
620 cardTool.template["non-interactive"] = true;
621+ cardTool.templateChanged();
622+
623+ var category0 = findChild(categoryListView, "dashCategory0");
624+ waitForRendering(category0);
625+
626+ var cardGrid = category0.item;
622 compare(cardGrid.cardTool.template["non-interactive"], true);
627 compare(cardGrid.cardTool.template["non-interactive"], true);
623
628
624 var item0 = findChild(cardGrid, "delegate0");
629 var item0 = findChild(cardGrid, "delegate0");
625 waitForRendering(item0);
630 waitForRendering(item0);
626− item0.template = cardTool.template;
627− compare(item0.template["non-interactive"], true);
628 compare(item0.enabled, false);
631 compare(item0.enabled, false);
629 var touchdown = findChild(item0, "touchdown");
632 var touchdown = findChild(item0, "touchdown");
630
633
631 compare(touchdown.visible, false);
634 compare(touchdown.visible, false);
632− mouseClick(item0);
635+ mousePress(item0);
633 compare(touchdown.visible, false);
636 compare(touchdown.visible, false);
637+ mouseRelease(item0);
634
638
635 cardTool.template["non-interactive"] = false;
639 cardTool.template["non-interactive"] = false;
640+ cardTool.templateChanged();
636 compare(cardGrid.cardTool.template["non-interactive"], false);
641 compare(cardGrid.cardTool.template["non-interactive"], false);
637− item0.template = cardTool.template;
642+
638− compare(item0.template["non-interactive"], false);
643+ waitForRendering(category0);
644+ item0 = findChild(cardGrid, "delegate0");
639 compare(item0.enabled, true);
645 compare(item0.enabled, true);
646+ var touchdown = findChild(item0, "touchdown");
647+
648+ compare(touchdown.visible, false);
649+ mousePress(item0);
650+ compare(touchdown.visible, true);
651+ mouseRelease(item0);
652+ compare(touchdown.visible, false);
653+ closePreview();
640 }
654 }
641 }
655 }
642 }
656 }