on xenial help sign in
Split artShape code for cardTool card and regular card
c453027Albert Astals Cid
plugins/Dash/CardAttributes.qml+26−18
@@ -43,28 +43,36 @@ GridLayout {
43 Layout.column: index % grid.columns
43 Layout.column: index % grid.columns
44 Layout.row: index / grid.columns
44 Layout.row: index / grid.columns
45 Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
45 Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
46− Layout.maximumWidth: Math.max(icon.width, label.x + label.implicitWidth)
46+ Layout.maximumWidth: Math.max(iconLoader.width, labelLoader.x + labelLoader.implicitWidth)
47 Layout.fillWidth: true
47 Layout.fillWidth: true
48 height: units.gu(2)
48 height: units.gu(2)
49− Icon {
49+ Loader {
50− id: icon
50+ id: iconLoader
51+ readonly property string source: "icon" in modelData && modelData["icon"] || ""
52+ active: source !== ""
53+ sourceComponent: Icon {
51− height: units.gu(2)
54+ height: units.gu(2)
52− // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
55+ // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
53− width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
56+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
54− source: "icon" in modelData && modelData["icon"] || ""
57+ source: parent.source
55− color: grid.color
58+ color: grid.color
59+ }
56 }
60 }
57− Label {
61+ Loader {
58− id: label
62+ id: labelLoader
59 width: parent.width - x
63 width: parent.width - x
64+ readonly property string value: "value" in modelData && modelData["value"] || ""
65+ active: value !== ""
66+ sourceComponent: Label {
60− anchors.verticalCenter: parent.verticalCenter
67+ anchors.verticalCenter: parent.verticalCenter
61− text: "value" in modelData && modelData["value"] || "";
68+ text: parent.value
62− elide: Text.ElideRight
69+ elide: Text.ElideRight
63− maximumLineCount: 1
70+ maximumLineCount: 1
64− font.weight: "style" in modelData && modelData["style"] === "highlighted" ? Font.Bold : Font.Light
71+ font.weight: "style" in modelData && modelData["style"] === "highlighted" ? Font.Bold : Font.Light
65− fontSize: "small"
72+ fontSize: "small"
66− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
73+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
67− color: grid.color
74+ color: grid.color
75+ }
68 }
76 }
69 }
77 }
70 }
78 }
plugins/Dash/CardCreator.js+59−12
@@ -129,6 +129,51 @@ var kArtShapeHolderCode = 'Item { \n\
129 } \n\
129 } \n\
130 }\n';
130 }\n';
131
131
132+// %1 is used as anchors of artShapeHolder
133+// %2 is used as image width
134+// %3 is used as image height
135+// %4 is whether the image should be visible
136+// %5 is used as aspect ratio
137+// %6 is whether the loader should be asynchronous or not
138+// %7 is the shape code we want to use
139+// %8 is injected as code to artImage
140+// %9 is used as image fallback
141+var kArtShapeHolderCodeCardToolCard = 'Item { \n\
142+ id: artShapeHolder; \n\
143+ height: artShapeLoader.height; \n\
144+ width: artShapeLoader.width; \n\
145+ anchors { %1 } \n\
146+ Loader { \n\
147+ id: artShapeLoader; \n\
148+ objectName: "artShapeLoader"; \n\
149+ readonly property string cardArt: cardData && cardData["art"] || %9; \n\
150+ onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
151+ active: cardArt != ""; \n\
152+ asynchronous: %6; \n\
153+ visible: status == Loader.Ready; \n\
154+ sourceComponent: Item { \n\
155+ id: artShape; \n\
156+ objectName: "artShape"; \n\
157+ visible: image.status == Image.Ready; \n\
158+ readonly property alias image: artImage; \n\
159+ %7 \n\
160+ readonly property real aspect: %5; \n\
161+ width: image.status !== Image.Ready ? 0 : image.width; \n\
162+ height: image.status !== Image.Ready ? 0 : image.height; \n\
163+ CroppedImageMinimumSourceSize { \n\
164+ id: artImage; \n\
165+ objectName: "artImage"; \n\
166+ source: artShapeLoader.cardArt; \n\
167+ asynchronous: %6; \n\
168+ visible: %4; \n\
169+ width: %2; \n\
170+ height: %3; \n\
171+ %8 \n\
172+ } \n\
173+ } \n\
174+ } \n\
175+ }\n';
176+
132// %1 is anchors.fill
177// %1 is anchors.fill
133// %2 is width
178// %2 is width
134// %3 is height
179// %3 is height
@@ -416,15 +461,16 @@ function cardString(template, components, isCardTool, artShapeStyle) {
416 property string backgroundShapeStyle: "inset"; \n\
461 property string backgroundShapeStyle: "inset"; \n\
417 property real fontScale: 1.0; \n\
462 property real fontScale: 1.0; \n\
418 property var scopeStyle: null; \n\
463 property var scopeStyle: null; \n\
419− %2\
420− property size fixedArtShapeSize: Qt.size(-1, -1); \n\
421 readonly property string title: cardData && cardData["title"] || ""; \n\
464 readonly property string title: cardData && cardData["title"] || ""; \n\
422 property bool showHeader: true; \n\
465 property bool showHeader: true; \n\
423 implicitWidth: childrenRect.width; \n\
466 implicitWidth: childrenRect.width; \n\
424 enabled: %1; \n\
467 enabled: %1; \n\
425 \n'.arg(templateInteractive);
468 \n'.arg(templateInteractive);
426
469
470+ if (!isCardTool) {
427− code = code.arg(isCardTool ? "" : "property int fixedHeaderHeight: -1; \n");
471+ code += "property int fixedHeaderHeight: -1; \n\
472+ property size fixedArtShapeSize: Qt.size(-1, -1); \n";
473+ }
428
474
429 var hasArt = components["art"] && components["art"]["field"] || false;
475 var hasArt = components["art"] && components["art"]["field"] || false;
430 var hasSummary = components["summary"] || false;
476 var hasSummary = components["summary"] || false;
@@ -533,15 +579,16 @@ function cardString(template, components, isCardTool, artShapeStyle) {
533 } else {
579 } else {
534 artShapeHolderShapeCode = "";
580 artShapeHolderShapeCode = "";
535 }
581 }
582+ var artShapeHolderCode = isCardTool ? kArtShapeHolderCodeCardToolCard : kArtShapeHolderCode;
536− code += kArtShapeHolderCode.arg(artAnchors)
583+ code += artShapeHolderCode.arg(artAnchors)
537− .arg(widthCode)
584+ .arg(widthCode)
538− .arg(heightCode)
585+ .arg(heightCode)
539− .arg(isConciergeMode ? "true" : "false")
586+ .arg(isConciergeMode ? "true" : "false")
540− .arg(aspectRatio)
587+ .arg(aspectRatio)
541− .arg(asynchronous)
588+ .arg(asynchronous)
542− .arg(artShapeHolderShapeCode)
589+ .arg(artShapeHolderShapeCode)
543− .arg(fallbackStatusCode)
590+ .arg(fallbackStatusCode)
544− .arg(fallbackURICode);
591+ .arg(fallbackURICode);
545 } else {
592 } else {
546 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
593 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
547 }
594 }
tests/plugins/Dash/cardcreator/1.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property int fixedHeaderHeight: -1;
8− property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
7+ readonly property string title: cardData && cardData["title"] || "";
10 property bool showHeader: true;
8 property bool showHeader: true;
11− implicitWidth: childrenRect.width;
9+ implicitWidth: childrenRect.width;
12 enabled: true;
10 enabled: true;
11+ property int fixedHeaderHeight: -1;
12+ property size fixedArtShapeSize: Qt.size(-1, -1);
13signal action(var actionId);
13signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
tests/plugins/Dash/cardcreator/1.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
13readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
12readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14Item {
13Item {
15 id: artShapeHolder;
14 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
15+ height: artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
16+ width: artShapeLoader.width;
18 anchors { horizontalCenter: parent.horizontalCenter; }
17 anchors { horizontalCenter: parent.horizontalCenter; }
19 Loader {
18 Loader {
20 id: artShapeLoader;
19 id: artShapeLoader;
@@ -36,19 +35,9 @@ Item {
36 radius: "medium";
35 radius: "medium";
37 aspect: UbuntuShape.Inset;
36 aspect: UbuntuShape.Inset;
38 }
37 }
39− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
38+ readonly property real aspect: 1.6;
40− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1.6;
41− Component.onCompleted: { updateWidthHeightBindings(); }
42− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
43− function updateWidthHeightBindings() {
44− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
45− width = root.fixedArtShapeSize.width;
46− height = root.fixedArtShapeSize.height;
47− } else {
48− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
39+ width: image.status !== Image.Ready ? 0 : image.width;
49− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
40+ height: image.status !== Image.Ready ? 0 : image.height;
50− }
51− }
52 CroppedImageMinimumSourceSize {
41 CroppedImageMinimumSourceSize {
53 id: artImage;
42 id: artImage;
54 objectName: "artImage";
43 objectName: "artImage";
tests/plugins/Dash/cardcreator/10.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14Loader {
14Loader {
15 id: backgroundLoader;
15 id: backgroundLoader;
tests/plugins/Dash/cardcreator/10.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/11.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14Loader {
14Loader {
15 id: backgroundLoader;
15 id: backgroundLoader;
tests/plugins/Dash/cardcreator/11.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
@@ -51,8 +50,8 @@ Loader {
51readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
50readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
52Item {
51Item {
53 id: artShapeHolder;
52 id: artShapeHolder;
54− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
53+ height: artShapeLoader.height;
55− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
54+ width: artShapeLoader.width;
56 anchors { horizontalCenter: parent.horizontalCenter; }
55 anchors { horizontalCenter: parent.horizontalCenter; }
57 Loader {
56 Loader {
58 id: artShapeLoader;
57 id: artShapeLoader;
@@ -74,19 +73,9 @@ Item {
74 radius: "medium";
73 radius: "medium";
75 aspect: UbuntuShape.Flat;
74 aspect: UbuntuShape.Flat;
76 }
75 }
77− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
76+ readonly property real aspect: 1;
78− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
79− Component.onCompleted: { updateWidthHeightBindings(); }
80− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
81− function updateWidthHeightBindings() {
82− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
83− width = root.fixedArtShapeSize.width;
84− height = root.fixedArtShapeSize.height;
85− } else {
86− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
77+ width: image.status !== Image.Ready ? 0 : image.width;
87− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
78+ height: image.status !== Image.Ready ? 0 : image.height;
88− }
89− }
90 CroppedImageMinimumSourceSize {
79 CroppedImageMinimumSourceSize {
91 id: artImage;
80 id: artImage;
92 objectName: "artImage";
81 objectName: "artImage";
tests/plugins/Dash/cardcreator/12.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
tests/plugins/Dash/cardcreator/12.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
13readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
12readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14Item {
13Item {
15 id: artShapeHolder;
14 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
15+ height: artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
16+ width: artShapeLoader.width;
18 anchors { horizontalCenter: parent.horizontalCenter; }
17 anchors { horizontalCenter: parent.horizontalCenter; }
19 Loader {
18 Loader {
20 id: artShapeLoader;
19 id: artShapeLoader;
@@ -36,19 +35,9 @@ Item {
36 radius: "medium";
35 radius: "medium";
37 aspect: UbuntuShape.Flat;
36 aspect: UbuntuShape.Flat;
38 }
37 }
39− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
38+ readonly property real aspect: 0.75;
40− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75;
41− Component.onCompleted: { updateWidthHeightBindings(); }
42− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
43− function updateWidthHeightBindings() {
44− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
45− width = root.fixedArtShapeSize.width;
46− height = root.fixedArtShapeSize.height;
47− } else {
48− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
39+ width: image.status !== Image.Ready ? 0 : image.width;
49− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
40+ height: image.status !== Image.Ready ? 0 : image.height;
50− }
51− }
52 CroppedImageMinimumSourceSize {
41 CroppedImageMinimumSourceSize {
53 id: artImage;
42 id: artImage;
54 objectName: "artImage";
43 objectName: "artImage";
tests/plugins/Dash/cardcreator/2.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14Loader {
14Loader {
15 id: backgroundLoader;
15 id: backgroundLoader;
tests/plugins/Dash/cardcreator/2.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/3.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
tests/plugins/Dash/cardcreator/3.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
13readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
12readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14Item {
13Item {
15 id: artShapeHolder;
14 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
15+ height: artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
16+ width: artShapeLoader.width;
18 anchors { horizontalCenter: parent.horizontalCenter; }
17 anchors { horizontalCenter: parent.horizontalCenter; }
19 Loader {
18 Loader {
20 id: artShapeLoader;
19 id: artShapeLoader;
@@ -34,19 +33,9 @@ Item {
34 source: artImage;
33 source: artImage;
35 aspect: UbuntuShape.DropShadow;
34 aspect: UbuntuShape.DropShadow;
36 }
35 }
37− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
36+ readonly property real aspect: 0.75;
38− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75;
39− Component.onCompleted: { updateWidthHeightBindings(); }
40− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
41− function updateWidthHeightBindings() {
42− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
43− width = root.fixedArtShapeSize.width;
44− height = root.fixedArtShapeSize.height;
45− } else {
46− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
37+ width: image.status !== Image.Ready ? 0 : image.width;
47− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
38+ height: image.status !== Image.Ready ? 0 : image.height;
48− }
49− }
50 CroppedImageMinimumSourceSize {
39 CroppedImageMinimumSourceSize {
51 id: artImage;
40 id: artImage;
52 objectName: "artImage";
41 objectName: "artImage";
tests/plugins/Dash/cardcreator/4.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14readonly property size artShapeSize: Qt.size(-1, -1);
14readonly property size artShapeSize: Qt.size(-1, -1);
15readonly property int headerHeight: row.height;
15readonly property int headerHeight: row.height;
tests/plugins/Dash/cardcreator/4.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/5.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: false;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: false;
13signal action(var actionId);
13signal action(var actionId);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15Item {
15Item {
tests/plugins/Dash/cardcreator/5.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
13readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
12readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
14Item {
13Item {
15 id: artShapeHolder;
14 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
15+ height: artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
16+ width: artShapeLoader.width;
18 anchors { horizontalCenter: parent.horizontalCenter; }
17 anchors { horizontalCenter: parent.horizontalCenter; }
19 Loader {
18 Loader {
20 id: artShapeLoader;
19 id: artShapeLoader;
@@ -29,19 +28,9 @@ Item {
29 objectName: "artShape";
28 objectName: "artShape";
30 visible: image.status == Image.Ready;
29 visible: image.status == Image.Ready;
31 readonly property alias image: artImage;
30 readonly property alias image: artImage;
32− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
31+ readonly property real aspect: 1;
33− readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
34− Component.onCompleted: { updateWidthHeightBindings(); }
35− Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
36− function updateWidthHeightBindings() {
37− if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
38− width = root.fixedArtShapeSize.width;
39− height = root.fixedArtShapeSize.height;
40− } else {
41− width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
32+ width: image.status !== Image.Ready ? 0 : image.width;
42− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
33+ height: image.status !== Image.Ready ? 0 : image.height;
43− }
44− }
45 CroppedImageMinimumSourceSize {
34 CroppedImageMinimumSourceSize {
46 id: artImage;
35 id: artImage;
47 objectName: "artImage";
36 objectName: "artImage";
tests/plugins/Dash/cardcreator/6.res+2−2
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property int fixedHeaderHeight: -1;
8− property size fixedArtShapeSize: Qt.size(-1, -1);
9 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
10 property bool showHeader: true;
8 property bool showHeader: true;
11 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
12 enabled: true;
10 enabled: true;
11+ property int fixedHeaderHeight: -1;
12+ property size fixedArtShapeSize: Qt.size(-1, -1);
13signal action(var actionId);
13signal action(var actionId);
14Loader {
14Loader {
15 id: backgroundLoader;
15 id: backgroundLoader;
tests/plugins/Dash/cardcreator/6.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/7.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14Loader {
14Loader {
15 id: backgroundLoader;
15 id: backgroundLoader;
tests/plugins/Dash/cardcreator/7.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/8.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14Loader {
14Loader {
15 id: backgroundLoader;
15 id: backgroundLoader;
tests/plugins/Dash/cardcreator/8.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/9.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
7 property int fixedHeaderHeight: -1;
11 property int fixedHeaderHeight: -1;
8 property size fixedArtShapeSize: Qt.size(-1, -1);
12 property size fixedArtShapeSize: Qt.size(-1, -1);
9− readonly property string title: cardData && cardData["title"] || "";
10− property bool showHeader: true;
11− implicitWidth: childrenRect.width;
12− enabled: true;
13signal action(var actionId);
13signal action(var actionId);
14readonly property size artShapeSize: Qt.size(-1, -1);
14readonly property size artShapeSize: Qt.size(-1, -1);
15readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + audioProgressBar.height + audioProgressBar.anchors.topMargin;
15readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + audioProgressBar.height + audioProgressBar.anchors.topMargin;
tests/plugins/Dash/cardcreator/9.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
4 property string backgroundShapeStyle: "inset";
4 property string backgroundShapeStyle: "inset";
5 property real fontScale: 1.0;
5 property real fontScale: 1.0;
6 property var scopeStyle: null;
6 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
8 readonly property string title: cardData && cardData["title"] || "";
7 readonly property string title: cardData && cardData["title"] || "";
9 property bool showHeader: true;
8 property bool showHeader: true;
10 implicitWidth: childrenRect.width;
9 implicitWidth: childrenRect.width;