22 var kBackgroundLoaderCode =
'Loader {\n\
23 id: backgroundLoader; \n\
24 objectName: "backgroundLoader"; \n\
25 anchors.fill: parent; \n\
26 asynchronous: root.asynchronous; \n\
27 visible: status == Loader.Ready; \n\
28 sourceComponent: UbuntuShape { \n\
29 objectName: "background"; \n\
31 color: getColor(0) || "white"; \n\
32 gradientColor: getColor(1) || color; \n\
33 anchors.fill: parent; \n\
34 image: backgroundImage.source ? backgroundImage : null; \n\
35 property real luminance: Style.luminance(color); \n\
36 property Image backgroundImage: Image { \n\
37 objectName: "backgroundImage"; \n\
39 if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\
43 function getColor(index) { \n\
44 if (cardData && typeof cardData["background"] === "object" \n\
45 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\
46 return cardData["background"]["elements"][index]; \n\
47 } else return index === 0 ? %2 : %3; \n\
55 var kArtShapeHolderCode =
'Item { \n\
56 id: artShapeHolder; \n\
57 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
58 width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
61 id: artShapeLoader; \n\
62 objectName: "artShapeLoader"; \n\
63 active: cardData && cardData["art"] || false; \n\
64 asynchronous: root.asynchronous; \n\
65 visible: status == Loader.Ready; \n\
66 sourceComponent: Item { \n\
68 objectName: "artShape"; \n\
69 property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
70 visible: image.status == Image.Ready; \n\
71 readonly property alias image: artImage.image; \n\
72 property alias borderSource: artShapeShape.borderSource; \n\
73 ShaderEffectSource { \n\
74 id: artShapeSource; \n\
75 sourceItem: artImage; \n\
76 anchors.centerIn: parent; \n\
79 hideSource: doShapeItem; \n\
82 id: artShapeShape; \n\
83 image: artShapeSource; \n\
84 anchors.fill: parent; \n\
85 visible: doShapeItem; \n\
88 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
89 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
90 Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
91 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
92 function updateWidthHeightBindings() { \n\
93 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
94 width = root.fixedArtShapeSize.width; \n\
95 height = root.fixedArtShapeSize.height; \n\
97 width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); \n\
98 height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); \n\
101 CroppedImageMinimumSourceSize { \n\
103 objectName: "artImage"; \n\
104 source: cardData && cardData["art"] || ""; \n\
105 asynchronous: root.asynchronous; \n\
113 var kOverlayLoaderCode =
'Loader { \n\
114 id: overlayLoader; \n\
116 left: artShapeHolder.left; \n\
117 right: artShapeHolder.right; \n\
118 bottom: artShapeHolder.bottom; \n\
120 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
121 asynchronous: root.asynchronous; \n\
122 visible: showHeader && status == Loader.Ready; \n\
123 sourceComponent: ShaderEffect { \n\
125 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
126 property real luminance: Style.luminance(overlayColor); \n\
127 property color overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
128 property var source: ShaderEffectSource { \n\
129 id: shaderSource; \n\
130 sourceItem: artShapeLoader.item; \n\
131 onVisibleChanged: if (visible) scheduleUpdate(); \n\
133 sourceRect: Qt.rect(0, artShapeLoader.height - overlay.height, artShapeLoader.width, overlay.height); \n\
136 uniform highp mat4 qt_Matrix; \n\
137 attribute highp vec4 qt_Vertex; \n\
138 attribute highp vec2 qt_MultiTexCoord0; \n\
139 varying highp vec2 coord; \n\
141 coord = qt_MultiTexCoord0; \n\
142 gl_Position = qt_Matrix * qt_Vertex; \n\
144 fragmentShader: " \n\
145 varying highp vec2 coord; \n\
146 uniform sampler2D source; \n\
147 uniform lowp float qt_Opacity; \n\
148 uniform highp vec4 overlayColor; \n\
150 lowp vec4 tex = texture2D(source, coord); \n\
151 gl_FragColor = vec4(overlayColor.r, overlayColor.g, overlayColor.b, 1) * qt_Opacity * overlayColor.a * tex.a; \n\
157 function kHeaderRowCodeGenerator() {
158 var kHeaderRowCodeTemplate =
'Row { \n\
160 objectName: "outerRow"; \n\
161 property real margins: units.gu(1); \n\
162 spacing: margins; \n\
163 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
165 anchors.right: parent.right; \n\
166 anchors.margins: margins; \n\
167 anchors.rightMargin: 0; \n\
172 var args = Array.prototype.slice.call(arguments);
173 var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(
',\n'));
178 function kHeaderContainerCodeGenerator() {
179 var headerContainerCodeTemplate =
'Item { \n\
180 id: headerTitleContainer; \n\
182 width: parent.width - x; \n\
183 implicitHeight: %2; \n\
188 var args = Array.prototype.slice.call(arguments);
189 var code = headerContainerCodeTemplate.arg(args.shift()).arg(args.shift()).arg(args.join(
',\n'));
194 var kMascotShapeLoaderCode =
'Loader { \n\
195 id: mascotShapeLoader; \n\
196 objectName: "mascotShapeLoader"; \n\
197 asynchronous: root.asynchronous; \n\
198 active: mascotImage.image.status === Image.Ready; \n\
199 visible: showHeader && active && status == Loader.Ready; \n\
200 width: units.gu(6); \n\
201 height: units.gu(5.625); \n\
202 sourceComponent: UbuntuShape { image: mascotImage.image } \n\
208 var kMascotImageCode =
'CroppedImageMinimumSourceSize { \n\
210 objectName: "mascotImage"; \n\
212 source: cardData && cardData["mascot"] || ""; \n\
213 width: units.gu(6); \n\
214 height: units.gu(5.625); \n\
215 horizontalAlignment: Image.AlignHCenter; \n\
216 verticalAlignment: Image.AlignVCenter; \n\
224 var kTitleLabelCode =
'Label { \n\
226 objectName: "titleLabel"; \n\
228 elide: Text.ElideRight; \n\
229 fontSize: "small"; \n\
230 wrapMode: Text.Wrap; \n\
231 maximumLineCount: 2; \n\
232 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
234 visible: showHeader %3; \n\
236 text: root.title; \n\
237 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; \n\
238 horizontalAlignment: root.titleAlignment; \n\
245 var kEmblemIconCode =
'Icon { \n\
247 objectName: "emblemIcon"; \n\
249 bottom: titleLabel.baseline; \n\
250 right: parent.right; \n\
253 source: cardData && cardData["emblem"] || ""; \n\
255 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
256 width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; \n\
260 var kTouchdownCode =
'UbuntuShape { \n\
262 objectName: "touchdown"; \n\
264 visible: root.pressed; \n\
265 radius: "medium"; \n\
266 borderSource: "radius_pressed.sci" \n\
271 var kSubtitleLabelCode =
'Label { \n\
272 id: subtitleLabel; \n\
273 objectName: "subtitleLabel"; \n\
275 anchors.topMargin: units.dp(2); \n\
276 elide: Text.ElideRight; \n\
277 maximumLineCount: 1; \n\
278 fontSize: "x-small"; \n\
279 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
281 visible: titleLabel.visible && titleLabel.text; \n\
282 text: cardData && cardData["subtitle"] || ""; \n\
283 font.weight: Font.Light; \n\
288 var kAttributesRowCode =
'CardAttributes { \n\
289 id: attributesRow; \n\
290 objectName: "attributesRow"; \n\
293 fontScale: root.fontScale; \n\
294 model: cardData && cardData["attributes"]; \n\
300 var kSummaryLabelCode =
'Label { \n\
302 objectName: "summaryLabel"; \n\
305 left: parent.left; \n\
306 right: parent.right; \n\
307 margins: units.gu(1); \n\
310 wrapMode: Text.Wrap; \n\
311 maximumLineCount: 5; \n\
312 elide: Text.ElideRight; \n\
313 text: cardData && cardData["summary"] || ""; \n\
314 height: text ? implicitHeight : 0; \n\
315 fontSize: "small"; \n\
319 function cardString(
template, components) {
322 var templateInteractive = (
template == null ?
true : (
template[
"non-interactive"] !== undefined ? !
template[
"non-interactive"] :
true)) ?
"true" :
"false";
324 code =
'AbstractButton { \n\
326 property var components; \n\
327 property var cardData; \n\
328 property var artShapeBorderSource: undefined; \n\
329 property real fontScale: 1.0; \n\
330 property var scopeStyle: null; \n\
331 property int titleAlignment: Text.AlignLeft; \n\
332 property int fixedHeaderHeight: -1; \n\
333 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
334 readonly property string title: cardData && cardData["title"] || ""; \n\
335 property bool asynchronous: true; \n\
336 property bool showHeader: true; \n\
337 implicitWidth: childrenRect.width; \n\
339 \n'.arg(templateInteractive);
341 var hasArt = components[
"art"] && components[
"art"][
"field"] ||
false;
342 var hasSummary = components[
"summary"] ||
false;
343 var artAndSummary = hasArt && hasSummary && components[
"art"][
"conciergeMode"] !==
true;
344 var isHorizontal =
template[
"card-layout"] ===
"horizontal";
345 var hasBackground = (!isHorizontal && (
template[
"card-background"] || components[
"background"] || artAndSummary)) ||
346 (hasSummary && (
template[
"card-background"] || components[
"background"]));
347 var hasTitle = components[
"title"] ||
false;
348 var hasMascot = components[
"mascot"] ||
false;
349 var hasEmblem = components[
"emblem"] && !(hasMascot &&
template[
"card-size"] ===
"small") ||
false;
350 var headerAsOverlay = hasArt &&
template &&
template[
"overlay"] ===
true && (hasTitle || hasMascot);
351 var hasSubtitle = hasTitle && components[
"subtitle"] ||
false;
352 var hasHeaderRow = hasMascot && hasTitle;
353 var hasAttributes = hasTitle && components[
"attributes"][
"field"] ||
false;
356 var templateCardBackground = (
template && typeof
template[
"card-background"] ===
"string") ?
template[
"card-background"] :
"";
357 var backgroundElements0;
358 var backgroundElements1;
359 if (
template && typeof
template[
"card-background"] ===
"object" && (
template[
"card-background"][
"type"] ===
"color" ||
template[
"card-background"][
"type"] ===
"gradient")) {
360 if (
template[
"card-background"][
"elements"][0] !== undefined) {
361 backgroundElements0 =
'"%1"'.arg(
template[
"card-background"][
"elements"][0]);
363 if (
template[
"card-background"][
"elements"][1] !== undefined) {
364 backgroundElements1 =
'"%1"'.arg(
template[
"card-background"][
"elements"][1]);
367 code += kBackgroundLoaderCode.arg(templateCardBackground).arg(backgroundElements0).arg(backgroundElements1);
371 code +=
'onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; } \n';
372 code +=
'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
374 var widthCode, heightCode;
377 artAnchors =
'left: parent.left';
378 if (hasMascot || hasTitle) {
379 widthCode =
'height * artShape.aspect'
380 heightCode =
'headerHeight + 2 * units.gu(1)';
384 widthCode =
'height * artShape.aspect'
385 heightCode =
'units.gu(7.625)';
388 artAnchors =
'horizontalCenter: parent.horizontalCenter;';
389 widthCode =
'root.width'
390 heightCode =
'width / artShape.aspect';
393 code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
394 var fallback = components[
"art"] && components[
"art"][
"fallback"] ||
"";
395 if (fallback !==
"") {
396 code +=
'Connections { target: artShapeLoader.item ? artShapeLoader.item.image : null; onStatusChanged: if (artShapeLoader.item.image.status === Image.Error) artShapeLoader.item.image.source = "%1"; } \n'.arg(fallback);
399 code +=
'readonly property size artShapeSize: Qt.size(-1, -1);\n'
402 if (headerAsOverlay) {
403 code += kOverlayLoaderCode;
406 var headerVerticalAnchors;
407 if (headerAsOverlay) {
408 headerVerticalAnchors =
'bottom: artShapeHolder.bottom; \n\
409 bottomMargin: units.gu(1);\n';
413 headerVerticalAnchors =
'top: artShapeHolder.top; \n\
414 topMargin: units.gu(1);\n';
416 headerVerticalAnchors =
'top: artShapeHolder.bottom; \n\
417 topMargin: units.gu(1);\n';
420 headerVerticalAnchors =
'top: parent.top; \n\
421 topMargin: units.gu(1);\n';
424 var headerLeftAnchor;
425 var headerLeftAnchorHasMargin =
false;
426 if (isHorizontal && hasArt) {
427 headerLeftAnchor =
'left: artShapeHolder.right; \n\
428 leftMargin: units.gu(1);\n';
429 headerLeftAnchorHasMargin =
true;
431 headerLeftAnchor =
'left: parent.left;\n';
434 var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary;
437 code +=
'readonly property int headerHeight: row.height;\n'
438 }
else if (hasMascot) {
439 code +=
'readonly property int headerHeight: mascotImage.height;\n'
440 }
else if (hasAttributes) {
441 if (hasTitle && hasSubtitle) {
442 code +=
'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
443 }
else if (hasTitle) {
444 code +=
'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
446 code +=
'readonly property int headerHeight: attributesRow.height;\n'
448 }
else if (hasSubtitle) {
449 code +=
'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
450 }
else if (hasTitle) {
451 code +=
'readonly property int headerHeight: titleLabel.height;\n'
453 code +=
'readonly property int headerHeight: 0;\n'
456 var mascotShapeCode =
'';
459 var useMascotShape = !hasBackground && !headerAsOverlay;
460 var mascotAnchors =
'';
462 mascotAnchors += headerLeftAnchor;
463 mascotAnchors += headerVerticalAnchors;
464 if (!headerLeftAnchorHasMargin) {
465 mascotAnchors +=
'leftMargin: units.gu(1);\n'
468 mascotAnchors =
'verticalCenter: parent.verticalCenter;'
471 if (useMascotShape) {
472 mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors);
475 var mascotImageVisible = useMascotShape ?
'false' :
'showHeader';
476 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
477 var fallback = components[
"mascot"] && components[
"mascot"][
"fallback"] ||
"";
478 if (fallback !==
"") {
479 code +=
'Connections { target: mascotImage.image; onStatusChanged: if (mascotImage.image.status === Image.Error) mascotImage.source = "%1"; } \n'.arg(fallback);
483 var summaryColorWithBackground =
'backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white")';
485 var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
486 var titleSubtitleCode =
'';
489 if (headerAsOverlay) {
490 titleColor =
'root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white")';
491 }
else if (hasSummary) {
492 titleColor =
'summary.color';
493 }
else if (hasBackground) {
494 titleColor = summaryColorWithBackground;
496 titleColor =
'root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText';
501 var attributesAnchors;
502 var titleContainerAnchors;
503 var titleRightAnchor;
504 var titleWidth =
"undefined";
506 var extraRightAnchor =
'';
507 var extraLeftAnchor =
'';
508 if (!touchdownOnArtShape) {
509 extraRightAnchor =
'rightMargin: units.gu(1); \n';
510 extraLeftAnchor =
'leftMargin: units.gu(1); \n';
511 }
else if (headerAsOverlay && !hasEmblem) {
512 extraRightAnchor =
'rightMargin: units.gu(1); \n';
516 titleContainerAnchors =
'verticalCenter: parent.verticalCenter; ';
518 titleContainerAnchors =
'right: parent.right; ';
519 titleContainerAnchors += headerLeftAnchor;
520 titleContainerAnchors += headerVerticalAnchors;
521 if (!headerLeftAnchorHasMargin) {
522 titleContainerAnchors += extraLeftAnchor;
526 titleRightAnchor =
'right: emblemIcon.left; \n\
527 rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
529 titleRightAnchor =
'right: parent.right; \n'
530 titleRightAnchor += extraRightAnchor;
533 if (hasTitleContainer) {
535 titleAnchors = titleRightAnchor;
536 titleAnchors +=
'left: parent.left; \n\
538 subtitleAnchors =
'right: parent.right; \n\
539 left: parent.left; \n';
540 subtitleAnchors += extraRightAnchor;
542 attributesAnchors = subtitleAnchors +
'top: subtitleLabel.bottom;\n';
543 subtitleAnchors +=
'top: titleLabel.bottom;\n';
545 attributesAnchors = subtitleAnchors +
'top: titleLabel.bottom;\n';
547 }
else if (hasMascot) {
549 titleAnchors =
'verticalCenter: parent.verticalCenter;\n';
550 titleWidth =
"parent.width - x";
552 if (headerAsOverlay) {
554 titleAnchors = titleRightAnchor;
555 titleAnchors +=
'left: parent.left; \n\
556 leftMargin: units.gu(1); \n\
557 top: overlayLoader.top; \n\
558 topMargin: units.gu(1);\n';
561 titleAnchors = titleRightAnchor;
562 titleAnchors += headerLeftAnchor;
563 titleAnchors += headerVerticalAnchors;
564 if (!headerLeftAnchorHasMargin) {
565 titleAnchors += extraLeftAnchor;
568 subtitleAnchors =
'left: titleLabel.left; \n\
569 leftMargin: titleLabel.leftMargin; \n';
570 subtitleAnchors += extraRightAnchor;
573 subtitleAnchors +=
'right: parent.right; \n';
575 subtitleAnchors +=
'right: titleLabel.right; \n';
579 attributesAnchors = subtitleAnchors +
'top: subtitleLabel.bottom;\n';
580 subtitleAnchors +=
'top: titleLabel.bottom;\n';
582 attributesAnchors = subtitleAnchors +
'top: titleLabel.bottom;\n';
587 var titleLabelVisibleExtra = (headerAsOverlay ?
'&& overlayLoader.active':
'');
588 var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra).arg(titleWidth);
593 var containerCode = [];
594 var containerHeight =
'titleLabel.height';
595 containerCode.push(titleCode);
597 subtitleCode = kSubtitleLabelCode.arg(subtitleAnchors).arg(titleColor);
598 containerCode.push(subtitleCode);
599 containerHeight +=
' + subtitleLabel.height';
602 containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
605 attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
606 containerCode.push(attributesCode);
607 containerHeight +=
' + attributesRow.height';
610 if (hasTitleContainer) {
612 titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
615 titleSubtitleCode = titleCode;
617 titleSubtitleCode += subtitleCode;
620 titleSubtitleCode += attributesCode;
626 var rowCode = [mascotCode, titleSubtitleCode];
627 if (mascotShapeCode !=
'') {
628 rowCode.unshift(mascotShapeCode);
630 code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
632 code += mascotShapeCode + mascotCode + titleSubtitleCode;
636 var summaryTopAnchor;
637 if (isHorizontal && hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
638 else if (headerAsOverlay && hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
639 else if (hasHeaderRow) summaryTopAnchor =
'row.bottom';
640 else if (hasTitleContainer) summaryTopAnchor =
'headerTitleContainer.bottom';
641 else if (hasMascot) summaryTopAnchor =
'mascotImage.bottom';
642 else if (hasAttributes) summaryTopAnchor =
'attributesRow.bottom';
643 else if (hasSubtitle) summaryTopAnchor =
'subtitleLabel.bottom';
644 else if (hasTitle) summaryTopAnchor =
'titleLabel.bottom';
645 else if (hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
646 else summaryTopAnchor =
'parent.top';
650 summaryColor = summaryColorWithBackground;
652 summaryColor =
'root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText';
655 var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ?
'anchors.margins' :
'0');
657 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
660 var touchdownAnchors;
662 touchdownAnchors =
'fill: backgroundLoader';
663 }
else if (touchdownOnArtShape) {
664 touchdownAnchors =
'fill: artShapeHolder';
666 touchdownAnchors =
'fill: root'
668 code += kTouchdownCode.arg(touchdownAnchors);
670 var implicitHeight =
'implicitHeight: ';
672 implicitHeight +=
'summary.y + summary.height + units.gu(1);\n';
673 }
else if (headerAsOverlay) {
674 implicitHeight +=
'artShapeHolder.height;\n';
675 }
else if (hasHeaderRow) {
676 implicitHeight +=
'row.y + row.height + units.gu(1);\n';
677 }
else if (hasMascot) {
678 implicitHeight +=
'mascotImage.y + mascotImage.height;\n';
679 }
else if (hasTitleContainer) {
680 implicitHeight +=
'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
681 }
else if (hasAttributes) {
682 implicitHeight +=
'attributesRow.y + attributesRow.height + units.gu(1);\n';
683 }
else if (hasSubtitle) {
684 implicitHeight +=
'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
685 }
else if (hasTitle) {
686 implicitHeight +=
'titleLabel.y + titleLabel.height + units.gu(1);\n';
688 implicitHeight +=
'artShapeHolder.height;\n';
694 code += implicitHeight +
'}\n';
699 function createCardComponent(parent,
template, components) {
700 var imports =
'import QtQuick 2.2; \n\
701 import Ubuntu.Components 1.1; \n\
702 import Ubuntu.Settings.Components 0.1; \n\
704 import Utils 0.1;\n';
705 var card = cardString(
template, components);
706 var code = imports +
'Component {\n' + card +
'}\n';
709 return Qt.createQmlObject(code, parent,
"createCardComponent");
711 console.error(
"ERROR: Invalid component created.");
712 console.error(
"Template:");
713 console.error(JSON.stringify(
template));
714 console.error(
"Components:");
715 console.error(JSON.stringify(components));
716 console.error(
"Code:");