on xenial help sign in
Split artShape code for cardTool card and regular card

The cardTool card never has a fixedArtShapeSize so it does not need all the code to take it into account

commitc4530278451169b56fe4b8cdd76bc513792fcd2a authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 17 Jun 2016, 01:13 (10 years ago) parentd3db405ddd4d0e
26 files changed+156−163
plugins/Dash/CardAttributes.qml+26−18 plugins/Dash/CardCreator.js+59−12 tests/plugins/Dash/cardcreator/1.res+4−4 tests/plugins/Dash/cardcreator/1.res.cardcreator+5−16 tests/plugins/Dash/cardcreator/10.res+4−4 tests/plugins/Dash/cardcreator/10.res.cardcreator−1 tests/plugins/Dash/cardcreator/11.res+4−4 tests/plugins/Dash/cardcreator/11.res.cardcreator+5−16 tests/plugins/Dash/cardcreator/12.res+4−4 tests/plugins/Dash/cardcreator/12.res.cardcreator+5−16 tests/plugins/Dash/cardcreator/2.res+4−4 tests/plugins/Dash/cardcreator/2.res.cardcreator−1 tests/plugins/Dash/cardcreator/3.res+4−4 tests/plugins/Dash/cardcreator/3.res.cardcreator+5−16 tests/plugins/Dash/cardcreator/4.res+4−4 tests/plugins/Dash/cardcreator/4.res.cardcreator−1 tests/plugins/Dash/cardcreator/5.res+4−4 tests/plugins/Dash/cardcreator/5.res.cardcreator+5−16 tests/plugins/Dash/cardcreator/6.res+2−2 tests/plugins/Dash/cardcreator/6.res.cardcreator−1 tests/plugins/Dash/cardcreator/7.res+4−4 tests/plugins/Dash/cardcreator/7.res.cardcreator−1 tests/plugins/Dash/cardcreator/8.res+4−4 tests/plugins/Dash/cardcreator/8.res.cardcreator−1 tests/plugins/Dash/cardcreator/9.res+4−4 tests/plugins/Dash/cardcreator/9.res.cardcreator−1
plugins/Dash/CardAttributes.qml+26−18
@@ -43,28 +43,36 @@ GridLayout {
4343 Layout.column: index % grid.columns
4444 Layout.row: index / grid.columns
4545 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)
4747 Layout.fillWidth: true
4848 height: units.gu(2)
49− Icon {
50− id: icon
51− height: units.gu(2)
52− // 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
54− source: "icon" in modelData && modelData["icon"] || ""
55− color: grid.color
49+ Loader {
50+ id: iconLoader
51+ readonly property string source: "icon" in modelData && modelData["icon"] || ""
52+ active: source !== ""
53+ sourceComponent: Icon {
54+ height: units.gu(2)
55+ // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
56+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
57+ source: parent.source
58+ color: grid.color
59+ }
5660 }
57− Label {
58− id: label
61+ Loader {
62+ id: labelLoader
5963 width: parent.width - x
60− anchors.verticalCenter: parent.verticalCenter
61− text: "value" in modelData && modelData["value"] || "";
62− elide: Text.ElideRight
63− maximumLineCount: 1
64− font.weight: "style" in modelData && modelData["style"] === "highlighted" ? Font.Bold : Font.Light
65− fontSize: "small"
66− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
67− color: grid.color
64+ readonly property string value: "value" in modelData && modelData["value"] || ""
65+ active: value !== ""
66+ sourceComponent: Label {
67+ anchors.verticalCenter: parent.verticalCenter
68+ text: parent.value
69+ elide: Text.ElideRight
70+ maximumLineCount: 1
71+ font.weight: "style" in modelData && modelData["style"] === "highlighted" ? Font.Bold : Font.Light
72+ fontSize: "small"
73+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
74+ color: grid.color
75+ }
6876 }
6977 }
7078 }
plugins/Dash/CardCreator.js+59−12
@@ -129,6 +129,51 @@ var kArtShapeHolderCode = 'Item { \n\
129129 } \n\
130130 }\n';
131131
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+
132177// %1 is anchors.fill
133178// %2 is width
134179// %3 is height
@@ -416,15 +461,16 @@ function cardString(template, components, isCardTool, artShapeStyle) {
416461 property string backgroundShapeStyle: "inset"; \n\
417462 property real fontScale: 1.0; \n\
418463 property var scopeStyle: null; \n\
419− %2\
420− property size fixedArtShapeSize: Qt.size(-1, -1); \n\
421464 readonly property string title: cardData && cardData["title"] || ""; \n\
422465 property bool showHeader: true; \n\
423466 implicitWidth: childrenRect.width; \n\
424467 enabled: %1; \n\
425468 \n'.arg(templateInteractive);
426469
427− code = code.arg(isCardTool ? "" : "property int fixedHeaderHeight: -1; \n");
470+ if (!isCardTool) {
471+ code += "property int fixedHeaderHeight: -1; \n\
472+ property size fixedArtShapeSize: Qt.size(-1, -1); \n";
473+ }
428474
429475 var hasArt = components["art"] && components["art"]["field"] || false;
430476 var hasSummary = components["summary"] || false;
@@ -533,15 +579,16 @@ function cardString(template, components, isCardTool, artShapeStyle) {
533579 } else {
534580 artShapeHolderShapeCode = "";
535581 }
536− code += kArtShapeHolderCode.arg(artAnchors)
537− .arg(widthCode)
538− .arg(heightCode)
539− .arg(isConciergeMode ? "true" : "false")
540− .arg(aspectRatio)
541− .arg(asynchronous)
542− .arg(artShapeHolderShapeCode)
543− .arg(fallbackStatusCode)
544− .arg(fallbackURICode);
582+ var artShapeHolderCode = isCardTool ? kArtShapeHolderCodeCardToolCard : kArtShapeHolderCode;
583+ code += artShapeHolderCode.arg(artAnchors)
584+ .arg(widthCode)
585+ .arg(heightCode)
586+ .arg(isConciergeMode ? "true" : "false")
587+ .arg(aspectRatio)
588+ .arg(asynchronous)
589+ .arg(artShapeHolderShapeCode)
590+ .arg(fallbackStatusCode)
591+ .arg(fallbackURICode);
545592 } else {
546593 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
547594 }
tests/plugins/Dash/cardcreator/1.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 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"] || "";
108 property bool showHeader: true;
11− implicitWidth: childrenRect.width;
9+ implicitWidth: childrenRect.width;
1210 enabled: true;
11+ property int fixedHeaderHeight: -1;
12+ property size fixedArtShapeSize: Qt.size(-1, -1);
1313signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
tests/plugins/Dash/cardcreator/1.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
1312readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1413Item {
1514 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
15+ height: artShapeLoader.height;
16+ width: artShapeLoader.width;
1817 anchors { horizontalCenter: parent.horizontalCenter; }
1918 Loader {
2019 id: artShapeLoader;
@@ -36,19 +35,9 @@ Item {
3635 radius: "medium";
3736 aspect: UbuntuShape.Inset;
3837 }
39− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
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 });
49− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
50− }
51− }
38+ readonly property real aspect: 1.6;
39+ width: image.status !== Image.Ready ? 0 : image.width;
40+ height: image.status !== Image.Ready ? 0 : image.height;
5241 CroppedImageMinimumSourceSize {
5342 id: artImage;
5443 objectName: "artImage";
tests/plugins/Dash/cardcreator/10.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414Loader {
1515 id: backgroundLoader;
tests/plugins/Dash/cardcreator/10.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/11.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414Loader {
1515 id: backgroundLoader;
tests/plugins/Dash/cardcreator/11.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
@@ -51,8 +50,8 @@ Loader {
5150readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
5251Item {
5352 id: artShapeHolder;
54− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
55− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
53+ height: artShapeLoader.height;
54+ width: artShapeLoader.width;
5655 anchors { horizontalCenter: parent.horizontalCenter; }
5756 Loader {
5857 id: artShapeLoader;
@@ -74,19 +73,9 @@ Item {
7473 radius: "medium";
7574 aspect: UbuntuShape.Flat;
7675 }
77− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -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 });
87− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
88− }
89− }
76+ readonly property real aspect: 1;
77+ width: image.status !== Image.Ready ? 0 : image.width;
78+ height: image.status !== Image.Ready ? 0 : image.height;
9079 CroppedImageMinimumSourceSize {
9180 id: artImage;
9281 objectName: "artImage";
tests/plugins/Dash/cardcreator/12.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
tests/plugins/Dash/cardcreator/12.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
1312readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1413Item {
1514 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
15+ height: artShapeLoader.height;
16+ width: artShapeLoader.width;
1817 anchors { horizontalCenter: parent.horizontalCenter; }
1918 Loader {
2019 id: artShapeLoader;
@@ -36,19 +35,9 @@ Item {
3635 radius: "medium";
3736 aspect: UbuntuShape.Flat;
3837 }
39− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
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 });
49− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
50− }
51− }
38+ readonly property real aspect: 0.75;
39+ width: image.status !== Image.Ready ? 0 : image.width;
40+ height: image.status !== Image.Ready ? 0 : image.height;
5241 CroppedImageMinimumSourceSize {
5342 id: artImage;
5443 objectName: "artImage";
tests/plugins/Dash/cardcreator/2.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414Loader {
1515 id: backgroundLoader;
tests/plugins/Dash/cardcreator/2.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/3.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
tests/plugins/Dash/cardcreator/3.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
1312readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1413Item {
1514 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
15+ height: artShapeLoader.height;
16+ width: artShapeLoader.width;
1817 anchors { horizontalCenter: parent.horizontalCenter; }
1918 Loader {
2019 id: artShapeLoader;
@@ -34,19 +33,9 @@ Item {
3433 source: artImage;
3534 aspect: UbuntuShape.DropShadow;
3635 }
37− readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
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 });
47− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
48− }
49− }
36+ readonly property real aspect: 0.75;
37+ width: image.status !== Image.Ready ? 0 : image.width;
38+ height: image.status !== Image.Ready ? 0 : image.height;
5039 CroppedImageMinimumSourceSize {
5140 id: artImage;
5241 objectName: "artImage";
tests/plugins/Dash/cardcreator/4.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414readonly property size artShapeSize: Qt.size(-1, -1);
1515readonly property int headerHeight: row.height;
tests/plugins/Dash/cardcreator/4.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/5.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: false;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1515Item {
tests/plugins/Dash/cardcreator/5.res.cardcreator+5−16
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
@@ -13,8 +12,8 @@ signal action(var actionId);
1312readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1413Item {
1514 id: artShapeHolder;
16− height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
17− width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
15+ height: artShapeLoader.height;
16+ width: artShapeLoader.width;
1817 anchors { horizontalCenter: parent.horizontalCenter; }
1918 Loader {
2019 id: artShapeLoader;
@@ -29,19 +28,9 @@ Item {
2928 objectName: "artShape";
3029 visible: image.status == Image.Ready;
3130 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;
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 });
42− height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
43− }
44− }
31+ readonly property real aspect: 1;
32+ width: image.status !== Image.Ready ? 0 : image.width;
33+ height: image.status !== Image.Ready ? 0 : image.height;
4534 CroppedImageMinimumSourceSize {
4635 id: artImage;
4736 objectName: "artImage";
tests/plugins/Dash/cardcreator/6.res+2−2
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property int fixedHeaderHeight: -1;
8− property size fixedArtShapeSize: Qt.size(-1, -1);
97 readonly property string title: cardData && cardData["title"] || "";
108 property bool showHeader: true;
119 implicitWidth: childrenRect.width;
1210 enabled: true;
11+ property int fixedHeaderHeight: -1;
12+ property size fixedArtShapeSize: Qt.size(-1, -1);
1313signal action(var actionId);
1414Loader {
1515 id: backgroundLoader;
tests/plugins/Dash/cardcreator/6.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/7.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414Loader {
1515 id: backgroundLoader;
tests/plugins/Dash/cardcreator/7.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/8.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414Loader {
1515 id: backgroundLoader;
tests/plugins/Dash/cardcreator/8.res.cardcreator−1
@@ -4,7 +4,6 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;
tests/plugins/Dash/cardcreator/9.res+4−4
@@ -4,12 +4,12 @@ AbstractButton {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7+ readonly property string title: cardData && cardData["title"] || "";
8+ property bool showHeader: true;
9+ implicitWidth: childrenRect.width;
10+ enabled: true;
711 property int fixedHeaderHeight: -1;
812 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;
1313signal action(var actionId);
1414readonly property size artShapeSize: Qt.size(-1, -1);
1515readonly 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 {
44 property string backgroundShapeStyle: "inset";
55 property real fontScale: 1.0;
66 property var scopeStyle: null;
7− property size fixedArtShapeSize: Qt.size(-1, -1);
87 readonly property string title: cardData && cardData["title"] || "";
98 property bool showHeader: true;
109 implicitWidth: childrenRect.width;