@@ -30,6 +30,7 @@ function createCardComponent(parent, template, components) {
30 property var cardData; \
30 property var cardData; \
31 property real fontScale: 1.0; \
31 property real fontScale: 1.0; \
32 property int headerAlignment: Text.AlignLeft; \
32 property int headerAlignment: Text.AlignLeft; \
33+ property int fixedHeaderHeight: -1; \
33 property size fixedArtShapeSize: Qt.size(-1, -1); \
34 property size fixedArtShapeSize: Qt.size(-1, -1); \
34 readonly property string title: cardData && cardData["title"] || ""; \
35 readonly property string title: cardData && cardData["title"] || ""; \
35 property bool asynchronous: true; \
36 property bool asynchronous: true; \
@@ -41,12 +42,11 @@ function createCardComponent(parent, template, components) {
41 var artAndSummary = hasArt && hasSummary;
42 var artAndSummary = hasArt && hasSummary;
42 var isHorizontal = template["card-layout"] === "horizontal";
43 var isHorizontal = template["card-layout"] === "horizontal";
43 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);
44 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);
44− var inOverlay = hasArt && template && template["overlay"] === true;
45 var hasTitle = components["title"] || false;
45 var hasTitle = components["title"] || false;
46 var hasMascot = components["mascot"] || false;
46 var hasMascot = components["mascot"] || false;
47+ var inOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
47 var hasSubtitle = components["subtitle"] || false;
48 var hasSubtitle = components["subtitle"] || false;
48 var hasHeaderRow = hasMascot && hasTitle;
49 var hasHeaderRow = hasMascot && hasTitle;
49− var mascotImageHeight = 'units.gu(5.625)';
51 if (hasBackground) {
51 if (hasBackground) {
52 code += 'Loader {\
52 code += 'Loader {\
@@ -88,12 +88,12 @@ function createCardComponent(parent, template, components) {
88 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);'
88 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);'
89 var imageWidthHeight;
89 var imageWidthHeight;
90 if (isHorizontal) {
90 if (isHorizontal) {
91− if (hasMascot) {
91+ if (hasMascot || hasTitle) {
92 imageWidthHeight = 'width: height * artShape.aspect; \
92 imageWidthHeight = 'width: height * artShape.aspect; \
93− height: mascotImage.height + 2 * units.gu(1);'
93+ height: headerHeight;'
95 imageWidthHeight = 'width: height * artShape.aspect; \
95 imageWidthHeight = 'width: height * artShape.aspect; \
96− height: ' + mascotImageHeight + ' + 2 * units.gu(1);'
96+ height: units.gu(8.625)';
99 imageWidthHeight = 'width: root.width; \
99 imageWidthHeight = 'width: root.width; \
@@ -144,12 +144,7 @@ function createCardComponent(parent, template, components) {
146 if (inOverlay) {
146 if (inOverlay) {
147− var height;
147+ var height = 'fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight;';
149− var height = 'mascotImage.height + 2 * units.gu(1);';
151− var height = mascotImageHeight + ' + 2 * units.gu(1);';
153 code += 'Loader { \
148 code += 'Loader { \
154 id: overlayLoader; \
149 id: overlayLoader; \
155 anchors { \
150 anchors { \
@@ -219,6 +214,7 @@ function createCardComponent(parent, template, components) {
221 if (hasHeaderRow) {
216 if (hasHeaderRow) {
217+ code += 'readonly property int headerHeight: row.height + row.margins * 2;'
222 code += 'Row { \
218 code += 'Row { \
223 id: row; \
219 id: row; \
224 objectName: "outerRow"; \
220 objectName: "outerRow"; \
@@ -237,6 +233,7 @@ function createCardComponent(parent, template, components) {
237 anchors += headerLeftAnchor;
233 anchors += headerLeftAnchor;
238 anchors += 'anchors.leftMargin: units.gu(1);'
234 anchors += 'anchors.leftMargin: units.gu(1);'
239 anchors += headerVerticalAnchors;
235 anchors += headerVerticalAnchors;
236+ code += 'readonly property int headerHeight: mascotImage.height + units.gu(1) * 2;'
241 anchors = "anchors.verticalCenter: parent.verticalCenter;"
238 anchors = "anchors.verticalCenter: parent.verticalCenter;"
@@ -262,7 +259,7 @@ function createCardComponent(parent, template, components) {
262 readonly property int maxSize: Math.max(width, height) * 4; \
259 readonly property int maxSize: Math.max(width, height) * 4; \
263 source: cardData && cardData["mascot"]; \
260 source: cardData && cardData["mascot"]; \
264 width: units.gu(6); \
261 width: units.gu(6); \
265− height: ' + mascotImageHeight + '; \
262+ height: units.gu(5.625); \
266 sourceSize { width: maxSize; height: maxSize } \
263 sourceSize { width: maxSize; height: maxSize } \
267 fillMode: Image.PreserveAspectCrop; \
264 fillMode: Image.PreserveAspectCrop; \
268 horizontalAlignment: Image.AlignHCenter; \
265 horizontalAlignment: Image.AlignHCenter; \
@@ -296,16 +293,17 @@ function createCardComponent(parent, template, components) {
296 width: parent.width - x;';
293 width: parent.width - x;';
297 } else if (hasMascot) {
294 } else if (hasMascot) {
298 titleAnchors = 'anchors.verticalCenter: parent.verticalCenter;'
295 titleAnchors = 'anchors.verticalCenter: parent.verticalCenter;'
299− } else if (inOverlay && hasSubtitle) {
296+ } else if (inOverlay) {
297+ titleAnchors = 'anchors.left: parent.left; \
300− titleAnchors = 'anchors.leftMargin: units.gu(1); \
298+ anchors.leftMargin: units.gu(1); \
301 anchors.right: parent.right; \
299 anchors.right: parent.right; \
302− anchors.bottom: subtitleLabel.top; \
300+ anchors.top: overlayLoader.top; \
303− anchors.bottomMargin: units.dp(2);';
301+ anchors.topMargin: units.gu(1);';
304− titleAnchors += headerLeftAnchor;
305 subtitleAnchors = 'anchors.left: titleLabel.left; \
302 subtitleAnchors = 'anchors.left: titleLabel.left; \
306 anchors.leftMargin: titleLabel.leftMargin; \
303 anchors.leftMargin: titleLabel.leftMargin; \
307− anchors.right: titleLabel.right;';
304+ anchors.right: titleLabel.right; \
308− subtitleAnchors += headerVerticalAnchors;
305+ anchors.top: titleLabel.bottom; \
306+ anchors.topMargin: units.dp(2);';
310 titleAnchors = "anchors.right: parent.right;";
308 titleAnchors = "anchors.right: parent.right;";
311 if (hasMascot) {
309 if (hasMascot) {
@@ -321,6 +319,13 @@ function createCardComponent(parent, template, components) {
321 anchors.top: titleLabel.bottom; \
319 anchors.top: titleLabel.bottom; \
322 anchors.topMargin: units.dp(2);';
320 anchors.topMargin: units.dp(2);';
322+ if (!hasHeaderRow) {
324+ code += 'readonly property int headerHeight: subtitleLabel.y + subtitleLabel.height - titleLabel.y + titleLabel.anchors.topMargin * 2 + subtitleLabel.anchors.topMargin;'
326+ code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;'
325 code += 'Label { \
330 code += 'Label { \
326 id: titleLabel; \
331 id: titleLabel; \
@@ -332,7 +337,7 @@ function createCardComponent(parent, template, components) {
332 maximumLineCount: 2; \
337 maximumLineCount: 2; \
333 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \
338 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \
334 color: ' + color + '; \
339 color: ' + color + '; \
335− visible: showHeader; \
340+ visible: showHeader ' + (inOverlay ? '&& overlayLoader.active': '') + '; \
336 text: root.title; \
341 text: root.title; \
337 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; \
342 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; \
338 horizontalAlignment: root.headerAlignment; \
343 horizontalAlignment: root.headerAlignment; \
@@ -347,7 +352,7 @@ function createCardComponent(parent, template, components) {
347 fontSize: "small"; \
352 fontSize: "small"; \
348 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \
353 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \
349 color: ' + color + '; \
354 color: ' + color + '; \
350− visible: showHeader && titleLabel.text; \
355+ visible: titleLabel.visible && titleLabel.text; \
351 text: cardData && cardData["subtitle"] || ""; \
356 text: cardData && cardData["subtitle"] || ""; \
352 font.weight: Font.Light; \
357 font.weight: Font.Light; \
353 horizontalAlignment: root.headerAlignment; \
358 horizontalAlignment: root.headerAlignment; \