on xenial help sign in
Make the diff smaller for easier reviewing
149cc79Albert Astals Cid
plugins/Dash/CardCreator.js+32−8
@@ -190,9 +190,10 @@ var kAudioButtonCode = 'AbstractButton { \n\
190 }';
190 }';
191
191
192// %1 is whether the loader should be asynchronous or not
192// %1 is whether the loader should be asynchronous or not
193+// %2 is the header height code
193var kOverlayLoaderCode = 'Loader { \n\
194var kOverlayLoaderCode = 'Loader { \n\
194 id: overlayLoader; \n\
195 id: overlayLoader; \n\
195− readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
196+ readonly property real overlayHeight: %2 + units.gu(2); \n\
196 anchors.fill: artShapeHolder; \n\
197 anchors.fill: artShapeHolder; \n\
197 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
198 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
198 asynchronous: %1; \n\
199 asynchronous: %1; \n\
@@ -214,17 +215,24 @@ function kHeaderRowCodeGenerator() {
214 objectName: "outerRow"; \n\
215 objectName: "outerRow"; \n\
215 property real margins: units.gu(1); \n\
216 property real margins: units.gu(1); \n\
216 spacing: margins; \n\
217 spacing: margins; \n\
217− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
218+ %2\
218 anchors { %1 } \n\
219 anchors { %1 } \n\
219 anchors.right: parent.right; \n\
220 anchors.right: parent.right; \n\
220 anchors.margins: margins; \n\
221 anchors.margins: margins; \n\
221 anchors.rightMargin: 0; \n\
222 anchors.rightMargin: 0; \n\
222 data: [ \n\
223 data: [ \n\
223− %2 \n\
224+ %3 \n\
224 ] \n\
225 ] \n\
225 }\n';
226 }\n';
226 var args = Array.prototype.slice.call(arguments);
227 var args = Array.prototype.slice.call(arguments);
228+ var isCardTool = args.shift();
229+ var heightCode;
230+ if (!isCardTool) {
231+ heightCode = "height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n";
232+ } else {
233+ heightCode = "";
234+ }
227− var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(',\n'));
235+ var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(heightCode).arg(args.join(',\n'));
228 return code;
236 return code;
229}
237}
230
238
@@ -415,7 +423,7 @@ function cardString(template, components, isCardTool) {
415 property real fontScale: 1.0; \n\
423 property real fontScale: 1.0; \n\
416 property var scopeStyle: null; \n\
424 property var scopeStyle: null; \n\
417 property int titleAlignment: Text.AlignLeft; \n\
425 property int titleAlignment: Text.AlignLeft; \n\
418− property int fixedHeaderHeight: -1; \n\
426+ %2\
419 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
427 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
420 readonly property string title: cardData && cardData["title"] || ""; \n\
428 readonly property string title: cardData && cardData["title"] || ""; \n\
421 property bool showHeader: true; \n\
429 property bool showHeader: true; \n\
@@ -423,6 +431,12 @@ function cardString(template, components, isCardTool) {
423 enabled: %1; \n\
431 enabled: %1; \n\
424 \n'.arg(templateInteractive);
432 \n'.arg(templateInteractive);
425
433
434+ if (!isCardTool) {
435+ code = code.arg("property int fixedHeaderHeight: -1; \n");
436+ } else {
437+ code = code.arg("");
438+ }
439+
426 var hasArt = components["art"] && components["art"]["field"] || false;
440 var hasArt = components["art"] && components["art"]["field"] || false;
427 var hasSummary = components["summary"] || false;
441 var hasSummary = components["summary"] || false;
428 var isConciergeMode = components["art"] && components["art"]["conciergeMode"] || false;
442 var isConciergeMode = components["art"] && components["art"]["conciergeMode"] || false;
@@ -524,7 +538,13 @@ function cardString(template, components, isCardTool) {
524 }
538 }
525
539
526 if (headerAsOverlay) {
540 if (headerAsOverlay) {
541+ var headerHeightCode;
542+ if (isCardTool) {
543+ headerHeightCode = "headerHeight";
544+ } else {
545+ headerHeightCode = "(fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight)";
546+ }
527− code += kOverlayLoaderCode.arg(asynchronous);
547+ code += kOverlayLoaderCode.arg(asynchronous).arg(headerHeightCode);
528 }
548 }
529
549
530 var headerVerticalAnchors;
550 var headerVerticalAnchors;
@@ -770,7 +790,7 @@ function cardString(template, components, isCardTool) {
770 if (mascotShapeCode != '') {
790 if (mascotShapeCode != '') {
771 rowCode.unshift(mascotShapeCode);
791 rowCode.unshift(mascotShapeCode);
772 }
792 }
773− code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
793+ code += kHeaderRowCodeGenerator(isCardTool, headerVerticalAnchors + headerLeftAnchor, rowCode)
774 } else {
794 } else {
775 code += mascotShapeCode + mascotCode + titleSubtitleCode;
795 code += mascotShapeCode + mascotCode + titleSubtitleCode;
776 }
796 }
@@ -794,7 +814,11 @@ function cardString(template, components, isCardTool) {
794 } else {
814 } else {
795 audioButtonAnchorsFill = 'undefined';
815 audioButtonAnchorsFill = 'undefined';
796 audioButtonWidth = 'height';
816 audioButtonWidth = 'height';
817+ if (isCardTool) {
818+ audioButtonHeight = 'headerHeight + 2 * units.gu(1)';
819+ } else {
797− audioButtonHeight = '(root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1)';
820+ audioButtonHeight = '(root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1)';
821+ }
798 }
822 }
799 code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight);
823 code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight);
800 }
824 }
tests/plugins/Dash/cardcreator/1.res.cardcreator−1
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
tests/plugins/Dash/cardcreator/10.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
58 objectName: "outerRow";
57 objectName: "outerRow";
59 property real margins: units.gu(1);
58 property real margins: units.gu(1);
60 spacing: margins;
59 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
62 anchors { top: parent.top;
60 anchors { top: parent.top;
63 topMargin: units.gu(1);
61 topMargin: units.gu(1);
64left: parent.left;
62left: parent.left;
tests/plugins/Dash/cardcreator/11.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -132,7 +131,6 @@ Row {
132 objectName: "outerRow";
131 objectName: "outerRow";
133 property real margins: units.gu(1);
132 property real margins: units.gu(1);
134 spacing: margins;
133 spacing: margins;
135− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
136 anchors { top: artShapeHolder.bottom;
134 anchors { top: artShapeHolder.bottom;
137 topMargin: units.gu(1);
135 topMargin: units.gu(1);
138left: parent.left;
136left: parent.left;
tests/plugins/Dash/cardcreator/2.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
58 objectName: "outerRow";
57 objectName: "outerRow";
59 property real margins: units.gu(1);
58 property real margins: units.gu(1);
60 spacing: margins;
59 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
62 anchors { top: parent.top;
60 anchors { top: parent.top;
63 topMargin: units.gu(1);
61 topMargin: units.gu(1);
64 left: parent.left;
62 left: parent.left;
tests/plugins/Dash/cardcreator/3.res.cardcreator−1
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
tests/plugins/Dash/cardcreator/4.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -20,7 +19,6 @@ Row {
20 objectName: "outerRow";
19 objectName: "outerRow";
21 property real margins: units.gu(1);
20 property real margins: units.gu(1);
22 spacing: margins;
21 spacing: margins;
23− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
24 anchors { top: parent.top;
22 anchors { top: parent.top;
25 topMargin: units.gu(1);
23 topMargin: units.gu(1);
26 left: parent.left;
24 left: parent.left;
tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -90,7 +89,7 @@ Item {
90 }
89 }
91Loader {
90Loader {
92 id: overlayLoader;
91 id: overlayLoader;
93− readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
92+ readonly property real overlayHeight: headerHeight + units.gu(2);
94 anchors.fill: artShapeHolder;
93 anchors.fill: artShapeHolder;
95 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
94 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
96 asynchronous: false;
95 asynchronous: false;
tests/plugins/Dash/cardcreator/6.res.cardcreator−1
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
tests/plugins/Dash/cardcreator/7.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
58 objectName: "outerRow";
57 objectName: "outerRow";
59 property real margins: units.gu(1);
58 property real margins: units.gu(1);
60 spacing: margins;
59 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
62 anchors { top: parent.top;
60 anchors { top: parent.top;
63 topMargin: units.gu(1);
61 topMargin: units.gu(1);
64 left: parent.left;
62 left: parent.left;
tests/plugins/Dash/cardcreator/8.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
58 objectName: "outerRow";
57 objectName: "outerRow";
59 property real margins: units.gu(1);
58 property real margins: units.gu(1);
60 spacing: margins;
59 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
62 anchors { top: parent.top;
60 anchors { top: parent.top;
63 topMargin: units.gu(1);
61 topMargin: units.gu(1);
64left: parent.left;
62left: parent.left;
tests/plugins/Dash/cardcreator/9.res.cardcreator+1−2
@@ -6,7 +6,6 @@ AbstractButton {
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
9 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
10 readonly property string title: cardData && cardData["title"] || "";
12 property bool showHeader: true;
11 property bool showHeader: true;
@@ -71,7 +70,7 @@ CardAudioProgress {
71 id: audioButton;
70 id: audioButton;
72 anchors.fill: undefined;
71 anchors.fill: undefined;
73 width: height;
72 width: height;
74− height: (root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1);
73+ height: headerHeight + 2 * units.gu(1);
75 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || "";
74 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || "";
76 UbuntuShape {
75 UbuntuShape {
77 anchors.fill: parent;
76 anchors.fill: parent;