@@ -71,19 +71,14 @@ var kArtShapeHolderCode = 'Item { \n\
71 visible: image.status == Image.Ready; \n\
71 visible: image.status == Image.Ready; \n\
72 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
72 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
73 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
73 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
74− readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \n\
75 Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
74 Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
76− onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); \n\
77 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
75 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
78 function updateWidthHeightBindings() { \n\
76 function updateWidthHeightBindings() { \n\
79 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
77 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
80 width = root.fixedArtShapeSize.width; \n\
78 width = root.fixedArtShapeSize.width; \n\
81 height = root.fixedArtShapeSize.height; \n\
79 height = root.fixedArtShapeSize.height; \n\
82− } else if (aspectSmallerThanImageAspect) { \n\
83− width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
84− height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect }); \n\
85 } else { \n\
80 } else { \n\
86− width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect }); \n\
81+ width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
87 height = Qt.binding(function() { return !visible ? 0 : image.height }); \n\
82 height = Qt.binding(function() { return !visible ? 0 : image.height }); \n\
@@ -92,8 +87,7 @@ var kArtShapeHolderCode = 'Item { \n\
92 source: cardData && cardData["art"] || ""; \n\
87 source: cardData && cardData["art"] || ""; \n\
93 cache: true; \n\
88 cache: true; \n\
94 asynchronous: root.asynchronous; \n\
89 asynchronous: root.asynchronous; \n\
95− fillMode: components && components["art"]["fill-mode"] === "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop; \n\
90+ fillMode: Image.PreserveAspectCrop; \n\
96− readonly property real aspect: implicitWidth / implicitHeight; \n\
97 width: %2; \n\
91 width: %2; \n\
98 height: %3; \n\
92 height: %3; \n\
@@ -114,7 +108,8 @@ var kOverlayLoaderCode = 'Loader { \n\
114 sourceComponent: ShaderEffect { \n\
108 sourceComponent: ShaderEffect { \n\
115 id: overlay; \n\
109 id: overlay; \n\
116 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
110 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
117− opacity: 0.6; \n\
111+ property real luminance: 0.2126 * overlayColor.r + 0.7152 * overlayColor.g + 0.0722 * overlayColor.b; \n\
112+ property color overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
118 property var source: ShaderEffectSource { \n\
113 property var source: ShaderEffectSource { \n\
119 id: shaderSource; \n\
114 id: shaderSource; \n\
120 sourceItem: artShapeLoader.item; \n\
115 sourceItem: artShapeLoader.item; \n\
@@ -135,17 +130,17 @@ var kOverlayLoaderCode = 'Loader { \n\
135 varying highp vec2 coord; \n\
130 varying highp vec2 coord; \n\
136 uniform sampler2D source; \n\
131 uniform sampler2D source; \n\
137 uniform lowp float qt_Opacity; \n\
132 uniform lowp float qt_Opacity; \n\
133+ uniform highp vec4 overlayColor; \n\
138 void main() { \n\
134 void main() { \n\
139 lowp vec4 tex = texture2D(source, coord); \n\
135 lowp vec4 tex = texture2D(source, coord); \n\
140− gl_FragColor = vec4(0, 0, 0, tex.a) * qt_Opacity; \n\
136+ gl_FragColor = vec4(overlayColor.r, overlayColor.g, overlayColor.b, 1) * qt_Opacity * overlayColor.a * tex.a; \n\
145−// %1 is used as anchors of row
141+// multiple row version of HeaderRowCode
146−// %2 is used as first child of the row
142+function kHeaderRowCodeGenerator() {
147−// %3 is used as second child of the row
143+var kHeaderRowCodeTemplate = 'Row { \n\
148−var kHeaderRow2Code = 'Row { \n\
149 id: row; \n\
144 id: row; \n\
150 objectName: "outerRow"; \n\
145 objectName: "outerRow"; \n\
151 property real margins: units.gu(1); \n\
146 property real margins: units.gu(1); \n\
@@ -153,45 +148,32 @@ var kHeaderRow2Code = 'Row { \n\
153 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
148 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
154 anchors { %1 } \n\
149 anchors { %1 } \n\
155 anchors.right: parent.right; \n\
150 anchors.right: parent.right; \n\
156− anchors.margins: margins;\n\
151+ anchors.margins: margins; \n\
152+ anchors.rightMargin: 0; \n\
157− data: [ %2\n\
153+ data: [ \n\
157+ var args = Array.prototype.slice.call(arguments);
158+ var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(',\n'));
163−// %1 is used as anchors of row
162+// multiple item version of kHeaderContainerCode
164−// %2 is used as first child of the row
163+function kHeaderContainerCodeGenerator() {
165−// %3 is used as second child of the row
164+ var headerContainerCodeTemplate = 'Item { \n\
166−// %4 is used as third child of the row
165+ id: headerTitleContainer; \n\
167−var kHeaderRow3Code = 'Row { \n\
166+ anchors { %1 } \n\
168− id: row; \n\
167+ width: parent.width - x; \n\
169− objectName: "outerRow"; \n\
168+ implicitHeight: %2; \n\
170− property real margins: units.gu(1); \n\
171− spacing: margins; \n\
172− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
174− anchors.right: parent.right; \n\
175− anchors.margins: margins;\n\
176− data: [ %2\n\
169+ data: [ \n\
184−// %1 is used as first child of the column
185−// %2 is used as second child of the column
186−var kHeaderColumnCode = 'Column { \n\
187− anchors.verticalCenter: parent.verticalCenter; \n\
188− spacing: units.dp(2); \n\
189− width: parent.width - x;\n\
173+ var args = Array.prototype.slice.call(arguments);
174+ var code = headerContainerCodeTemplate.arg(args.shift()).arg(args.shift()).arg(args.join(',\n'));
196// %1 is used as anchors of mascotShapeLoader
178// %1 is used as anchors of mascotShapeLoader
197var kMascotShapeLoaderCode = 'Loader { \n\
179var kMascotShapeLoaderCode = 'Loader { \n\
@@ -213,7 +195,7 @@ var kMascotImageCode = 'Image { \n\
213 objectName: "mascotImage"; \n\
195 objectName: "mascotImage"; \n\
214 anchors { %1 } \n\
196 anchors { %1 } \n\
215 readonly property int maxSize: Math.max(width, height) * 4; \n\
197 readonly property int maxSize: Math.max(width, height) * 4; \n\
216− source: cardData && cardData["mascot"]; \n\
198+ source: cardData && cardData["mascot"] || ""; \n\
217 width: units.gu(6); \n\
199 width: units.gu(6); \n\
218 height: units.gu(5.625); \n\
200 height: units.gu(5.625); \n\
219 sourceSize { width: maxSize; height: maxSize } \n\
201 sourceSize { width: maxSize; height: maxSize } \n\
@@ -224,7 +206,7 @@ var kMascotImageCode = 'Image { \n\
226// %1 is used as anchors of titleLabel
208// %1 is used as anchors of titleLabel
227−// %1 is used as color of titleLabel
209+// %2 is used as color of titleLabel
228// %3 is used as extra condition for visible of titleLabel
210// %3 is used as extra condition for visible of titleLabel
229var kTitleLabelCode = 'Label { \n\
211var kTitleLabelCode = 'Label { \n\
230 id: titleLabel; \n\
212 id: titleLabel; \n\
@@ -242,12 +224,39 @@ var kTitleLabelCode = 'Label { \n\
242 horizontalAlignment: root.headerAlignment; \n\
224 horizontalAlignment: root.headerAlignment; \n\
227+// %1 is used as extra anchors of emblemIcon
228+// %2 is used as color of emblemIcon
229+var kEmblemIconCode = 'Icon { \n\
231+ objectName: "emblemIcon"; \n\
233+ bottom: titleLabel.baseline; \n\
234+ right: parent.right; \n\
237+ source: cardData && cardData["emblem"] || ""; \n\
240+ height: source != "" ? titleLabel.font.pixelSize : 0; \n\
243+// %1 is used as anchors of touchdown effect
244+var kTouchdownCode = 'UbuntuShape { \n\
246+ objectName: "touchdown"; \n\
248+ visible: root.pressed; \n\
249+ radius: "medium"; \n\
250+ borderSource: "radius_pressed.sci" \n\
245// %1 is used as anchors of subtitleLabel
253// %1 is used as anchors of subtitleLabel
246// %2 is used as color of subtitleLabel
254// %2 is used as color of subtitleLabel
247var kSubtitleLabelCode = 'Label { \n\
255var kSubtitleLabelCode = 'Label { \n\
248 id: subtitleLabel; \n\
256 id: subtitleLabel; \n\
249 objectName: "subtitleLabel"; \n\
257 objectName: "subtitleLabel"; \n\
250 anchors { %1 } \n\
258 anchors { %1 } \n\
259+ anchors.topMargin: units.dp(2); \n\
251 elide: Text.ElideRight; \n\
260 elide: Text.ElideRight; \n\
252 fontSize: "small"; \n\
261 fontSize: "small"; \n\
253 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
262 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
@@ -258,6 +267,16 @@ var kSubtitleLabelCode = 'Label { \n\
258 horizontalAlignment: root.headerAlignment; \n\
267 horizontalAlignment: root.headerAlignment; \n\
270+// %1 is used as anchors of attributesRow
271+// %2 is used as color of attributesRow
272+var kAttributesRowCode = 'CardAttributes { \n\
273+ id: attributesRow; \n\
274+ objectName: "attributesRow"; \n\
277+ model: cardData && cardData["attributes"]; \n\
261// %1 is used as top anchor of summary
280// %1 is used as top anchor of summary
262// %2 is used as topMargin anchor of summary
281// %2 is used as topMargin anchor of summary
263// %3 is used as color of summary
282// %3 is used as color of summary
@@ -305,9 +324,11 @@ function cardString(template, components) {
305 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);
324 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);
306 var hasTitle = components["title"] || false;
325 var hasTitle = components["title"] || false;
307 var hasMascot = components["mascot"] || false;
326 var hasMascot = components["mascot"] || false;
327+ var hasEmblem = components["emblem"] && !(hasMascot && template["card-size"] === "small") || false;
308 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
328 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
309 var hasSubtitle = hasTitle && components["subtitle"] || false;
329 var hasSubtitle = hasTitle && components["subtitle"] || false;
310 var hasHeaderRow = hasMascot && hasTitle;
330 var hasHeaderRow = hasMascot && hasTitle;
331+ var hasAttributes = hasTitle && components["attributes"]["field"] || false;
312 if (hasBackground) {
333 if (hasBackground) {
313 code += kBackgroundLoaderCode;
334 code += kBackgroundLoaderCode;
@@ -318,9 +339,9 @@ function cardString(template, components) {
318 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
339 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
320 var widthCode, heightCode;
341 var widthCode, heightCode;
321− var anchors;
342+ var artAnchors;
322 if (isHorizontal) {
343 if (isHorizontal) {
323− anchors = 'left: parent.left';
344+ artAnchors = 'left: parent.left';
324 if (hasMascot || hasTitle) {
345 if (hasMascot || hasTitle) {
325 widthCode = 'height * artShape.aspect'
346 widthCode = 'height * artShape.aspect'
326 heightCode = 'headerHeight + 2 * units.gu(1)';
347 heightCode = 'headerHeight + 2 * units.gu(1)';
@@ -331,12 +352,12 @@ function cardString(template, components) {
331 heightCode = 'units.gu(7.625)';
352 heightCode = 'units.gu(7.625)';
334− anchors = 'horizontalCenter: parent.horizontalCenter;';
355+ artAnchors = 'horizontalCenter: parent.horizontalCenter;';
335 widthCode = 'root.width'
356 widthCode = 'root.width'
336 heightCode = 'width / artShape.aspect';
357 heightCode = 'width / artShape.aspect';
339− code += kArtShapeHolderCode.arg(anchors).arg(widthCode).arg(heightCode);
360+ code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
341 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
362 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
@@ -373,10 +394,20 @@ function cardString(template, components) {
373 headerLeftAnchor = 'left: parent.left;\n';
394 headerLeftAnchor = 'left: parent.left;\n';
397+ var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary;
376 if (hasHeaderRow) {
399 if (hasHeaderRow) {
377 code += 'readonly property int headerHeight: row.height;\n'
400 code += 'readonly property int headerHeight: row.height;\n'
378 } else if (hasMascot) {
401 } else if (hasMascot) {
379 code += 'readonly property int headerHeight: mascotImage.height;\n'
402 code += 'readonly property int headerHeight: mascotImage.height;\n'
403+ } else if (hasAttributes) {
404+ if (hasTitle && hasSubtitle) {
405+ code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
406+ } else if (hasTitle) {
407+ code += 'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
409+ code += 'readonly property int headerHeight: attributesRow.height;\n'
380 } else if (hasSubtitle) {
411 } else if (hasSubtitle) {
381 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
412 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
382 } else if (hasTitle) {
413 } else if (hasTitle) {
@@ -385,149 +416,242 @@ function cardString(template, components) {
385 code += 'readonly property int headerHeight: 0;\n'
416 code += 'readonly property int headerHeight: 0;\n'
388− var mascotShapeCode = "";
419+ var mascotShapeCode = '';
389− var mascotCode = "";
420+ var mascotCode = '';
390 if (hasMascot) {
421 if (hasMascot) {
391 var useMascotShape = !hasBackground && !headerAsOverlay;
422 var useMascotShape = !hasBackground && !headerAsOverlay;
392− var anchors = "";
423+ var mascotAnchors = '';
393 if (!hasHeaderRow) {
424 if (!hasHeaderRow) {
394− anchors += headerLeftAnchor;
425+ mascotAnchors += headerLeftAnchor;
395− anchors += headerVerticalAnchors;
426+ mascotAnchors += headerVerticalAnchors;
396 if (!headerLeftAnchorHasMargin) {
427 if (!headerLeftAnchorHasMargin) {
397− anchors += 'leftMargin: units.gu(1);\n'
428+ mascotAnchors += 'leftMargin: units.gu(1);\n'
400− anchors = "verticalCenter: parent.verticalCenter;"
431+ mascotAnchors = 'verticalCenter: parent.verticalCenter;'
403 if (useMascotShape) {
434 if (useMascotShape) {
404− mascotShapeCode = kMascotShapeLoaderCode.arg(anchors);
435+ mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors);
407 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
438 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
408− mascotCode = kMascotImageCode.arg(anchors).arg(mascotImageVisible);
439+ mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
411− 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 : "grey")';
444+ var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
413− var titleSubtitleCode = "";
445+ var titleSubtitleCode = '';
414 if (hasTitle) {
446 if (hasTitle) {
415− var color;
447+ var titleColor;
416 if (headerAsOverlay) {
448 if (headerAsOverlay) {
417− 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 : "grey")';
418 } else if (hasSummary) {
450 } else if (hasSummary) {
419− color = 'summary.color';
451+ titleColor = 'summary.color';
420 } else if (hasBackground) {
452 } else if (hasBackground) {
421− color = summaryColorWithBackground;
453+ titleColor = summaryColorWithBackground;
423− color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
455+ titleColor = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
426 var titleAnchors;
458 var titleAnchors;
427 var subtitleAnchors;
459 var subtitleAnchors;
460+ var attributesAnchors;
461+ var titleContainerAnchors;
462+ var titleRightAnchor;
464+ var extraRightAnchor = '';
465+ var extraLeftAnchor = '';
466+ if (!touchdownOnArtShape) {
467+ extraRightAnchor = 'rightMargin: units.gu(1); \n';
468+ extraLeftAnchor = 'leftMargin: units.gu(1); \n';
428− if (hasMascot && hasSubtitle) {
471+ if (hasMascot) {
429− // Using row + column
472+ titleContainerAnchors = 'verticalCenter: parent.verticalCenter; ';
474+ titleContainerAnchors = 'right: parent.right; ';
475+ titleContainerAnchors += headerLeftAnchor;
476+ titleContainerAnchors += headerVerticalAnchors;
477+ if (!headerLeftAnchorHasMargin) {
478+ titleContainerAnchors += extraLeftAnchor;
482+ titleRightAnchor = 'right: emblemIcon.left; \n\
483+ rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
485+ titleRightAnchor = 'right: parent.right; \n'
486+ titleRightAnchor += extraRightAnchor;
489+ if (hasTitleContainer) {
490+ // Using headerTitleContainer
491+ titleAnchors = titleRightAnchor;
430− titleAnchors = 'left: parent.left; right: parent.right';
492+ titleAnchors += 'left: parent.left; \n\
494+ subtitleAnchors = 'right: parent.right; \n\
495+ left: parent.left; \n';
431− subtitleAnchors = titleAnchors;
496+ subtitleAnchors += extraRightAnchor;
498+ attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
499+ subtitleAnchors += 'top: titleLabel.bottom;\n';
501+ attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
432 } else if (hasMascot) {
503 } else if (hasMascot) {
433− // Using row + label
504+ // Using row + titleContainer
434− titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
505+ titleAnchors = 'verticalCenter: parent.verticalCenter;\n';
436 if (headerAsOverlay) {
507 if (headerAsOverlay) {
437 // Using anchors to the overlay
508 // Using anchors to the overlay
509+ titleAnchors = titleRightAnchor;
438− titleAnchors = 'left: parent.left; \n\
510+ titleAnchors += 'left: parent.left; \n\
439− leftMargin: units.gu(1); \n\
511+ leftMargin: units.gu(1); \n\
440− right: parent.right; \n\
441− top: overlayLoader.top; \n\
512+ top: overlayLoader.top; \n\
442− topMargin: units.gu(1);\n';
513+ topMargin: units.gu(1);\n';
444 // Using anchors to the mascot/parent
515 // Using anchors to the mascot/parent
445− titleAnchors = "right: parent.right;";
516+ titleAnchors = titleRightAnchor;
446 titleAnchors += headerLeftAnchor;
517 titleAnchors += headerLeftAnchor;
447 titleAnchors += headerVerticalAnchors;
518 titleAnchors += headerVerticalAnchors;
448 if (!headerLeftAnchorHasMargin) {
519 if (!headerLeftAnchorHasMargin) {
449− titleAnchors += 'leftMargin: units.gu(1);\n'
520+ titleAnchors += extraLeftAnchor;
452 subtitleAnchors = 'left: titleLabel.left; \n\
523 subtitleAnchors = 'left: titleLabel.left; \n\
453− leftMargin: titleLabel.leftMargin; \n\
524+ leftMargin: titleLabel.leftMargin; \n';
525+ subtitleAnchors += extraRightAnchor;
528+ subtitleAnchors += 'right: parent.right; \n';
454− right: titleLabel.right; \n\
530+ subtitleAnchors += 'right: titleLabel.right; \n';
534+ attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
455− top: titleLabel.bottom; \n\
535+ subtitleAnchors += 'top: titleLabel.bottom;\n';
456− topMargin: units.dp(2);\n';
536+ } else {
537+ attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
541+ // code for different elements
459 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
542 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
460− var titleCode = kTitleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
543+ var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra);
461− var subtitleCode = "";
544+ var subtitleCode;
547+ // code for the title container
548+ var containerCode = [];
549+ var containerHeight = 'titleLabel.height';
550+ containerCode.push(titleCode);
462 if (hasSubtitle) {
551 if (hasSubtitle) {
463− subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
552+ subtitleCode = kSubtitleLabelCode.arg(subtitleAnchors).arg(titleColor);
553+ containerCode.push(subtitleCode);
554+ containerHeight += ' + subtitleLabel.height';
557+ containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
559+ if (hasAttributes) {
560+ attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
561+ containerCode.push(attributesCode);
562+ containerHeight += ' + attributesRow.height';
466− if (hasMascot && hasSubtitle) {
565+ if (hasTitleContainer) {
467− // If using row + column wrap the code in the column
566+ // use container
468− titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
567+ titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
470− titleSubtitleCode = titleCode + subtitleCode;
570+ titleSubtitleCode = titleCode;
572+ titleSubtitleCode += subtitleCode;
574+ if (hasAttributes) {
575+ titleSubtitleCode += attributesCode;
474 if (hasHeaderRow) {
580 if (hasHeaderRow) {
581+ var rowCode = [mascotCode, titleSubtitleCode];
475− if (mascotShapeCode != "") {
582+ if (mascotShapeCode != '') {
476− code += kHeaderRow3Code.arg(headerVerticalAnchors + headerLeftAnchor).arg(mascotShapeCode).arg(mascotCode).arg(titleSubtitleCode);
583+ rowCode.unshift(mascotShapeCode);
478− code += kHeaderRow2Code.arg(headerVerticalAnchors + headerLeftAnchor).arg(mascotCode).arg(titleSubtitleCode);
585+ code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
481 code += mascotShapeCode + mascotCode + titleSubtitleCode;
587 code += mascotShapeCode + mascotCode + titleSubtitleCode;
484 if (hasSummary) {
590 if (hasSummary) {
485 var summaryTopAnchor;
591 var summaryTopAnchor;
486− if (isHorizontal && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
592+ if (isHorizontal && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
487− else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
593+ else if (headerAsOverlay && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
488− else if (hasHeaderRow) summaryTopAnchor = "row.bottom";
594+ else if (hasHeaderRow) summaryTopAnchor = 'row.bottom';
595+ else if (hasTitleContainer) summaryTopAnchor = 'headerTitleContainer.bottom';
489− else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";
596+ else if (hasMascot) summaryTopAnchor = 'mascotImage.bottom';
597+ else if (hasAttributes) summaryTopAnchor = 'attributesRow.bottom';
490− else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";
598+ else if (hasSubtitle) summaryTopAnchor = 'subtitleLabel.bottom';
491− else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";
599+ else if (hasTitle) summaryTopAnchor = 'titleLabel.bottom';
492− else if (hasArt) summaryTopAnchor = "artShapeHolder.bottom";
600+ else if (hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
493− else summaryTopAnchor = "parent.top";
601+ else summaryTopAnchor = 'parent.top';
495− var color;
603+ var summaryColor;
496 if (hasBackground) {
604 if (hasBackground) {
497− color = summaryColorWithBackground;
605+ summaryColor = summaryColorWithBackground;
499− color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
607+ summaryColor = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
502− var summaryTopMargin = (hasMascot || hasSubtitle ? 'anchors.margins' : '0');
610+ var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ? 'anchors.margins' : '0');
504− code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
612+ code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
615+ var touchdownAnchors;
616+ if (hasBackground) {
617+ touchdownAnchors = 'fill: backgroundLoader';
618+ } else if (touchdownOnArtShape) {
619+ touchdownAnchors = 'fill: artShapeHolder';
621+ touchdownAnchors = 'fill: root'
623+ code += kTouchdownCode.arg(touchdownAnchors);
625+ var implicitHeight = 'implicitHeight: ';
507 if (hasSummary) {
626 if (hasSummary) {
508− 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';
509 } else if (hasHeaderRow) {
628 } else if (hasHeaderRow) {
510− code += 'implicitHeight: row.y + row.height + units.gu(1);\n';
629+ implicitHeight += 'row.y + row.height + units.gu(1);\n';
511 } else if (hasMascot) {
630 } else if (hasMascot) {
512− 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';
634+ } else if (hasAttributes) {
635+ implicitHeight += 'attributesRow.y + attributesRow.height + units.gu(1);\n';
513 } else if (hasSubtitle) {
636 } else if (hasSubtitle) {
514− code += 'implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
637+ implicitHeight += 'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
515 } else if (hasTitle) {
638 } else if (hasTitle) {
516− code += 'implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);\n';
639+ implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
517 } else if (hasArt) {
640 } else if (hasArt) {
518− code += 'implicitHeight: artShapeHolder.height;\n';
641+ implicitHeight += 'artShapeHolder.height;\n';
520 // Close the AbstractButton
643 // Close the AbstractButton
521− code += '}\n';
644+ code += implicitHeight + '}\n';
523 return code;
646 return code;
526function createCardComponent(parent, template, components) {
649function createCardComponent(parent, template, components) {
527 var imports = 'import QtQuick 2.2; \n\
650 var imports = 'import QtQuick 2.2; \n\
528− import Ubuntu.Components 0.1; \n\
651+ import Ubuntu.Components 1.1; \n\
529− import Ubuntu.Thumbnailer 0.1;\n';
652+ import Dash 0.1;\n';
530 var card = cardString(template, components);
653 var card = cardString(template, components);
531 var code = imports + 'Component {\n' + card + '}\n';
654 var code = imports + 'Component {\n' + card + '}\n';
532 return Qt.createQmlObject(code, parent, "createCardComponent");
656 return Qt.createQmlObject(code, parent, "createCardComponent");