on xenial help sign in
Document and limit what you can do with subtitleLabelCode substitutions
619df75Albert Astals
plugins/Dash/CardCreator.js+9−7
@@ -204,10 +204,12 @@ var titleLabelCode = 'Label { \n\
204 horizontalAlignment: root.headerAlignment; \n\
204 horizontalAlignment: root.headerAlignment; \n\
205 }\n';
205 }\n';
206
206
207+// %1 is used as anchors of subtitleLabel
208+// %2 is used as color of subtitleLabel
207var subtitleLabelCode = 'Label { \n\
209var subtitleLabelCode = 'Label { \n\
208 id: subtitleLabel; \n\
210 id: subtitleLabel; \n\
209 objectName: "subtitleLabel"; \n\
211 objectName: "subtitleLabel"; \n\
210− %1 \n\
212+ anchors { %1 } \n\
211 elide: Text.ElideRight; \n\
213 elide: Text.ElideRight; \n\
212 fontSize: "small"; \n\
214 fontSize: "small"; \n\
213 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
215 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
@@ -381,7 +383,7 @@ function cardString(template, components) {
381 if (hasMascot && hasSubtitle) {
383 if (hasMascot && hasSubtitle) {
382 // Using row + column
384 // Using row + column
383 titleAnchors = 'anchors { left: parent.left; right: parent.right }\n';
385 titleAnchors = 'anchors { left: parent.left; right: parent.right }\n';
384− subtitleAnchors = titleAnchors;
386+ subtitleAnchors = 'left: parent.left; right: parent.right';
385 } else if (hasMascot) {
387 } else if (hasMascot) {
386 // Using row + label
388 // Using row + label
387 titleAnchors = 'anchors.verticalCenter: parent.verticalCenter;\n'
389 titleAnchors = 'anchors.verticalCenter: parent.verticalCenter;\n'
@@ -399,11 +401,11 @@ function cardString(template, components) {
399 titleAnchors += headerLeftAnchor;
401 titleAnchors += headerLeftAnchor;
400 titleAnchors += headerVerticalAnchors;
402 titleAnchors += headerVerticalAnchors;
401 }
403 }
402− subtitleAnchors = 'anchors.left: titleLabel.left; \n\
404+ subtitleAnchors = 'left: titleLabel.left; \n\
403− anchors.leftMargin: titleLabel.leftMargin; \n\
405+ leftMargin: titleLabel.leftMargin; \n\
404− anchors.right: titleLabel.right; \n\
406+ right: titleLabel.right; \n\
405− anchors.top: titleLabel.bottom; \n\
407+ top: titleLabel.bottom; \n\
406− anchors.topMargin: units.dp(2);\n';
408+ topMargin: units.dp(2);\n';
407 }
409 }
408
410
409 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
411 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
tests/plugins/Dash/cardcreator/3.res+5−6
@@ -78,12 +78,11 @@ anchors.top: artShapeHolder.bottom;
78Label {
78Label {
79 id: subtitleLabel;
79 id: subtitleLabel;
80 objectName: "subtitleLabel";
80 objectName: "subtitleLabel";
81− anchors.left: titleLabel.left;
81+ anchors { left: titleLabel.left;
82− anchors.leftMargin: titleLabel.leftMargin;
82+ leftMargin: titleLabel.leftMargin;
83− anchors.right: titleLabel.right;
83+ right: titleLabel.right;
84− anchors.top: titleLabel.bottom;
84+ top: titleLabel.bottom;
85− anchors.topMargin: units.dp(2);
85+ topMargin: units.dp(2); }
86−
87 elide: Text.ElideRight;
86 elide: Text.ElideRight;
88 fontSize: "small";
87 fontSize: "small";
89 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
88 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
tests/plugins/Dash/cardcreator/5.res+5−5
@@ -121,11 +121,11 @@ Label {
121Label {
121Label {
122 id: subtitleLabel;
122 id: subtitleLabel;
123 objectName: "subtitleLabel";
123 objectName: "subtitleLabel";
124− anchors.left: titleLabel.left;
124+ anchors { left: titleLabel.left;
125− anchors.leftMargin: titleLabel.leftMargin;
125+ leftMargin: titleLabel.leftMargin;
126− anchors.right: titleLabel.right;
126+ right: titleLabel.right;
127− anchors.top: titleLabel.bottom;
127+ top: titleLabel.bottom;
128− anchors.topMargin: units.dp(2);
128+ topMargin: units.dp(2); }
129
129
130 elide: Text.ElideRight;
130 elide: Text.ElideRight;
131 fontSize: "small";
131 fontSize: "small";