@@ -108,6 +108,7 @@ var kOverlayLoaderCode = 'Loader { \n\
108108 sourceComponent: ShaderEffect { \n\
109109 id: overlay; \n\
110110 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
111+ property real luminance: 0.2126 * overlayColor.r + 0.7152 * overlayColor.g + 0.0722 * overlayColor.b; \n\
111112 property color overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
112113 property var source: ShaderEffectSource { \n\
113114 id: shaderSource; \n\
@@ -137,10 +138,9 @@ var kOverlayLoaderCode = 'Loader { \n\
137138 } \n\
138139 }\n';
139140
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+// multiple row version of HeaderRowCode
142+function kHeaderRowCodeGenerator() {
143+var kHeaderRowCodeTemplate = 'Row { \n\
144144 id: row; \n\
145145 objectName: "outerRow"; \n\
146146 property real margins: units.gu(1); \n\
@@ -148,58 +148,30 @@ var kHeaderRow2Code = 'Row { \n\
148148 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
149149 anchors { %1 } \n\
150150 anchors.right: parent.right; \n\
151− anchors.margins: margins;\n\
152− data: [ %2\n\
153− ,\n\
154− %3 \n\
151+ anchors.margins: margins; \n\
152+ anchors.rightMargin: 0; \n\
153+ data: [ \n\
154+ %2 \n\
155155 ] \n\
156156 }\n';
157+ var args = Array.prototype.slice.call(arguments);
158+ var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(',\n'));
159+ return code;
160+}
157161
158−// %1 is used as anchors of row
159−// %2 is used as first child of the row
160−// %3 is used as second child of the row
161−// %4 is used as third child of the row
162−var kHeaderRow3Code = 'Row { \n\
163− id: row; \n\
164− objectName: "outerRow"; \n\
165− property real margins: units.gu(1); \n\
166− spacing: margins; \n\
167− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
168− anchors { %1 } \n\
169− anchors.right: parent.right; \n\
170− anchors.margins: margins;\n\
171− data: [ %2\n\
172− ,\n\
162+// multiple item version of kHeaderContainerCode
163+function kHeaderContainerCodeGenerator() {
164+ var headerContainerCodeTemplate = 'Item { \n\
165+ id: headerTitleContainer; \n\
166+ anchors { %1 } \n\
167+ width: parent.width - x; \n\
168+ implicitHeight: %2; \n\
169+ data: [ \n\
173170 %3 \n\
174− ,\n\
175− %4 \n\
176− ] \n\
177− }\n';
178−
179−// %1 is used as first child of the column
180−// %2 is used as second child of the column
181−var kHeaderColumnCode = 'Column { \n\
182− anchors.verticalCenter: parent.verticalCenter; \n\
183− spacing: units.dp(2); \n\
184− width: parent.width - x;\n\
185− data: [ %1\n\
186− ,\n\
187− %2 \n\
188− ] \n\
171+ ]\n\
189172 }\n';
190−
191−// multiple column version of kHeaderColumnCode.
192−function kHeaderColumnCodeGenerator() {
193− var headerColumnCodeTemplate = 'Column { \n\
194− anchors.verticalCenter: parent.verticalCenter; \n\
195− spacing: units.dp(2); \n\
196− width: parent.width - x;\n\
197− data: [ \n\
198− %1 \n\
199− ]\n\
200− }\n';
201173 var args = Array.prototype.slice.call(arguments);
202− var code = headerColumnCodeTemplate.arg(args.join(',\n'));
174+ var code = headerContainerCodeTemplate.arg(args.shift()).arg(args.shift()).arg(args.join(',\n'));
203175 return code;
204176}
205177
@@ -223,7 +195,7 @@ var kMascotImageCode = 'Image { \n\
223195 objectName: "mascotImage"; \n\
224196 anchors { %1 } \n\
225197 readonly property int maxSize: Math.max(width, height) * 4; \n\
226− source: cardData && cardData["mascot"]; \n\
198+ source: cardData && cardData["mascot"] || ""; \n\
227199 width: units.gu(6); \n\
228200 height: units.gu(5.625); \n\
229201 sourceSize { width: maxSize; height: maxSize } \n\
@@ -252,6 +224,22 @@ var kTitleLabelCode = 'Label { \n\
252224 horizontalAlignment: root.headerAlignment; \n\
253225 }\n';
254226
227+// %1 is used as extra anchors of emblemIcon
228+// %2 is used as color of emblemIcon
229+var kEmblemIconCode = 'Icon { \n\
230+ id: emblemIcon; \n\
231+ objectName: "emblemIcon"; \n\
232+ anchors { \n\
233+ bottom: titleLabel.baseline; \n\
234+ right: parent.right; \n\
235+ %1
236+ } \n\
237+ source: cardData && cardData["emblem"] || ""; \n\
238+ color: %2; \n\
239+ width: height; \n\
240+ height: source != "" ? titleLabel.font.pixelSize : 0; \n\
241+ }\n';
242+
255243// %1 is used as anchors of touchdown effect
256244var kTouchdownCode = 'UbuntuShape { \n\
257245 id: touchdown; \n\
@@ -268,6 +256,7 @@ var kSubtitleLabelCode = 'Label { \n\
268256 id: subtitleLabel; \n\
269257 objectName: "subtitleLabel"; \n\
270258 anchors { %1 } \n\
259+ anchors.topMargin: units.dp(2); \n\
271260 elide: Text.ElideRight; \n\
272261 fontSize: "small"; \n\
273262 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
@@ -279,12 +268,13 @@ var kSubtitleLabelCode = 'Label { \n\
279268 }\n';
280269
281270// %1 is used as anchors of attributesRow
271+// %2 is used as color of attributesRow
282272var kAttributesRowCode = 'CardAttributes { \n\
283273 id: attributesRow; \n\
284274 objectName: "attributesRow"; \n\
285275 anchors { %1 } \n\
286276 color: %2; \n\
287− model: cardData["attributes"]; \n\
277+ model: cardData && cardData["attributes"]; \n\
288278 }\n';
289279
290280// %1 is used as top anchor of summary
@@ -334,10 +324,11 @@ function cardString(template, components) {
334324 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);
335325 var hasTitle = components["title"] || false;
336326 var hasMascot = components["mascot"] || false;
327+ var hasEmblem = components["emblem"] && !(hasMascot && template["card-size"] === "small") || false;
337328 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
338329 var hasSubtitle = hasTitle && components["subtitle"] || false;
339330 var hasHeaderRow = hasMascot && hasTitle;
340− var hasAttributes = hasTitle && components["attributes"] || false;
331+ var hasAttributes = hasTitle && components["attributes"]["field"] || false;
341332
342333 if (hasBackground) {
343334 code += kBackgroundLoaderCode;
@@ -348,9 +339,9 @@ function cardString(template, components) {
348339 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
349340
350341 var widthCode, heightCode;
351− var anchors;
342+ var artAnchors;
352343 if (isHorizontal) {
353− anchors = 'left: parent.left';
344+ artAnchors = 'left: parent.left';
354345 if (hasMascot || hasTitle) {
355346 widthCode = 'height * artShape.aspect'
356347 heightCode = 'headerHeight + 2 * units.gu(1)';
@@ -361,12 +352,12 @@ function cardString(template, components) {
361352 heightCode = 'units.gu(7.625)';
362353 }
363354 } else {
364− anchors = 'horizontalCenter: parent.horizontalCenter;';
355+ artAnchors = 'horizontalCenter: parent.horizontalCenter;';
365356 widthCode = 'root.width'
366357 heightCode = 'width / artShape.aspect';
367358 }
368359
369− code += kArtShapeHolderCode.arg(anchors).arg(widthCode).arg(heightCode);
360+ code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
370361 } else {
371362 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
372363 }
@@ -403,6 +394,8 @@ function cardString(template, components) {
403394 headerLeftAnchor = 'left: parent.left;\n';
404395 }
405396
397+ var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary;
398+
406399 if (hasHeaderRow) {
407400 code += 'readonly property int headerHeight: row.height;\n'
408401 } else if (hasMascot) {
@@ -423,194 +416,256 @@ function cardString(template, components) {
423416 code += 'readonly property int headerHeight: 0;\n'
424417 }
425418
426− var mascotShapeCode = "";
427− var mascotCode = "";
419+ var mascotShapeCode = '';
420+ var mascotCode = '';
428421 if (hasMascot) {
429422 var useMascotShape = !hasBackground && !headerAsOverlay;
430− var anchors = "";
423+ var mascotAnchors = '';
431424 if (!hasHeaderRow) {
432− anchors += headerLeftAnchor;
433− anchors += headerVerticalAnchors;
425+ mascotAnchors += headerLeftAnchor;
426+ mascotAnchors += headerVerticalAnchors;
434427 if (!headerLeftAnchorHasMargin) {
435− anchors += 'leftMargin: units.gu(1);\n'
428+ mascotAnchors += 'leftMargin: units.gu(1);\n'
436429 }
437430 } else {
438− anchors = "verticalCenter: parent.verticalCenter;"
431+ mascotAnchors = 'verticalCenter: parent.verticalCenter;'
439432 }
440433
441434 if (useMascotShape) {
442− mascotShapeCode = kMascotShapeLoaderCode.arg(anchors);
435+ mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors);
443436 }
444437
445438 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
446− mascotCode = kMascotImageCode.arg(anchors).arg(mascotImageVisible);
439+ mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
447440 }
448441
449− var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey")';
442+ var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText)';
450443
451− var titleSubtitleCode = "";
444+ var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
445+ var titleSubtitleCode = '';
452446 if (hasTitle) {
453− var color;
447+ var titleColor;
454448 if (headerAsOverlay) {
455− color = '"white"';
449+ titleColor = 'overlayLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText)';
456450 } else if (hasSummary) {
457− color = 'summary.color';
451+ titleColor = 'summary.color';
458452 } else if (hasBackground) {
459− color = summaryColorWithBackground;
453+ titleColor = summaryColorWithBackground;
460454 } else {
461− color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
455+ titleColor = 'root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText';
462456 }
463457
464458 var titleAnchors;
465459 var subtitleAnchors;
466460 var attributesAnchors;
467− if (hasMascot && (hasSubtitle || hasAttributes)) {
468− // Using row + column
469− titleAnchors = 'left: parent.left; right: parent.right';
470− subtitleAnchors = titleAnchors;
471− attributesAnchors = subtitleAnchors;
461+ var titleContainerAnchors;
462+ var titleRightAnchor;
463+
464+ var extraRightAnchor = '';
465+ var extraLeftAnchor = '';
466+ if (!touchdownOnArtShape) {
467+ extraRightAnchor = 'rightMargin: units.gu(1); \n';
468+ extraLeftAnchor = 'leftMargin: units.gu(1); \n';
469+ }
470+
471+ if (hasMascot) {
472+ titleContainerAnchors = 'verticalCenter: parent.verticalCenter; ';
473+ } else {
474+ titleContainerAnchors = 'right: parent.right; ';
475+ titleContainerAnchors += headerLeftAnchor;
476+ titleContainerAnchors += headerVerticalAnchors;
477+ if (!headerLeftAnchorHasMargin) {
478+ titleContainerAnchors += extraLeftAnchor;
479+ }
480+ }
481+ if (hasEmblem) {
482+ titleRightAnchor = 'right: emblemIcon.left; \n\
483+ rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
484+ } else {
485+ titleRightAnchor = 'right: parent.right; \n'
486+ titleRightAnchor += extraRightAnchor;
487+ }
488+
489+ if (hasTitleContainer) {
490+ // Using headerTitleContainer
491+ titleAnchors = titleRightAnchor;
492+ titleAnchors += 'left: parent.left; \n\
493+ top: parent.top;';
494+ subtitleAnchors = 'right: parent.right; \n\
495+ left: parent.left; \n';
496+ subtitleAnchors += extraRightAnchor;
497+ if (hasSubtitle) {
498+ attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
499+ subtitleAnchors += 'top: titleLabel.bottom;\n';
500+ } else {
501+ attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
502+ }
472503 } else if (hasMascot) {
473− // Using row + label
474− titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
504+ // Using row + titleContainer
505+ titleAnchors = 'verticalCenter: parent.verticalCenter;\n';
475506 } else {
476507 if (headerAsOverlay) {
477508 // Using anchors to the overlay
478− titleAnchors = 'left: parent.left; \n\
479− leftMargin: units.gu(1); \n\
480− right: parent.right; \n\
481− rightMargin: units.gu(1); \n\
482− top: overlayLoader.top; \n\
483− topMargin: units.gu(1);\n';
509+ titleAnchors = titleRightAnchor;
510+ titleAnchors += 'left: parent.left; \n\
511+ leftMargin: units.gu(1); \n\
512+ top: overlayLoader.top; \n\
513+ topMargin: units.gu(1);\n';
484514 } else {
485515 // Using anchors to the mascot/parent
486− titleAnchors = "right: parent.right;\n";
487− titleAnchors += "rightMargin: units.gu(1);\n";
516+ titleAnchors = titleRightAnchor;
488517 titleAnchors += headerLeftAnchor;
489518 titleAnchors += headerVerticalAnchors;
490519 if (!headerLeftAnchorHasMargin) {
491− titleAnchors += 'leftMargin: units.gu(1);\n'
520+ titleAnchors += extraLeftAnchor;
492521 }
493522 }
494523 subtitleAnchors = 'left: titleLabel.left; \n\
495− leftMargin: titleLabel.leftMargin; \n\
496− right: titleLabel.right; \n\
497− rightMargin: titleLabel.rightMargin; \n\
498− top: titleLabel.bottom; \n\
499− topMargin: units.dp(2);\n';
524+ leftMargin: titleLabel.leftMargin; \n';
525+ subtitleAnchors += extraRightAnchor;
526+ if (hasEmblem) {
527+ // using container
528+ subtitleAnchors += 'right: parent.right; \n';
529+ } else {
530+ subtitleAnchors += 'right: titleLabel.right; \n';
531+ }
532+
500533 if (hasSubtitle) {
501− attributesAnchors = 'left: subtitleLabel.left; \n\
502− leftMargin: subtitleLabel.leftMargin; \n\
503− right: subtitleLabel.right; \n\
504− rightMargin: subtitleLabel.rightMargin; \n\
505− top: subtitleLabel.bottom; \n\
506− topMargin: units.dp(2);\n';
534+ attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
535+ subtitleAnchors += 'top: titleLabel.bottom;\n';
507536 } else {
508− attributesAnchors = subtitleAnchors;
537+ attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
509538 }
510539 }
511540
541+ // code for different elements
512542 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
513− var titleCode = kTitleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
514− var subtitleCode = "";
543+ var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra);
544+ var subtitleCode;
545+ var attributesCode;
546+
547+ // code for the title container
548+ var containerCode = [];
549+ var containerHeight = 'titleLabel.height';
550+ containerCode.push(titleCode);
515551 if (hasSubtitle) {
516− subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
552+ subtitleCode = kSubtitleLabelCode.arg(subtitleAnchors).arg(titleColor);
553+ containerCode.push(subtitleCode);
554+ containerHeight += ' + subtitleLabel.height';
555+ }
556+ if (hasEmblem) {
557+ containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
558+ }
559+ if (hasAttributes) {
560+ attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
561+ containerCode.push(attributesCode);
562+ containerHeight += ' + attributesRow.height';
517563 }
518564
519− if (hasMascot && (hasSubtitle || hasAttributes)) {
520− // If using row + column wrap the code in the column
521− titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
522− if (hasSubtitle && hasAttributes) {
523− var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
524− titleSubtitleCode = kHeaderColumnCodeGenerator(titleCode, subtitleCode, attributesCode);
525− } else if (hasSubtitle) {
526− titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
527− } else if (hasAttributes) {
528− var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
529− titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(attributesCode);
530− }
565+ if (hasTitleContainer) {
566+ // use container
567+ titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
531568 } else {
569+ // no container
532570 titleSubtitleCode = titleCode;
533571 if (hasSubtitle) {
534− titleSubtitleCode = titleSubtitleCode + subtitleCode;
572+ titleSubtitleCode += subtitleCode;
535573 }
536574 if (hasAttributes) {
537− var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
538− titleSubtitleCode = titleSubtitleCode + attributesCode;
575+ titleSubtitleCode += attributesCode;
539576 }
540577 }
541578 }
542579
543580 if (hasHeaderRow) {
544− if (mascotShapeCode != "") {
545− code += kHeaderRow3Code.arg(headerVerticalAnchors + headerLeftAnchor).arg(mascotShapeCode).arg(mascotCode).arg(titleSubtitleCode);
546− } else {
547− code += kHeaderRow2Code.arg(headerVerticalAnchors + headerLeftAnchor).arg(mascotCode).arg(titleSubtitleCode);
581+ var rowCode = [mascotCode, titleSubtitleCode];
582+ if (mascotShapeCode != '') {
583+ rowCode.unshift(mascotShapeCode);
548584 }
585+ code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
549586 } else {
550587 code += mascotShapeCode + mascotCode + titleSubtitleCode;
551588 }
552589
553590 if (hasSummary) {
554591 var summaryTopAnchor;
555− if (isHorizontal && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
556− else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
557− else if (hasHeaderRow) summaryTopAnchor = "row.bottom";
558− else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";
559− else if (hasAttributes) summaryTopAnchor = "attributesRow.bottom";
560− else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";
561− else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";
562− else if (hasArt) summaryTopAnchor = "artShapeHolder.bottom";
563− else summaryTopAnchor = "parent.top";
564−
565− var color;
592+ if (isHorizontal && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
593+ else if (headerAsOverlay && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
594+ else if (hasHeaderRow) summaryTopAnchor = 'row.bottom';
595+ else if (hasTitleContainer) summaryTopAnchor = 'headerTitleContainer.bottom';
596+ else if (hasMascot) summaryTopAnchor = 'mascotImage.bottom';
597+ else if (hasAttributes) summaryTopAnchor = 'attributesRow.bottom';
598+ else if (hasSubtitle) summaryTopAnchor = 'subtitleLabel.bottom';
599+ else if (hasTitle) summaryTopAnchor = 'titleLabel.bottom';
600+ else if (hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
601+ else summaryTopAnchor = 'parent.top';
602+
603+ var summaryColor;
566604 if (hasBackground) {
567− color = summaryColorWithBackground;
605+ summaryColor = summaryColorWithBackground;
568606 } else {
569− color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
607+ summaryColor = 'root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText';
570608 }
571609
572610 var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ? 'anchors.margins' : '0');
573611
574− code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
612+ code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
575613 }
576614
577615 var touchdownAnchors;
578616 if (hasBackground) {
579617 touchdownAnchors = 'fill: backgroundLoader';
580− } else if (hasArt && !hasMascot && !hasSummary) {
618+ } else if (touchdownOnArtShape) {
581619 touchdownAnchors = 'fill: artShapeHolder';
582620 } else {
583621 touchdownAnchors = 'fill: root'
584622 }
585623 code += kTouchdownCode.arg(touchdownAnchors);
586624
625+ var implicitHeight = 'implicitHeight: ';
587626 if (hasSummary) {
588− code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
627+ implicitHeight += 'summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
589628 } else if (hasHeaderRow) {
590− code += 'implicitHeight: row.y + row.height + units.gu(1);\n';
629+ implicitHeight += 'row.y + row.height + units.gu(1);\n';
591630 } else if (hasMascot) {
592− code += 'implicitHeight: mascotImage.y + mascotImage.height;\n';
631+ implicitHeight += 'mascotImage.y + mascotImage.height;\n';
632+ } else if (hasTitleContainer) {
633+ implicitHeight += 'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
593634 } else if (hasAttributes) {
594− code += 'implicitHeight: attributesRow.y + attributesRow.height + units.gu(1);\n';
635+ implicitHeight += 'attributesRow.y + attributesRow.height + units.gu(1);\n';
595636 } else if (hasSubtitle) {
596− code += 'implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
637+ implicitHeight += 'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
597638 } else if (hasTitle) {
598− code += 'implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);\n';
639+ implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
599640 } else if (hasArt) {
600− code += 'implicitHeight: artShapeHolder.height;\n';
641+ implicitHeight += 'artShapeHolder.height;\n';
642+ } else {
643+ implicitHeight = '';
601644 }
645+
602646 // Close the AbstractButton
603− code += '}\n';
647+ code += implicitHeight + '}\n';
604648
605649 return code;
606650}
607651
608652function createCardComponent(parent, template, components) {
609653 var imports = 'import QtQuick 2.2; \n\
610− import Ubuntu.Components 0.1; \n\
654+ import Ubuntu.Components 1.1; \n\
611655 import Dash 0.1;\n';
612656 var card = cardString(template, components);
613657 var code = imports + 'Component {\n' + card + '}\n';
614658
615− return Qt.createQmlObject(code, parent, "createCardComponent");
659+ try {
660+ return Qt.createQmlObject(code, parent, "createCardComponent");
661+ } catch (e) {
662+ console.error("ERROR: Invalid component created.");
663+ console.error("Template:");
664+ console.error(JSON.stringify(template));
665+ console.error("Components:");
666+ console.error(JSON.stringify(components));
667+ console.error("Code:");
668+ console.error(code);
669+ throw e;
670+ }
616671}