on xenial help sign in
Moar fixes
commit160c975c49359f5fc23926eb9b19d5413ef2859b authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 8 Aug 2014, 14:59 (12 years ago) parent980bb65
5 files changed+390−390
plugins/Dash/CardCreator.js+6−6 tests/plugins/Dash/cardcreator/2.res+105−105 tests/plugins/Dash/cardcreator/4.res+76−76 tests/plugins/Dash/cardcreator/6.res+84−84 tests/plugins/Dash/cardcreator/7.res+119−119
plugins/Dash/CardCreator.js+6−6
@@ -197,7 +197,7 @@ var kMascotImageCode = 'Image { \n\
197197 objectName: "mascotImage"; \n\
198198 anchors { %1 } \n\
199199 readonly property int maxSize: Math.max(width, height) * 4; \n\
200− source: cardData && cardData["mascot"]; \n\
200+ source: cardData && cardData["mascot"] || ""; \n\
201201 width: units.gu(6); \n\
202202 height: units.gu(5.625); \n\
203203 sourceSize { width: maxSize; height: maxSize } \n\
@@ -232,11 +232,11 @@ var kEmblemImageCode = 'Image { \n\
232232 anchors { \n\
233233 bottom: titleLabel.baseline; \n\
234234 right: parent.right; \n\
235− rightMargin: units.gu(1); \n\
235+ rightMargin: status === Image.Ready ? units.gu(1) : 0; \n\
236236 } \n\
237− source: cardData["emblem"]; \n\
237+ source: cardData && cardData["emblem"] || ""; \n\
238238 width: height; \n\
239− height: titleLabel.font.pixelSize; \n\
239+ height: status === Image.Ready ? titleLabel.font.pixelSize : 0; \n\
240240 fillMode: Image.PreserveAspectFit; \n\
241241 }\n';
242242
@@ -273,7 +273,7 @@ var kAttributesRowCode = 'CardAttributes { \n\
273273 objectName: "attributesRow"; \n\
274274 anchors { %1 } \n\
275275 color: %2; \n\
276− model: cardData["attributes"]; \n\
276+ model: cardData && cardData["attributes"]; \n\
277277 }\n';
278278
279279// %1 is used as top anchor of summary
@@ -470,7 +470,7 @@ function cardString(template, components) {
470470 }
471471 if (hasEmblem) {
472472 titleRightAnchor = 'right: emblemImage.left; \n\
473− rightMargin: units.gu(0.5); \n';
473+ rightMargin: emblemImage.width > 0 ? units.gu(0.5) : 0; \n';
474474 } else {
475475 titleRightAnchor = 'right: parent.right; \n\
476476 rightMargin: units.gu(1); \n';
tests/plugins/Dash/cardcreator/2.res+105−105
@@ -1,128 +1,128 @@
1−AbstractButton {
2− id: root;
3− property var template;
4− property var components;
5− property var cardData;
6− property var artShapeBorderSource: undefined;
7− property real fontScale: 1.0;
8− property var scopeStyle: null;
9− property int headerAlignment: Text.AlignLeft;
10− property int fixedHeaderHeight: -1;
11− property size fixedArtShapeSize: Qt.size(-1, -1);
12− readonly property string title: cardData && cardData["title"] || "";
13− property bool asynchronous: true;
14− property bool showHeader: true;
15− implicitWidth: childrenRect.width;
1+AbstractButton {
2+ id: root;
3+ property var template;
4+ property var components;
5+ property var cardData;
6+ property var artShapeBorderSource: undefined;
7+ property real fontScale: 1.0;
8+ property var scopeStyle: null;
9+ property int headerAlignment: Text.AlignLeft;
10+ property int fixedHeaderHeight: -1;
11+ property size fixedArtShapeSize: Qt.size(-1, -1);
12+ readonly property string title: cardData && cardData["title"] || "";
13+ property bool asynchronous: true;
14+ property bool showHeader: true;
15+ implicitWidth: childrenRect.width;
1616Loader {
17− id: backgroundLoader;
18− objectName: "backgroundLoader";
19− anchors.fill: parent;
20− asynchronous: root.asynchronous;
21− visible: status == Loader.Ready;
22− sourceComponent: UbuntuShape {
23− objectName: "background";
24− radius: "medium";
25− color: getColor(0) || "white";
26− gradientColor: getColor(1) || color;
27− anchors.fill: parent;
28− image: backgroundImage.source ? backgroundImage : null;
29− property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30− property Image backgroundImage: Image {
31− objectName: "backgroundImage";
32− source: {
33− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34− else if (template && typeof template["card-background"] === "string") return template["card-background"];
35− else return "";
36− }
37− }
38− function getColor(index) {
39− if (cardData && typeof cardData["background"] === "object"
40− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41− return cardData["background"]["elements"][index];
42− } else if (template && typeof template["card-background"] === "object"
43− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44− return template["card-background"]["elements"][index];
45− } else return undefined;
46− }
47− }
17+ id: backgroundLoader;
18+ objectName: "backgroundLoader";
19+ anchors.fill: parent;
20+ asynchronous: root.asynchronous;
21+ visible: status == Loader.Ready;
22+ sourceComponent: UbuntuShape {
23+ objectName: "background";
24+ radius: "medium";
25+ color: getColor(0) || "white";
26+ gradientColor: getColor(1) || color;
27+ anchors.fill: parent;
28+ image: backgroundImage.source ? backgroundImage : null;
29+ property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30+ property Image backgroundImage: Image {
31+ objectName: "backgroundImage";
32+ source: {
33+ if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34+ else if (template && typeof template["card-background"] === "string") return template["card-background"];
35+ else return "";
36+ }
37+ }
38+ function getColor(index) {
39+ if (cardData && typeof cardData["background"] === "object"
40+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41+ return cardData["background"]["elements"][index];
42+ } else if (template && typeof template["card-background"] === "object"
43+ && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44+ return template["card-background"]["elements"][index];
45+ } else return undefined;
46+ }
47+ }
4848 }
4949readonly property size artShapeSize: Qt.size(-1, -1);
5050readonly property int headerHeight: row.height;
51−Row {
52− id: row;
53− objectName: "outerRow";
54− property real margins: units.gu(1);
55− spacing: margins;
56− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
57− anchors { top: parent.top;
51+Row {
52+ id: row;
53+ objectName: "outerRow";
54+ property real margins: units.gu(1);
55+ spacing: margins;
56+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
57+ anchors { top: parent.top;
5858 topMargin: units.gu(1);
5959 left: parent.left;
60− }
61− anchors.right: parent.right;
60+ }
61+ anchors.right: parent.right;
6262 anchors.margins: margins;
6363 anchors.rightMargin: 0;
6464 data: [
65−Image {
66− id: mascotImage;
67− objectName: "mascotImage";
68− anchors { verticalCenter: parent.verticalCenter; }
69− readonly property int maxSize: Math.max(width, height) * 4;
70− source: cardData && cardData["mascot"];
71− width: units.gu(6);
72− height: units.gu(5.625);
73− sourceSize { width: maxSize; height: maxSize }
74− fillMode: Image.PreserveAspectCrop;
75− horizontalAlignment: Image.AlignHCenter;
76− verticalAlignment: Image.AlignVCenter;
77− visible: showHeader;
65+Image {
66+ id: mascotImage;
67+ objectName: "mascotImage";
68+ anchors { verticalCenter: parent.verticalCenter; }
69+ readonly property int maxSize: Math.max(width, height) * 4;
70+ source: cardData && cardData["mascot"] || "";
71+ width: units.gu(6);
72+ height: units.gu(5.625);
73+ sourceSize { width: maxSize; height: maxSize }
74+ fillMode: Image.PreserveAspectCrop;
75+ horizontalAlignment: Image.AlignHCenter;
76+ verticalAlignment: Image.AlignVCenter;
77+ visible: showHeader;
7878 }
79−,Item {
80− id: headerTitleContainer;
81− anchors { verticalCenter: parent.verticalCenter; }
82− width: parent.width - x;
83− implicitHeight: titleLabel.height + subtitleLabel.height;
84− data: [
85− Label {
86− id: titleLabel;
87− objectName: "titleLabel";
79+,Item {
80+ id: headerTitleContainer;
81+ anchors { verticalCenter: parent.verticalCenter; }
82+ width: parent.width - x;
83+ implicitHeight: titleLabel.height + subtitleLabel.height;
84+ data: [
85+ Label {
86+ id: titleLabel;
87+ objectName: "titleLabel";
8888 anchors { right: parent.right;
8989 rightMargin: units.gu(1);
9090 left: parent.left;
91− top: parent.top; }
92− elide: Text.ElideRight;
93− fontSize: "small";
94− wrapMode: Text.Wrap;
95− maximumLineCount: 2;
96− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
97− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
98− visible: showHeader ;
99− text: root.title;
100− font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
101− horizontalAlignment: root.headerAlignment;
91+ top: parent.top; }
92+ elide: Text.ElideRight;
93+ fontSize: "small";
94+ wrapMode: Text.Wrap;
95+ maximumLineCount: 2;
96+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
97+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
98+ visible: showHeader ;
99+ text: root.title;
100+ font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
101+ horizontalAlignment: root.headerAlignment;
102102 }
103− ,Label {
104− id: subtitleLabel;
105− objectName: "subtitleLabel";
103+ ,Label {
104+ id: subtitleLabel;
105+ objectName: "subtitleLabel";
106106 anchors { right: parent.right;
107107 left: parent.left;
108108 rightMargin: units.gu(1);
109109 top: titleLabel.bottom;
110− }
111− anchors.topMargin: units.dp(2);
112− elide: Text.ElideRight;
113− fontSize: "small";
114− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
115− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
116− visible: titleLabel.visible && titleLabel.text;
117− text: cardData && cardData["subtitle"] || "";
118− font.weight: Font.Light;
119− horizontalAlignment: root.headerAlignment;
110+ }
111+ anchors.topMargin: units.dp(2);
112+ elide: Text.ElideRight;
113+ fontSize: "small";
114+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
115+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
116+ visible: titleLabel.visible && titleLabel.text;
117+ text: cardData && cardData["subtitle"] || "";
118+ font.weight: Font.Light;
119+ horizontalAlignment: root.headerAlignment;
120120 }
121−
122− ]
121+
122+ ]
123123 }
124−
125− ]
124+
125+ ]
126126 }
127127UbuntuShape {
128128 id: touchdown;
tests/plugins/Dash/cardcreator/4.res+76−76
@@ -1,102 +1,102 @@
1−AbstractButton {
2− id: root;
3− property var template;
4− property var components;
5− property var cardData;
6− property var artShapeBorderSource: undefined;
7− property real fontScale: 1.0;
1+AbstractButton {
2+ id: root;
3+ property var template;
4+ property var components;
5+ property var cardData;
6+ property var artShapeBorderSource: undefined;
7+ property real fontScale: 1.0;
88 property var scopeStyle: null;
99 property int headerAlignment: Text.AlignLeft;
10− property int fixedHeaderHeight: -1;
11− property size fixedArtShapeSize: Qt.size(-1, -1);
12− readonly property string title: cardData && cardData["title"] || "";
13− property bool asynchronous: true;
14− property bool showHeader: true;
15− implicitWidth: childrenRect.width;
10+ property int fixedHeaderHeight: -1;
11+ property size fixedArtShapeSize: Qt.size(-1, -1);
12+ readonly property string title: cardData && cardData["title"] || "";
13+ property bool asynchronous: true;
14+ property bool showHeader: true;
15+ implicitWidth: childrenRect.width;
1616readonly property size artShapeSize: Qt.size(-1, -1);
1717readonly property int headerHeight: row.height;
18−Row {
19− id: row;
20− objectName: "outerRow";
21− property real margins: units.gu(1);
22− spacing: margins;
18+Row {
19+ id: row;
20+ objectName: "outerRow";
21+ property real margins: units.gu(1);
22+ spacing: margins;
2323 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
24− anchors { top: parent.top;
24+ anchors { top: parent.top;
2525 topMargin: units.gu(1);
2626 left: parent.left;
2727}
28− anchors.right: parent.right;
28+ anchors.right: parent.right;
2929 anchors.margins: margins;
3030 anchors.rightMargin: 0;
31−data: [
32−Loader {
33− id: mascotShapeLoader;
34− objectName: "mascotShapeLoader";
35− asynchronous: root.asynchronous;
36− active: mascotImage.status === Image.Ready;
37− visible: showHeader && active && status == Loader.Ready;
38− width: units.gu(6);
39− height: units.gu(5.625);
40− sourceComponent: UbuntuShape { image: mascotImage }
31+data: [
32+Loader {
33+ id: mascotShapeLoader;
34+ objectName: "mascotShapeLoader";
35+ asynchronous: root.asynchronous;
36+ active: mascotImage.status === Image.Ready;
37+ visible: showHeader && active && status == Loader.Ready;
38+ width: units.gu(6);
39+ height: units.gu(5.625);
40+ sourceComponent: UbuntuShape { image: mascotImage }
4141 anchors { verticalCenter: parent.verticalCenter; }
4242 }
4343
44−,Image {
45− id: mascotImage;
46− objectName: "mascotImage";
44+,Image {
45+ id: mascotImage;
46+ objectName: "mascotImage";
4747 anchors { verticalCenter: parent.verticalCenter; }
48− readonly property int maxSize: Math.max(width, height) * 4;
49− source: cardData && cardData["mascot"];
50− width: units.gu(6);
51− height: units.gu(5.625);
52− sourceSize { width: maxSize; height: maxSize }
53− fillMode: Image.PreserveAspectCrop;
54− horizontalAlignment: Image.AlignHCenter;
55− verticalAlignment: Image.AlignVCenter;
56− visible: false;
48+ readonly property int maxSize: Math.max(width, height) * 4;
49+ source: cardData && cardData["mascot"] || "";
50+ width: units.gu(6);
51+ height: units.gu(5.625);
52+ sourceSize { width: maxSize; height: maxSize }
53+ fillMode: Image.PreserveAspectCrop;
54+ horizontalAlignment: Image.AlignHCenter;
55+ verticalAlignment: Image.AlignVCenter;
56+ visible: false;
5757 }
5858
59−,Item {
60− id: headerTitleContainer;
61− anchors { verticalCenter: parent.verticalCenter; }
62− width: parent.width - x;
63− implicitHeight: titleLabel.height + subtitleLabel.height;
64− data: [
65−Label {
66− id: titleLabel;
67− objectName: "titleLabel";
59+,Item {
60+ id: headerTitleContainer;
61+ anchors { verticalCenter: parent.verticalCenter; }
62+ width: parent.width - x;
63+ implicitHeight: titleLabel.height + subtitleLabel.height;
64+ data: [
65+Label {
66+ id: titleLabel;
67+ objectName: "titleLabel";
6868 anchors { right: parent.right;
69− rightMargin: units.gu(1);
70− left: parent.left;
69+ rightMargin: units.gu(1);
70+ left: parent.left;
7171 top: parent.top; }
72− elide: Text.ElideRight;
73− fontSize: "small";
74− wrapMode: Text.Wrap;
75− maximumLineCount: 2;
76− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
72+ elide: Text.ElideRight;
73+ fontSize: "small";
74+ wrapMode: Text.Wrap;
75+ maximumLineCount: 2;
76+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
7777 color: root.scopeStyle ? root.scopeStyle.foreground : "grey";
78− visible: showHeader ;
79− text: root.title;
80− font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
81− horizontalAlignment: root.headerAlignment;
78+ visible: showHeader ;
79+ text: root.title;
80+ font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
81+ horizontalAlignment: root.headerAlignment;
8282 }
83−,Label {
84− id: subtitleLabel;
85− objectName: "subtitleLabel";
86− anchors { right: parent.right;
87− left: parent.left;
88− rightMargin: units.gu(1);
89− top: titleLabel.bottom;
83+,Label {
84+ id: subtitleLabel;
85+ objectName: "subtitleLabel";
86+ anchors { right: parent.right;
87+ left: parent.left;
88+ rightMargin: units.gu(1);
89+ top: titleLabel.bottom;
9090 }
9191 anchors.topMargin: units.dp(2);
92− elide: Text.ElideRight;
93− fontSize: "small";
94− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
92+ elide: Text.ElideRight;
93+ fontSize: "small";
94+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
9595 color: root.scopeStyle ? root.scopeStyle.foreground : "grey";
96− visible: titleLabel.visible && titleLabel.text;
97− text: cardData && cardData["subtitle"] || "";
98− font.weight: Font.Light;
99− horizontalAlignment: root.headerAlignment;
96+ visible: titleLabel.visible && titleLabel.text;
97+ text: cardData && cardData["subtitle"] || "";
98+ font.weight: Font.Light;
99+ horizontalAlignment: root.headerAlignment;
100100 }
101101]
102102}
tests/plugins/Dash/cardcreator/6.res+84−84
@@ -14,100 +14,100 @@ AbstractButton {
1414 property bool showHeader: true;
1515 implicitWidth: childrenRect.width;
1616Loader {
17− id: backgroundLoader;
18− objectName: "backgroundLoader";
19− anchors.fill: parent;
20− asynchronous: root.asynchronous;
21− visible: status == Loader.Ready;
22− sourceComponent: UbuntuShape {
23− objectName: "background";
24− radius: "medium";
25− color: getColor(0) || "white";
26− gradientColor: getColor(1) || color;
27− anchors.fill: parent;
28− image: backgroundImage.source ? backgroundImage : null;
29− property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30− property Image backgroundImage: Image {
31− objectName: "backgroundImage";
32− source: {
33− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34− else if (template && typeof template["card-background"] === "string") return template["card-background"];
35− else return "";
36− }
37− }
38− function getColor(index) {
39− if (cardData && typeof cardData["background"] === "object"
40− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41− return cardData["background"]["elements"][index];
42− } else if (template && typeof template["card-background"] === "object"
43− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44− return template["card-background"]["elements"][index];
45− } else return undefined;
46− }
47− }
17+ id: backgroundLoader;
18+ objectName: "backgroundLoader";
19+ anchors.fill: parent;
20+ asynchronous: root.asynchronous;
21+ visible: status == Loader.Ready;
22+ sourceComponent: UbuntuShape {
23+ objectName: "background";
24+ radius: "medium";
25+ color: getColor(0) || "white";
26+ gradientColor: getColor(1) || color;
27+ anchors.fill: parent;
28+ image: backgroundImage.source ? backgroundImage : null;
29+ property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30+ property Image backgroundImage: Image {
31+ objectName: "backgroundImage";
32+ source: {
33+ if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34+ else if (template && typeof template["card-background"] === "string") return template["card-background"];
35+ else return "";
36+ }
37+ }
38+ function getColor(index) {
39+ if (cardData && typeof cardData["background"] === "object"
40+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41+ return cardData["background"]["elements"][index];
42+ } else if (template && typeof template["card-background"] === "object"
43+ && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44+ return template["card-background"]["elements"][index];
45+ } else return undefined;
46+ }
47+ }
4848 }
4949readonly property size artShapeSize: Qt.size(-1, -1);
5050readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
51−Item {
52− id: headerTitleContainer;
51+Item {
52+ id: headerTitleContainer;
5353 anchors { right: parent.right; left: parent.left;
54− top: parent.top;
54+ top: parent.top;
5555 topMargin: units.gu(1);
5656 leftMargin: units.gu(1);
57− }
58− width: parent.width - x;
59− implicitHeight: titleLabel.height + subtitleLabel.height;
60− data: [
61− Label {
62− id: titleLabel;
63− objectName: "titleLabel";
64− anchors { right: emblemImage.left;
65− rightMargin: units.gu(0.5);
66− left: parent.left;
67− top: parent.top; }
68− elide: Text.ElideRight;
69− fontSize: "small";
70− wrapMode: Text.Wrap;
71− maximumLineCount: 2;
72− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
74− visible: showHeader ;
75− text: root.title;
76− font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
77− horizontalAlignment: root.headerAlignment;
57+ }
58+ width: parent.width - x;
59+ implicitHeight: titleLabel.height + subtitleLabel.height;
60+ data: [
61+ Label {
62+ id: titleLabel;
63+ objectName: "titleLabel";
64+ anchors { right: emblemImage.left;
65+ rightMargin: emblemImage.width > 0 ? units.gu(0.5) : 0;
66+ left: parent.left;
67+ top: parent.top; }
68+ elide: Text.ElideRight;
69+ fontSize: "small";
70+ wrapMode: Text.Wrap;
71+ maximumLineCount: 2;
72+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
74+ visible: showHeader ;
75+ text: root.title;
76+ font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
77+ horizontalAlignment: root.headerAlignment;
7878 }
79−,Label {
80− id: subtitleLabel;
81− objectName: "subtitleLabel";
82− anchors { right: parent.right;
83− left: parent.left;
84− rightMargin: units.gu(1);
79+,Label {
80+ id: subtitleLabel;
81+ objectName: "subtitleLabel";
82+ anchors { right: parent.right;
83+ left: parent.left;
84+ rightMargin: units.gu(1);
8585 top: titleLabel.bottom;
86− }
87− anchors.topMargin: units.dp(2);
88− elide: Text.ElideRight;
89− fontSize: "small";
90− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
92− visible: titleLabel.visible && titleLabel.text;
93− text: cardData && cardData["subtitle"] || "";
94− font.weight: Font.Light;
95− horizontalAlignment: root.headerAlignment;
86+ }
87+ anchors.topMargin: units.dp(2);
88+ elide: Text.ElideRight;
89+ fontSize: "small";
90+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
92+ visible: titleLabel.visible && titleLabel.text;
93+ text: cardData && cardData["subtitle"] || "";
94+ font.weight: Font.Light;
95+ horizontalAlignment: root.headerAlignment;
9696 }
97−,Image {
98− id: emblemImage;
99− objectName: "emblemImage";
100− anchors {
101− bottom: titleLabel.baseline;
102− right: parent.right;
103− rightMargin: units.gu(1);
104− }
105− source: cardData["emblem"];
106− width: height;
107− height: titleLabel.font.pixelSize;
108− fillMode: Image.PreserveAspectFit;
97+,Image {
98+ id: emblemImage;
99+ objectName: "emblemImage";
100+ anchors {
101+ bottom: titleLabel.baseline;
102+ right: parent.right;
103+ rightMargin: status === Image.Ready ? units.gu(1) : 0;
104+ }
105+ source: cardData && cardData["emblem"] || "";
106+ width: height;
107+ height: status === Image.Ready ? titleLabel.font.pixelSize : 0;
108+ fillMode: Image.PreserveAspectFit;
109109 }
110−
110+
111111 ]
112112 }
113113UbuntuShape {
tests/plugins/Dash/cardcreator/7.res+119−119
@@ -1,140 +1,140 @@
1−AbstractButton {
2− id: root;
3− property var template;
4− property var components;
5− property var cardData;
6− property var artShapeBorderSource: undefined;
7− property real fontScale: 1.0;
8− property var scopeStyle: null;
9− property int headerAlignment: Text.AlignLeft;
10− property int fixedHeaderHeight: -1;
11− property size fixedArtShapeSize: Qt.size(-1, -1);
12− readonly property string title: cardData && cardData["title"] || "";
13− property bool asynchronous: true;
14− property bool showHeader: true;
15− implicitWidth: childrenRect.width;
1+AbstractButton {
2+ id: root;
3+ property var template;
4+ property var components;
5+ property var cardData;
6+ property var artShapeBorderSource: undefined;
7+ property real fontScale: 1.0;
8+ property var scopeStyle: null;
9+ property int headerAlignment: Text.AlignLeft;
10+ property int fixedHeaderHeight: -1;
11+ property size fixedArtShapeSize: Qt.size(-1, -1);
12+ readonly property string title: cardData && cardData["title"] || "";
13+ property bool asynchronous: true;
14+ property bool showHeader: true;
15+ implicitWidth: childrenRect.width;
1616Loader {
17− id: backgroundLoader;
18− objectName: "backgroundLoader";
19− anchors.fill: parent;
20− asynchronous: root.asynchronous;
21− visible: status == Loader.Ready;
22− sourceComponent: UbuntuShape {
23− objectName: "background";
24− radius: "medium";
25− color: getColor(0) || "white";
26− gradientColor: getColor(1) || color;
27− anchors.fill: parent;
28− image: backgroundImage.source ? backgroundImage : null;
29− property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30− property Image backgroundImage: Image {
31− objectName: "backgroundImage";
32− source: {
33− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34− else if (template && typeof template["card-background"] === "string") return template["card-background"];
35− else return "";
36− }
37− }
38− function getColor(index) {
39− if (cardData && typeof cardData["background"] === "object"
40− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41− return cardData["background"]["elements"][index];
42− } else if (template && typeof template["card-background"] === "object"
43− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44− return template["card-background"]["elements"][index];
45− } else return undefined;
46− }
47− }
17+ id: backgroundLoader;
18+ objectName: "backgroundLoader";
19+ anchors.fill: parent;
20+ asynchronous: root.asynchronous;
21+ visible: status == Loader.Ready;
22+ sourceComponent: UbuntuShape {
23+ objectName: "background";
24+ radius: "medium";
25+ color: getColor(0) || "white";
26+ gradientColor: getColor(1) || color;
27+ anchors.fill: parent;
28+ image: backgroundImage.source ? backgroundImage : null;
29+ property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
30+ property Image backgroundImage: Image {
31+ objectName: "backgroundImage";
32+ source: {
33+ if (cardData && typeof cardData["background"] === "string") return cardData["background"];
34+ else if (template && typeof template["card-background"] === "string") return template["card-background"];
35+ else return "";
36+ }
37+ }
38+ function getColor(index) {
39+ if (cardData && typeof cardData["background"] === "object"
40+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
41+ return cardData["background"]["elements"][index];
42+ } else if (template && typeof template["card-background"] === "object"
43+ && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
44+ return template["card-background"]["elements"][index];
45+ } else return undefined;
46+ }
47+ }
4848 }
4949readonly property size artShapeSize: Qt.size(-1, -1);
5050readonly property int headerHeight: row.height;
51−Row {
52− id: row;
53− objectName: "outerRow";
54− property real margins: units.gu(1);
55− spacing: margins;
56− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
57− anchors { top: parent.top;
51+Row {
52+ id: row;
53+ objectName: "outerRow";
54+ property real margins: units.gu(1);
55+ spacing: margins;
56+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
57+ anchors { top: parent.top;
5858 topMargin: units.gu(1);
5959 left: parent.left;
60− }
61− anchors.right: parent.right;
60+ }
61+ anchors.right: parent.right;
6262 anchors.margins: margins;
6363 anchors.rightMargin: 0;
64− data: [
65−Image {
66− id: mascotImage;
67− objectName: "mascotImage";
68− anchors { verticalCenter: parent.verticalCenter; }
69− readonly property int maxSize: Math.max(width, height) * 4;
70− source: cardData && cardData["mascot"];
71− width: units.gu(6);
72− height: units.gu(5.625);
73− sourceSize { width: maxSize; height: maxSize }
74− fillMode: Image.PreserveAspectCrop;
75− horizontalAlignment: Image.AlignHCenter;
76− verticalAlignment: Image.AlignVCenter;
77− visible: showHeader;
64+ data: [
65+Image {
66+ id: mascotImage;
67+ objectName: "mascotImage";
68+ anchors { verticalCenter: parent.verticalCenter; }
69+ readonly property int maxSize: Math.max(width, height) * 4;
70+ source: cardData && cardData["mascot"] || "";
71+ width: units.gu(6);
72+ height: units.gu(5.625);
73+ sourceSize { width: maxSize; height: maxSize }
74+ fillMode: Image.PreserveAspectCrop;
75+ horizontalAlignment: Image.AlignHCenter;
76+ verticalAlignment: Image.AlignVCenter;
77+ visible: showHeader;
7878 }
7979
80−,Item {
81− id: headerTitleContainer;
82− anchors { verticalCenter: parent.verticalCenter; }
83− width: parent.width - x;
84− implicitHeight: titleLabel.height + subtitleLabel.height + attributesRow.height;
85− data: [
86− Label {
87− id: titleLabel;
88− objectName: "titleLabel";
89− anchors { right: parent.right;
90− rightMargin: units.gu(1);
91− left: parent.left;
92− top: parent.top; }
93− elide: Text.ElideRight;
94− fontSize: "small";
95− wrapMode: Text.Wrap;
96− maximumLineCount: 2;
97− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
98− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
99− visible: showHeader ;
100− text: root.title;
101− font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
102− horizontalAlignment: root.headerAlignment;
80+,Item {
81+ id: headerTitleContainer;
82+ anchors { verticalCenter: parent.verticalCenter; }
83+ width: parent.width - x;
84+ implicitHeight: titleLabel.height + subtitleLabel.height + attributesRow.height;
85+ data: [
86+ Label {
87+ id: titleLabel;
88+ objectName: "titleLabel";
89+ anchors { right: parent.right;
90+ rightMargin: units.gu(1);
91+ left: parent.left;
92+ top: parent.top; }
93+ elide: Text.ElideRight;
94+ fontSize: "small";
95+ wrapMode: Text.Wrap;
96+ maximumLineCount: 2;
97+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
98+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
99+ visible: showHeader ;
100+ text: root.title;
101+ font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
102+ horizontalAlignment: root.headerAlignment;
103103 }
104−,Label {
105− id: subtitleLabel;
106− objectName: "subtitleLabel";
107− anchors { right: parent.right;
108− left: parent.left;
109− rightMargin: units.gu(1);
110− top: titleLabel.bottom;
111− }
112− anchors.topMargin: units.dp(2);
113− elide: Text.ElideRight;
114− fontSize: "small";
115− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
117− visible: titleLabel.visible && titleLabel.text;
118− text: cardData && cardData["subtitle"] || "";
119− font.weight: Font.Light;
120− horizontalAlignment: root.headerAlignment;
104+,Label {
105+ id: subtitleLabel;
106+ objectName: "subtitleLabel";
107+ anchors { right: parent.right;
108+ left: parent.left;
109+ rightMargin: units.gu(1);
110+ top: titleLabel.bottom;
111+ }
112+ anchors.topMargin: units.dp(2);
113+ elide: Text.ElideRight;
114+ fontSize: "small";
115+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
117+ visible: titleLabel.visible && titleLabel.text;
118+ text: cardData && cardData["subtitle"] || "";
119+ font.weight: Font.Light;
120+ horizontalAlignment: root.headerAlignment;
121121 }
122−,CardAttributes {
123− id: attributesRow;
124− objectName: "attributesRow";
122+,CardAttributes {
123+ id: attributesRow;
124+ objectName: "attributesRow";
125125 anchors { right: parent.right;
126126 left: parent.left;
127127 rightMargin: units.gu(1);
128− top: subtitleLabel.bottom;
129− }
130− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
131− model: cardData["attributes"];
128+ top: subtitleLabel.bottom;
129+ }
130+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey");
131+ model: cardData && cardData["attributes"];
132132 }
133−
133+
134134 ]
135135 }
136−
137− ]
136+
137+ ]
138138 }
139139UbuntuShape {
140140 id: touchdown;