on xenial help sign in
Make the diff smaller for easier reviewing
commit149cc7973ceea64c248b96749bcc47cbc6397f01 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 16 Feb 2016, 15:15 (11 years ago) parent2cd0d2a
12 files changed+34−27
plugins/Dash/CardCreator.js+32−8 tests/plugins/Dash/cardcreator/1.res.cardcreator−1 tests/plugins/Dash/cardcreator/10.res.cardcreator−2 tests/plugins/Dash/cardcreator/11.res.cardcreator−2 tests/plugins/Dash/cardcreator/2.res.cardcreator−2 tests/plugins/Dash/cardcreator/3.res.cardcreator−1 tests/plugins/Dash/cardcreator/4.res.cardcreator−2 tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/6.res.cardcreator−1 tests/plugins/Dash/cardcreator/7.res.cardcreator−2 tests/plugins/Dash/cardcreator/8.res.cardcreator−2 tests/plugins/Dash/cardcreator/9.res.cardcreator+1−2
plugins/Dash/CardCreator.js+32−8
@@ -190,9 +190,10 @@ var kAudioButtonCode = 'AbstractButton { \n\
190190 }';
191191
192192// %1 is whether the loader should be asynchronous or not
193+// %2 is the header height code
193194var kOverlayLoaderCode = 'Loader { \n\
194195 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\
196197 anchors.fill: artShapeHolder; \n\
197198 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
198199 asynchronous: %1; \n\
@@ -214,17 +215,24 @@ function kHeaderRowCodeGenerator() {
214215 objectName: "outerRow"; \n\
215216 property real margins: units.gu(1); \n\
216217 spacing: margins; \n\
217− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
218+ %2\
218219 anchors { %1 } \n\
219220 anchors.right: parent.right; \n\
220221 anchors.margins: margins; \n\
221222 anchors.rightMargin: 0; \n\
222223 data: [ \n\
223− %2 \n\
224+ %3 \n\
224225 ] \n\
225226 }\n';
226227 var args = Array.prototype.slice.call(arguments);
227− var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(',\n'));
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+ }
235+ var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(heightCode).arg(args.join(',\n'));
228236 return code;
229237}
230238
@@ -415,7 +423,7 @@ function cardString(template, components, isCardTool) {
415423 property real fontScale: 1.0; \n\
416424 property var scopeStyle: null; \n\
417425 property int titleAlignment: Text.AlignLeft; \n\
418− property int fixedHeaderHeight: -1; \n\
426+ %2\
419427 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
420428 readonly property string title: cardData && cardData["title"] || ""; \n\
421429 property bool showHeader: true; \n\
@@ -423,6 +431,12 @@ function cardString(template, components, isCardTool) {
423431 enabled: %1; \n\
424432 \n'.arg(templateInteractive);
425433
434+ if (!isCardTool) {
435+ code = code.arg("property int fixedHeaderHeight: -1; \n");
436+ } else {
437+ code = code.arg("");
438+ }
439+
426440 var hasArt = components["art"] && components["art"]["field"] || false;
427441 var hasSummary = components["summary"] || false;
428442 var isConciergeMode = components["art"] && components["art"]["conciergeMode"] || false;
@@ -524,7 +538,13 @@ function cardString(template, components, isCardTool) {
524538 }
525539
526540 if (headerAsOverlay) {
527− code += kOverlayLoaderCode.arg(asynchronous);
541+ var headerHeightCode;
542+ if (isCardTool) {
543+ headerHeightCode = "headerHeight";
544+ } else {
545+ headerHeightCode = "(fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight)";
546+ }
547+ code += kOverlayLoaderCode.arg(asynchronous).arg(headerHeightCode);
528548 }
529549
530550 var headerVerticalAnchors;
@@ -770,7 +790,7 @@ function cardString(template, components, isCardTool) {
770790 if (mascotShapeCode != '') {
771791 rowCode.unshift(mascotShapeCode);
772792 }
773− code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
793+ code += kHeaderRowCodeGenerator(isCardTool, headerVerticalAnchors + headerLeftAnchor, rowCode)
774794 } else {
775795 code += mascotShapeCode + mascotCode + titleSubtitleCode;
776796 }
@@ -794,7 +814,11 @@ function cardString(template, components, isCardTool) {
794814 } else {
795815 audioButtonAnchorsFill = 'undefined';
796816 audioButtonWidth = 'height';
797− audioButtonHeight = '(root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1)';
817+ if (isCardTool) {
818+ audioButtonHeight = 'headerHeight + 2 * units.gu(1)';
819+ } else {
820+ audioButtonHeight = '(root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1)';
821+ }
798822 }
799823 code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight);
800824 }
tests/plugins/Dash/cardcreator/1.res.cardcreator−1
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
tests/plugins/Dash/cardcreator/10.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
5857 objectName: "outerRow";
5958 property real margins: units.gu(1);
6059 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6260 anchors { top: parent.top;
6361 topMargin: units.gu(1);
6462left: parent.left;
tests/plugins/Dash/cardcreator/11.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -132,7 +131,6 @@ Row {
132131 objectName: "outerRow";
133132 property real margins: units.gu(1);
134133 spacing: margins;
135− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
136134 anchors { top: artShapeHolder.bottom;
137135 topMargin: units.gu(1);
138136left: parent.left;
tests/plugins/Dash/cardcreator/2.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
5857 objectName: "outerRow";
5958 property real margins: units.gu(1);
6059 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6260 anchors { top: parent.top;
6361 topMargin: units.gu(1);
6462 left: parent.left;
tests/plugins/Dash/cardcreator/3.res.cardcreator−1
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
tests/plugins/Dash/cardcreator/4.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -20,7 +19,6 @@ Row {
2019 objectName: "outerRow";
2120 property real margins: units.gu(1);
2221 spacing: margins;
23− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
2422 anchors { top: parent.top;
2523 topMargin: units.gu(1);
2624 left: parent.left;
tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -90,7 +89,7 @@ Item {
9089 }
9190Loader {
9291 id: overlayLoader;
93− readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
92+ readonly property real overlayHeight: headerHeight + units.gu(2);
9493 anchors.fill: artShapeHolder;
9594 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
9695 asynchronous: false;
tests/plugins/Dash/cardcreator/6.res.cardcreator−1
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
tests/plugins/Dash/cardcreator/7.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
5857 objectName: "outerRow";
5958 property real margins: units.gu(1);
6059 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6260 anchors { top: parent.top;
6361 topMargin: units.gu(1);
6462 left: parent.left;
tests/plugins/Dash/cardcreator/8.res.cardcreator−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -58,7 +57,6 @@ Row {
5857 objectName: "outerRow";
5958 property real margins: units.gu(1);
6059 spacing: margins;
61− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6260 anchors { top: parent.top;
6361 topMargin: units.gu(1);
6462left: parent.left;
tests/plugins/Dash/cardcreator/9.res.cardcreator+1−2
@@ -6,7 +6,6 @@ AbstractButton {
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
9− property int fixedHeaderHeight: -1;
109 property size fixedArtShapeSize: Qt.size(-1, -1);
1110 readonly property string title: cardData && cardData["title"] || "";
1211 property bool showHeader: true;
@@ -71,7 +70,7 @@ CardAudioProgress {
7170 id: audioButton;
7271 anchors.fill: undefined;
7372 width: height;
74− height: (root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1);
73+ height: headerHeight + 2 * units.gu(1);
7574 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || "";
7675 UbuntuShape {
7776 anchors.fill: parent;