on xenial help sign in
Document and narrow what you can do with the arg replacement in headerColumnCode
commit172c89838619008dfab5ff9face4400eeea98acb authorAlbert Astals <albert.astals@canonical.com> dateWed 7 May 2014, 14:55 (12 years ago) parent869d64b
3 files changed+18−5
plugins/Dash/CardCreator.js+12−5 tests/plugins/Dash/cardcreator/2.res+3 tests/plugins/Dash/cardcreator/4.res+3
plugins/Dash/CardCreator.js+12−5
@@ -149,11 +149,16 @@ var headerRowCode = 'Row { \n\
149149 %3 \n\
150150 }\n';
151151
152+// %1 is used as first child of the column
153+// %2 is used as second child of the column
152154var headerColumnCode = 'Column { \n\
153155 anchors.verticalCenter: parent.verticalCenter; \n\
154156 spacing: units.dp(2); \n\
155157 width: parent.width - x;\n\
156− %1 \n\
158+ data: [ %1\n\
159+ ,\n\
160+ %2 \n\
161+ ] \n\
157162 }\n';
158163
159164var mascotShapeLoaderCode = 'Loader { \n\
@@ -402,15 +407,17 @@ function cardString(template, components) {
402407 }
403408
404409 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
405− titleSubtitleCode += titleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
406−
410+ var titleCode = titleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
411+ var subtitleCode = "";
407412 if (hasSubtitle) {
408− titleSubtitleCode += subtitleLabelCode.arg(subtitleAnchors).arg(color);
413+ subtitleCode += subtitleLabelCode.arg(subtitleAnchors).arg(color);
409414 }
410415
411416 if (hasMascot && hasSubtitle) {
412417 // If using row + column wrap the code in the column
413− titleSubtitleCode = headerColumnCode.arg(titleSubtitleCode);
418+ titleSubtitleCode = headerColumnCode.arg(titleCode).arg(subtitleCode);
419+ } else {
420+ titleSubtitleCode = titleCode + subtitleCode;
414421 }
415422 }
416423
tests/plugins/Dash/cardcreator/2.res+3
@@ -76,6 +76,7 @@ Column {
7676 anchors.verticalCenter: parent.verticalCenter;
7777 spacing: units.dp(2);
7878 width: parent.width - x;
79+ data: [
7980Label {
8081 id: titleLabel;
8182 objectName: "titleLabel";
@@ -92,6 +93,7 @@ Label {
9293 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
9394 horizontalAlignment: root.headerAlignment;
9495 }
96+,
9597Label {
9698 id: subtitleLabel;
9799 objectName: "subtitleLabel";
@@ -106,6 +108,7 @@ Label {
106108 font.weight: Font.Light;
107109 horizontalAlignment: root.headerAlignment;
108110 }
111+]
109112}
110113}
111114implicitHeight: row.y + row.height + units.gu(1);
tests/plugins/Dash/cardcreator/4.res+3
@@ -54,6 +54,7 @@ Column {
5454 anchors.verticalCenter: parent.verticalCenter;
5555 spacing: units.dp(2);
5656 width: parent.width - x;
57+data: [
5758Label {
5859 id: titleLabel;
5960 objectName: "titleLabel";
@@ -70,6 +71,7 @@ Label {
7071 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
7172 horizontalAlignment: root.headerAlignment;
7273 }
74+,
7375Label {
7476 id: subtitleLabel;
7577 objectName: "subtitleLabel";
@@ -84,6 +86,7 @@ Label {
8486 font.weight: Font.Light;
8587 horizontalAlignment: root.headerAlignment;
8688 }
89+]
8790}
8891}
8992implicitHeight: row.y + row.height + units.gu(1);