@@ -16,7 +16,7 @@
17.pragma library
17.pragma library
19−var backgroundLoaderCode = 'Loader {\n\
19+var kBackgroundLoaderCode = 'Loader {\n\
20 id: backgroundLoader; \n\
20 id: backgroundLoader; \n\
21 objectName: "backgroundLoader"; \n\
21 objectName: "backgroundLoader"; \n\
22 anchors.fill: parent; \n\
22 anchors.fill: parent; \n\
@@ -53,7 +53,7 @@ var backgroundLoaderCode = 'Loader {\n\
53// %1 is used as anchors of artShapeHolder
53// %1 is used as anchors of artShapeHolder
54// %2 is used as image width
54// %2 is used as image width
55// %3 is used as image height
55// %3 is used as image height
56−var artShapeHolderCode = 'Item { \n\
56+var kArtShapeHolderCode = 'Item { \n\
57 id: artShapeHolder; \n\
57 id: artShapeHolder; \n\
58 height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
58 height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
59 width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
59 width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
@@ -96,7 +96,7 @@ var artShapeHolderCode = 'Item { \n\
99−var overlayLoaderCode = 'Loader { \n\
99+var kOverlayLoaderCode = 'Loader { \n\
100 id: overlayLoader; \n\
100 id: overlayLoader; \n\
101 anchors { \n\
101 anchors { \n\
102 left: artShapeHolder.left; \n\
102 left: artShapeHolder.left; \n\
@@ -137,21 +137,46 @@ var overlayLoaderCode = 'Loader { \n\
140−var headerRowCode = 'Row { \n\
140+// %1 is used as anchors of row
141+// %2 is used as first child of the row
142+// %3 is used as second child of the row
143+var kHeaderRow2Code = 'Row { \n\
141 id: row; \n\
144 id: row; \n\
142 objectName: "outerRow"; \n\
145 objectName: "outerRow"; \n\
143 property real margins: units.gu(1); \n\
146 property real margins: units.gu(1); \n\
144 spacing: margins; \n\
147 spacing: margins; \n\
145− %1 \n\
148+ anchors { %1 } \n\
147 anchors.right: parent.right; \n\
149 anchors.right: parent.right; \n\
148 anchors.margins: margins;\n\
150 anchors.margins: margins;\n\
157+// %1 is used as anchors of row
158+// %2 is used as first child of the row
159+// %3 is used as second child of the row
160+// %4 is used as third child of the row
161+var kHeaderRow3Code = 'Row { \n\
163+ objectName: "outerRow"; \n\
164+ property real margins: units.gu(1); \n\
165+ spacing: margins; \n\
167+ anchors.right: parent.right; \n\
168+ anchors.margins: margins;\n\
152// %1 is used as first child of the column
177// %1 is used as first child of the column
153// %2 is used as second child of the column
178// %2 is used as second child of the column
154−var headerColumnCode = 'Column { \n\
179+var kHeaderColumnCode = 'Column { \n\
155 anchors.verticalCenter: parent.verticalCenter; \n\
180 anchors.verticalCenter: parent.verticalCenter; \n\
156 spacing: units.dp(2); \n\
181 spacing: units.dp(2); \n\
157 width: parent.width - x;\n\
182 width: parent.width - x;\n\
@@ -161,7 +186,8 @@ var headerColumnCode = 'Column { \n\
164−var mascotShapeLoaderCode = 'Loader { \n\
189+// %1 is used as anchors of mascotShapeLoader
190+var kMascotShapeLoaderCode = 'Loader { \n\
165 id: mascotShapeLoader; \n\
191 id: mascotShapeLoader; \n\
166 objectName: "mascotShapeLoader"; \n\
192 objectName: "mascotShapeLoader"; \n\
167 asynchronous: root.asynchronous; \n\
193 asynchronous: root.asynchronous; \n\
@@ -170,13 +196,15 @@ var mascotShapeLoaderCode = 'Loader { \n\
170 width: units.gu(6); \n\
196 width: units.gu(6); \n\
171 height: units.gu(5.625); \n\
197 height: units.gu(5.625); \n\
172 sourceComponent: UbuntuShape { image: mascotImage } \n\
198 sourceComponent: UbuntuShape { image: mascotImage } \n\
173− %1 \n\
199+ anchors { %1 } \n\
176−var mascotImageCode = 'Image { \n\
202+// %1 is used as anchors of mascotImage
203+// %2 is used as visible of mascotImage
204+var kMascotImageCode = 'Image { \n\
177 id: mascotImage; \n\
205 id: mascotImage; \n\
178 objectName: "mascotImage"; \n\
206 objectName: "mascotImage"; \n\
179− %1 \n\
207+ anchors { %1 } \n\
180 readonly property int maxSize: Math.max(width, height) * 4; \n\
208 readonly property int maxSize: Math.max(width, height) * 4; \n\
181 source: cardData && cardData["mascot"]; \n\
209 source: cardData && cardData["mascot"]; \n\
182 width: units.gu(6); \n\
210 width: units.gu(6); \n\
@@ -188,10 +216,13 @@ var mascotImageCode = 'Image { \n\
188 visible: %2; \n\
216 visible: %2; \n\
191−var titleLabelCode = 'Label { \n\
219+// %1 is used as anchors of titleLabel
220+// %1 is used as color of titleLabel
221+// %3 is used as extra condition for visible of titleLabel
222+var kTitleLabelCode = 'Label { \n\
192 id: titleLabel; \n\
223 id: titleLabel; \n\
193 objectName: "titleLabel"; \n\
224 objectName: "titleLabel"; \n\
194− %1 \n\
225+ anchors { %1 } \n\
195 elide: Text.ElideRight; \n\
226 elide: Text.ElideRight; \n\
196 fontSize: "small"; \n\
227 fontSize: "small"; \n\
197 wrapMode: Text.Wrap; \n\
228 wrapMode: Text.Wrap; \n\
@@ -206,7 +237,7 @@ var titleLabelCode = 'Label { \n\
207// %1 is used as anchors of subtitleLabel
238// %1 is used as anchors of subtitleLabel
208// %2 is used as color of subtitleLabel
239// %2 is used as color of subtitleLabel
209−var subtitleLabelCode = 'Label { \n\
240+var kSubtitleLabelCode = 'Label { \n\
210 id: subtitleLabel; \n\
241 id: subtitleLabel; \n\
211 objectName: "subtitleLabel"; \n\
242 objectName: "subtitleLabel"; \n\
212 anchors { %1 } \n\
243 anchors { %1 } \n\
@@ -223,7 +254,7 @@ var subtitleLabelCode = 'Label { \n\
223// %1 is used as top anchor of summary
254// %1 is used as top anchor of summary
224// %2 is used as topMargin anchor of summary
255// %2 is used as topMargin anchor of summary
225// %3 is used as color of summary
256// %3 is used as color of summary
226−var summaryLabelCode = 'Label { \n\
257+var kSummaryLabelCode = 'Label { \n\
227 id: summary; \n\
258 id: summary; \n\
228 objectName: "summaryLabel"; \n\
259 objectName: "summaryLabel"; \n\
229 anchors { \n\
260 anchors { \n\
@@ -270,7 +301,7 @@ function cardString(template, components) {
270 var hasHeaderRow = hasMascot && hasTitle;
301 var hasHeaderRow = hasMascot && hasTitle;
272 if (hasBackground) {
303 if (hasBackground) {
273− code += backgroundLoaderCode;
304+ code += kBackgroundLoaderCode;
276 if (hasArt) {
307 if (hasArt) {
@@ -295,41 +326,41 @@ function cardString(template, components) {
295 heightCode = 'width / artShape.aspect';
326 heightCode = 'width / artShape.aspect';
298− code += artShapeHolderCode.arg(anchors).arg(widthCode).arg(heightCode);
329+ code += kArtShapeHolderCode.arg(anchors).arg(widthCode).arg(heightCode);
300 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
331 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
303 if (headerAsOverlay) {
334 if (headerAsOverlay) {
304− code += overlayLoaderCode;
335+ code += kOverlayLoaderCode;
307 var headerVerticalAnchors;
338 var headerVerticalAnchors;
308 if (headerAsOverlay) {
339 if (headerAsOverlay) {
309− headerVerticalAnchors = 'anchors.bottom: artShapeHolder.bottom; \n\
340+ headerVerticalAnchors = 'bottom: artShapeHolder.bottom; \n\
310− anchors.bottomMargin: units.gu(1);\n';
341+ bottomMargin: units.gu(1);\n';
312 if (hasArt) {
343 if (hasArt) {
313 if (isHorizontal) {
344 if (isHorizontal) {
314− headerVerticalAnchors = 'anchors.top: artShapeHolder.top; \n\
345+ headerVerticalAnchors = 'top: artShapeHolder.top; \n\
315− anchors.topMargin: units.gu(1);\n';
346+ topMargin: units.gu(1);\n';
317− headerVerticalAnchors = 'anchors.top: artShapeHolder.bottom; \n\
348+ headerVerticalAnchors = 'top: artShapeHolder.bottom; \n\
318− anchors.topMargin: units.gu(1);\n';
349+ topMargin: units.gu(1);\n';
321− headerVerticalAnchors = 'anchors.top: parent.top; \n\
352+ headerVerticalAnchors = 'top: parent.top; \n\
322− anchors.topMargin: units.gu(1);\n';
353+ topMargin: units.gu(1);\n';
325 var headerLeftAnchor;
356 var headerLeftAnchor;
326 var headerLeftAnchorHasMagin = false;
357 var headerLeftAnchorHasMagin = false;
327 if (isHorizontal && hasArt) {
358 if (isHorizontal && hasArt) {
328− headerLeftAnchor = 'anchors.left: artShapeHolder.right; \n\
359+ headerLeftAnchor = 'left: artShapeHolder.right; \n\
329− anchors.leftMargin: units.gu(1);\n';
360+ leftMargin: units.gu(1);\n';
330 headerLeftAnchorHasMagin = true;
361 headerLeftAnchorHasMagin = true;
332− headerLeftAnchor = 'anchors.left: parent.left;\n';
363+ headerLeftAnchor = 'left: parent.left;\n';
335 if (hasHeaderRow) {
366 if (hasHeaderRow) {
@@ -344,6 +375,7 @@ function cardString(template, components) {
344 code += 'readonly property int headerHeight: 0;\n'
375 code += 'readonly property int headerHeight: 0;\n'
378+ var mascotShapeCode = "";
347 var mascotCode = "";
379 var mascotCode = "";
348 if (hasMascot) {
380 if (hasMascot) {
349 var useMascotShape = !hasBackground && !headerAsOverlay;
381 var useMascotShape = !hasBackground && !headerAsOverlay;
@@ -352,18 +384,18 @@ function cardString(template, components) {
352 anchors += headerLeftAnchor;
384 anchors += headerLeftAnchor;
353 anchors += headerVerticalAnchors;
385 anchors += headerVerticalAnchors;
354 if (!headerLeftAnchorHasMagin) {
386 if (!headerLeftAnchorHasMagin) {
355− anchors += 'anchors.leftMargin: units.gu(1);\n'
387+ anchors += 'leftMargin: units.gu(1);\n'
358− anchors = "anchors.verticalCenter: parent.verticalCenter;"
390+ anchors = "verticalCenter: parent.verticalCenter;"
361 if (useMascotShape) {
393 if (useMascotShape) {
362− mascotCode += mascotShapeLoaderCode.arg(anchors);
394+ mascotShapeCode = kMascotShapeLoaderCode.arg(anchors);
365 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
397 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
366− mascotCode += mascotImageCode.arg(anchors).arg(mascotImageVisible);
398+ mascotCode = kMascotImageCode.arg(anchors).arg(mascotImageVisible);
369 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"';
401 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"';
@@ -385,22 +417,22 @@ function cardString(template, components) {
385 var subtitleAnchors;
417 var subtitleAnchors;
386 if (hasMascot && hasSubtitle) {
418 if (hasMascot && hasSubtitle) {
387 // Using row + column
419 // Using row + column
388− titleAnchors = 'anchors { left: parent.left; right: parent.right }\n';
420+ titleAnchors = 'left: parent.left; right: parent.right';
389− subtitleAnchors = 'left: parent.left; right: parent.right';
421+ subtitleAnchors = titleAnchors;
390 } else if (hasMascot) {
422 } else if (hasMascot) {
391 // Using row + label
423 // Using row + label
392− titleAnchors = 'anchors.verticalCenter: parent.verticalCenter;\n'
424+ titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
394 if (headerAsOverlay) {
426 if (headerAsOverlay) {
395 // Using anchors to the overlay
427 // Using anchors to the overlay
396− titleAnchors = 'anchors.left: parent.left; \n\
428+ titleAnchors = 'left: parent.left; \n\
397− anchors.leftMargin: units.gu(1); \n\
429+ leftMargin: units.gu(1); \n\
398− anchors.right: parent.right; \n\
430+ right: parent.right; \n\
399− anchors.top: overlayLoader.top; \n\
431+ top: overlayLoader.top; \n\
400− anchors.topMargin: units.gu(1);\n';
432+ topMargin: units.gu(1);\n';
402 // Using anchors to the mascot/parent
434 // Using anchors to the mascot/parent
403− titleAnchors = "anchors.right: parent.right;";
435+ titleAnchors = "right: parent.right;";
404 titleAnchors += headerLeftAnchor;
436 titleAnchors += headerLeftAnchor;
405 titleAnchors += headerVerticalAnchors;
437 titleAnchors += headerVerticalAnchors;
@@ -412,24 +444,28 @@ function cardString(template, components) {
414 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
446 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
415− var titleCode = titleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
447+ var titleCode = kTitleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
416 var subtitleCode = "";
448 var subtitleCode = "";
417 if (hasSubtitle) {
449 if (hasSubtitle) {
418− subtitleCode += subtitleLabelCode.arg(subtitleAnchors).arg(color);
450+ subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
421 if (hasMascot && hasSubtitle) {
453 if (hasMascot && hasSubtitle) {
422 // If using row + column wrap the code in the column
454 // If using row + column wrap the code in the column
423− titleSubtitleCode = headerColumnCode.arg(titleCode).arg(subtitleCode);
455+ titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
425 titleSubtitleCode = titleCode + subtitleCode;
457 titleSubtitleCode = titleCode + subtitleCode;
429 if (hasHeaderRow) {
461 if (hasHeaderRow) {
462+ if (mascotShapeCode != "") {
430− code += headerRowCode.arg(headerVerticalAnchors).arg(headerLeftAnchor).arg(mascotCode + titleSubtitleCode);
463+ code += kHeaderRow3Code.arg(headerVerticalAnchors + headerLeftAnchor).arg(mascotShapeCode).arg(mascotCode).arg(titleSubtitleCode);
465+ code += kHeaderRow2Code.arg(headerVerticalAnchors + headerLeftAnchor).arg(mascotCode).arg(titleSubtitleCode);
432− code += mascotCode + titleSubtitleCode;
468+ code += mascotShapeCode + mascotCode + titleSubtitleCode;
435 if (hasSummary) {
471 if (hasSummary) {
@@ -452,7 +488,7 @@ function cardString(template, components) {
453 var summaryTopMargin = (hasMascot || hasSubtitle ? 'anchors.margins' : '0');
489 var summaryTopMargin = (hasMascot || hasSubtitle ? 'anchors.margins' : '0');
455− code += summaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
491+ code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
458 if (hasSummary) {
494 if (hasSummary) {