on xenial help sign in
Document and narrow what you can do with the arg replacement in headerColumnCode
172c898Albert Astals
plugins/Dash/CardCreator.js+12−5
@@ -149,11 +149,16 @@ var headerRowCode = 'Row { \n\
149 %3 \n\
149 %3 \n\
150 }\n';
150 }\n';
151
151
152+// %1 is used as first child of the column
153+// %2 is used as second child of the column
152var headerColumnCode = 'Column { \n\
154var headerColumnCode = 'Column { \n\
153 anchors.verticalCenter: parent.verticalCenter; \n\
155 anchors.verticalCenter: parent.verticalCenter; \n\
154 spacing: units.dp(2); \n\
156 spacing: units.dp(2); \n\
155 width: parent.width - x;\n\
157 width: parent.width - x;\n\
158+ data: [ %1\n\
159+ ,\n\
160+ %2 \n\
156− %1 \n\
161+ ] \n\
157 }\n';
162 }\n';
158
163
159var mascotShapeLoaderCode = 'Loader { \n\
164var mascotShapeLoaderCode = 'Loader { \n\
@@ -402,15 +407,17 @@ function cardString(template, components) {
402 }
407 }
403
408
404 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
409 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
405− titleSubtitleCode += titleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
410+ var titleCode = titleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
406−
411+ var subtitleCode = "";
407 if (hasSubtitle) {
412 if (hasSubtitle) {
408− titleSubtitleCode += subtitleLabelCode.arg(subtitleAnchors).arg(color);
413+ subtitleCode += subtitleLabelCode.arg(subtitleAnchors).arg(color);
409 }
414 }
410
415
411 if (hasMascot && hasSubtitle) {
416 if (hasMascot && hasSubtitle) {
412 // If using row + column wrap the code in the column
417 // 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;
414 }
421 }
415 }
422 }
416
423
tests/plugins/Dash/cardcreator/2.res+3
@@ -76,6 +76,7 @@ Column {
76 anchors.verticalCenter: parent.verticalCenter;
76 anchors.verticalCenter: parent.verticalCenter;
77 spacing: units.dp(2);
77 spacing: units.dp(2);
78 width: parent.width - x;
78 width: parent.width - x;
79+ data: [
79Label {
80Label {
80 id: titleLabel;
81 id: titleLabel;
81 objectName: "titleLabel";
82 objectName: "titleLabel";
@@ -92,6 +93,7 @@ Label {
92 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
93 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
93 horizontalAlignment: root.headerAlignment;
94 horizontalAlignment: root.headerAlignment;
94 }
95 }
96+,
95Label {
97Label {
96 id: subtitleLabel;
98 id: subtitleLabel;
97 objectName: "subtitleLabel";
99 objectName: "subtitleLabel";
@@ -106,6 +108,7 @@ Label {
106 font.weight: Font.Light;
108 font.weight: Font.Light;
107 horizontalAlignment: root.headerAlignment;
109 horizontalAlignment: root.headerAlignment;
108 }
110 }
111+]
109}
112}
110}
113}
111implicitHeight: row.y + row.height + units.gu(1);
114implicitHeight: row.y + row.height + units.gu(1);
tests/plugins/Dash/cardcreator/4.res+3
@@ -54,6 +54,7 @@ Column {
54 anchors.verticalCenter: parent.verticalCenter;
54 anchors.verticalCenter: parent.verticalCenter;
55 spacing: units.dp(2);
55 spacing: units.dp(2);
56 width: parent.width - x;
56 width: parent.width - x;
57+data: [
57Label {
58Label {
58 id: titleLabel;
59 id: titleLabel;
59 objectName: "titleLabel";
60 objectName: "titleLabel";
@@ -70,6 +71,7 @@ Label {
70 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
71 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
71 horizontalAlignment: root.headerAlignment;
72 horizontalAlignment: root.headerAlignment;
72 }
73 }
74+,
73Label {
75Label {
74 id: subtitleLabel;
76 id: subtitleLabel;
75 objectName: "subtitleLabel";
77 objectName: "subtitleLabel";
@@ -84,6 +86,7 @@ Label {
84 font.weight: Font.Light;
86 font.weight: Font.Light;
85 horizontalAlignment: root.headerAlignment;
87 horizontalAlignment: root.headerAlignment;
86 }
88 }
89+]
87}
90}
88}
91}
89implicitHeight: row.y + row.height + units.gu(1);
92implicitHeight: row.y + row.height + units.gu(1);