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 backgroundColor: getColor(0) || "white"; \n\
32 secondaryBackgroundColor: getColor(1) || backgroundColor; \n\
33 backgroundMode: UbuntuShape.VerticalGradient; \n\
34 anchors.fill: parent; \n\
35 source: backgroundImage.source ? backgroundImage : null; \n\
36 property real luminance: Style.luminance(backgroundColor); \n\
37 property Image backgroundImage: Image { \n\
38 objectName: "backgroundImage"; \n\
40 if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\
44 function getColor(index) { \n\
45 if (cardData && typeof cardData["background"] === "object" \n\
46 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\
47 return cardData["background"]["elements"][index]; \n\
48 } else return index === 0 ? %2 : %3; \n\
56 var kArtShapeHolderCode =
'Item { \n\
57 id: artShapeHolder; \n\
58 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
59 width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
62 id: artShapeLoader; \n\
63 objectName: "artShapeLoader"; \n\
64 active: cardData && cardData["art"] || false; \n\
65 asynchronous: root.asynchronous; \n\
66 visible: status == Loader.Ready; \n\
67 sourceComponent: Item { \n\
69 objectName: "artShape"; \n\
70 readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
71 visible: image.status == Image.Ready; \n\
72 readonly property alias image: artImage; \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 source: artShapeSource; \n\
84 anchors.fill: parent; \n\
85 visible: doShapeItem; \n\
87 aspect: root.artShapeStyle === "inset" ? UbuntuShape.Inset : UbuntuShape.Flat; \n\
89 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
90 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
91 Component.onCompleted: { updateWidthHeightBindings(); } \n\
92 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
93 function updateWidthHeightBindings() { \n\
94 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
95 width = root.fixedArtShapeSize.width; \n\
96 height = root.fixedArtShapeSize.height; \n\
98 width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); \n\
99 height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); \n\
102 CroppedImageMinimumSourceSize { \n\
104 objectName: "artImage"; \n\
105 source: cardData && cardData["art"] || ""; \n\
106 asynchronous: root.asynchronous; \n\
114 var kOverlayLoaderCode =
'Loader { \n\
115 id: overlayLoader; \n\
116 readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
117 anchors.fill: artShapeHolder; \n\
118 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
119 asynchronous: root.asynchronous; \n\
120 visible: showHeader && status == Loader.Ready; \n\
121 sourceComponent: UbuntuShapeOverlay { \n\
123 property real luminance: Style.luminance(overlayColor); \n\
124 aspect: UbuntuShape.Flat; \n\
125 radius: "medium"; \n\
126 overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
127 overlayRect: Qt.rect(0, 1 - overlayLoader.overlayHeight / height, 1, 1); \n\
132 function kHeaderRowCodeGenerator() {
133 var kHeaderRowCodeTemplate =
'Row { \n\
135 objectName: "outerRow"; \n\
136 property real margins: units.gu(1); \n\
137 spacing: margins; \n\
138 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
140 anchors.right: parent.right; \n\
141 anchors.margins: margins; \n\
142 anchors.rightMargin: 0; \n\
147 var args = Array.prototype.slice.call(arguments);
148 var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(
',\n'));
153 function kHeaderContainerCodeGenerator() {
154 var headerContainerCodeTemplate =
'Item { \n\
155 id: headerTitleContainer; \n\
157 width: parent.width - x; \n\
158 implicitHeight: %2; \n\
163 var args = Array.prototype.slice.call(arguments);
164 var code = headerContainerCodeTemplate.arg(args.shift()).arg(args.shift()).arg(args.join(
',\n'));
169 var kMascotShapeLoaderCode =
'Loader { \n\
170 id: mascotShapeLoader; \n\
171 objectName: "mascotShapeLoader"; \n\
172 asynchronous: root.asynchronous; \n\
173 active: mascotImage.status === Image.Ready; \n\
174 visible: showHeader && active && status == Loader.Ready; \n\
175 width: units.gu(6); \n\
176 height: units.gu(5.625); \n\
177 sourceComponent: UbuntuShape { image: mascotImage } \n\
183 var kMascotImageCode =
'CroppedImageMinimumSourceSize { \n\
185 objectName: "mascotImage"; \n\
187 source: cardData && cardData["mascot"] || ""; \n\
188 width: units.gu(6); \n\
189 height: units.gu(5.625); \n\
190 horizontalAlignment: Image.AlignHCenter; \n\
191 verticalAlignment: Image.AlignVCenter; \n\
199 var kTitleLabelCode =
'Label { \n\
201 objectName: "titleLabel"; \n\
203 elide: Text.ElideRight; \n\
204 fontSize: "small"; \n\
205 wrapMode: Text.Wrap; \n\
206 maximumLineCount: 2; \n\
207 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
209 visible: showHeader %3; \n\
211 text: root.title; \n\
212 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; \n\
213 horizontalAlignment: root.titleAlignment; \n\
220 var kEmblemIconCode =
'Icon { \n\
222 objectName: "emblemIcon"; \n\
224 bottom: titleLabel.baseline; \n\
225 right: parent.right; \n\
228 source: cardData && cardData["emblem"] || ""; \n\
230 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
231 width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; \n\
235 var kTouchdownCode =
'UbuntuShape { \n\
237 objectName: "touchdown"; \n\
239 visible: root.pressed; \n\
240 radius: "medium"; \n\
241 borderSource: "radius_pressed.sci" \n\
246 var kSubtitleLabelCode =
'Label { \n\
247 id: subtitleLabel; \n\
248 objectName: "subtitleLabel"; \n\
250 anchors.topMargin: units.dp(2); \n\
251 elide: Text.ElideRight; \n\
252 maximumLineCount: 1; \n\
253 fontSize: "x-small"; \n\
254 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
256 visible: titleLabel.visible && titleLabel.text; \n\
257 text: cardData && cardData["subtitle"] || ""; \n\
258 font.weight: Font.Light; \n\
263 var kAttributesRowCode =
'CardAttributes { \n\
264 id: attributesRow; \n\
265 objectName: "attributesRow"; \n\
268 fontScale: root.fontScale; \n\
269 model: cardData && cardData["attributes"]; \n\
275 var kSummaryLabelCode =
'Label { \n\
277 objectName: "summaryLabel"; \n\
280 left: parent.left; \n\
281 right: parent.right; \n\
282 margins: units.gu(1); \n\
285 wrapMode: Text.Wrap; \n\
286 maximumLineCount: 5; \n\
287 elide: Text.ElideRight; \n\
288 text: cardData && cardData["summary"] || ""; \n\
289 height: text ? implicitHeight : 0; \n\
290 fontSize: "small"; \n\
294 function cardString(
template, components) {
297 var templateInteractive = (
template == null ?
true : (
template[
"non-interactive"] !== undefined ? !
template[
"non-interactive"] :
true)) ?
"true" :
"false";
299 code =
'AbstractButton { \n\
301 property var components; \n\
302 property var cardData; \n\
303 property string artShapeStyle: "inset"; \n\
304 property real fontScale: 1.0; \n\
305 property var scopeStyle: null; \n\
306 property int titleAlignment: Text.AlignLeft; \n\
307 property int fixedHeaderHeight: -1; \n\
308 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
309 readonly property string title: cardData && cardData["title"] || ""; \n\
310 property bool asynchronous: true; \n\
311 property bool showHeader: true; \n\
312 implicitWidth: childrenRect.width; \n\
314 \n'.arg(templateInteractive);
316 var hasArt = components[
"art"] && components[
"art"][
"field"] ||
false;
317 var hasSummary = components[
"summary"] ||
false;
318 var artAndSummary = hasArt && hasSummary && components[
"art"][
"conciergeMode"] !==
true;
319 var isHorizontal =
template[
"card-layout"] ===
"horizontal";
320 var hasBackground = (!isHorizontal && (
template[
"card-background"] || components[
"background"] || artAndSummary)) ||
321 (hasSummary && (
template[
"card-background"] || components[
"background"]));
322 var hasTitle = components[
"title"] ||
false;
323 var hasMascot = components[
"mascot"] ||
false;
324 var hasEmblem = components[
"emblem"] && !(hasMascot &&
template[
"card-size"] ===
"small") ||
false;
325 var headerAsOverlay = hasArt &&
template &&
template[
"overlay"] ===
true && (hasTitle || hasMascot);
326 var hasSubtitle = hasTitle && components[
"subtitle"] ||
false;
327 var hasHeaderRow = hasMascot && hasTitle;
328 var hasAttributes = hasTitle && components[
"attributes"][
"field"] ||
false;
331 var templateCardBackground = (
template && typeof
template[
"card-background"] ===
"string") ?
template[
"card-background"] :
"";
332 var backgroundElements0;
333 var backgroundElements1;
334 if (
template && typeof
template[
"card-background"] ===
"object" && (
template[
"card-background"][
"type"] ===
"color" ||
template[
"card-background"][
"type"] ===
"gradient")) {
335 if (
template[
"card-background"][
"elements"][0] !== undefined) {
336 backgroundElements0 =
'"%1"'.arg(
template[
"card-background"][
"elements"][0]);
338 if (
template[
"card-background"][
"elements"][1] !== undefined) {
339 backgroundElements1 =
'"%1"'.arg(
template[
"card-background"][
"elements"][1]);
342 code += kBackgroundLoaderCode.arg(templateCardBackground).arg(backgroundElements0).arg(backgroundElements1);
346 code +=
'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
348 var widthCode, heightCode;
351 artAnchors =
'left: parent.left';
352 if (hasMascot || hasTitle) {
353 widthCode =
'height * artShape.aspect'
354 heightCode =
'headerHeight + 2 * units.gu(1)';
358 widthCode =
'height * artShape.aspect'
359 heightCode =
'units.gu(7.625)';
362 artAnchors =
'horizontalCenter: parent.horizontalCenter;';
363 widthCode =
'root.width'
364 heightCode =
'width / artShape.aspect';
367 code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
368 var fallback = components[
"art"] && components[
"art"][
"fallback"] ||
"";
369 if (fallback !==
"") {
370 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);
373 code +=
'readonly property size artShapeSize: Qt.size(-1, -1);\n'
376 if (headerAsOverlay) {
377 code += kOverlayLoaderCode;
380 var headerVerticalAnchors;
381 if (headerAsOverlay) {
382 headerVerticalAnchors =
'bottom: artShapeHolder.bottom; \n\
383 bottomMargin: units.gu(1);\n';
387 headerVerticalAnchors =
'top: artShapeHolder.top; \n\
388 topMargin: units.gu(1);\n';
390 headerVerticalAnchors =
'top: artShapeHolder.bottom; \n\
391 topMargin: units.gu(1);\n';
394 headerVerticalAnchors =
'top: parent.top; \n\
395 topMargin: units.gu(1);\n';
398 var headerLeftAnchor;
399 var headerLeftAnchorHasMargin =
false;
400 if (isHorizontal && hasArt) {
401 headerLeftAnchor =
'left: artShapeHolder.right; \n\
402 leftMargin: units.gu(1);\n';
403 headerLeftAnchorHasMargin =
true;
405 headerLeftAnchor =
'left: parent.left;\n';
408 var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary;
411 code +=
'readonly property int headerHeight: row.height;\n'
412 }
else if (hasMascot) {
413 code +=
'readonly property int headerHeight: mascotImage.height;\n'
414 }
else if (hasAttributes) {
415 if (hasTitle && hasSubtitle) {
416 code +=
'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
417 }
else if (hasTitle) {
418 code +=
'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
420 code +=
'readonly property int headerHeight: attributesRow.height;\n'
422 }
else if (hasSubtitle) {
423 code +=
'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
424 }
else if (hasTitle) {
425 code +=
'readonly property int headerHeight: titleLabel.height;\n'
427 code +=
'readonly property int headerHeight: 0;\n'
430 var mascotShapeCode =
'';
433 var useMascotShape = !hasBackground && !headerAsOverlay;
434 var mascotAnchors =
'';
436 mascotAnchors += headerLeftAnchor;
437 mascotAnchors += headerVerticalAnchors;
438 if (!headerLeftAnchorHasMargin) {
439 mascotAnchors +=
'leftMargin: units.gu(1);\n'
442 mascotAnchors =
'verticalCenter: parent.verticalCenter;'
445 if (useMascotShape) {
446 mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors);
449 var mascotImageVisible = useMascotShape ?
'false' :
'showHeader';
450 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
451 var fallback = components[
"mascot"] && components[
"mascot"][
"fallback"] ||
"";
452 if (fallback !==
"") {
453 code +=
'Connections { target: mascotImage; onStatusChanged: if (mascotImage.status === Image.Error) mascotImage.source = "%1"; } \n'.arg(fallback);
457 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")';
459 var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
460 var titleSubtitleCode =
'';
463 if (headerAsOverlay) {
464 titleColor =
'root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white")';
465 }
else if (hasSummary) {
466 titleColor =
'summary.color';
467 }
else if (hasBackground) {
468 titleColor = summaryColorWithBackground;
470 titleColor =
'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
475 var attributesAnchors;
476 var titleContainerAnchors;
477 var titleRightAnchor;
478 var titleWidth =
"undefined";
480 var extraRightAnchor =
'';
481 var extraLeftAnchor =
'';
482 if (!touchdownOnArtShape) {
483 extraRightAnchor =
'rightMargin: units.gu(1); \n';
484 extraLeftAnchor =
'leftMargin: units.gu(1); \n';
485 }
else if (headerAsOverlay && !hasEmblem) {
486 extraRightAnchor =
'rightMargin: units.gu(1); \n';
490 titleContainerAnchors =
'verticalCenter: parent.verticalCenter; ';
492 titleContainerAnchors =
'right: parent.right; ';
493 titleContainerAnchors += headerLeftAnchor;
494 titleContainerAnchors += headerVerticalAnchors;
495 if (!headerLeftAnchorHasMargin) {
496 titleContainerAnchors += extraLeftAnchor;
500 titleRightAnchor =
'right: emblemIcon.left; \n\
501 rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
503 titleRightAnchor =
'right: parent.right; \n'
504 titleRightAnchor += extraRightAnchor;
507 if (hasTitleContainer) {
509 titleAnchors = titleRightAnchor;
510 titleAnchors +=
'left: parent.left; \n\
512 subtitleAnchors =
'right: parent.right; \n\
513 left: parent.left; \n';
514 subtitleAnchors += extraRightAnchor;
516 attributesAnchors = subtitleAnchors +
'top: subtitleLabel.bottom;\n';
517 subtitleAnchors +=
'top: titleLabel.bottom;\n';
519 attributesAnchors = subtitleAnchors +
'top: titleLabel.bottom;\n';
521 }
else if (hasMascot) {
523 titleAnchors =
'verticalCenter: parent.verticalCenter;\n';
524 titleWidth =
"parent.width - x";
526 if (headerAsOverlay) {
528 titleAnchors = titleRightAnchor;
529 titleAnchors +=
'left: parent.left; \n\
530 leftMargin: units.gu(1); \n\
531 top: overlayLoader.top; \n\
532 topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight; \n';
535 titleAnchors = titleRightAnchor;
536 titleAnchors += headerLeftAnchor;
537 titleAnchors += headerVerticalAnchors;
538 if (!headerLeftAnchorHasMargin) {
539 titleAnchors += extraLeftAnchor;
542 subtitleAnchors =
'left: titleLabel.left; \n\
543 leftMargin: titleLabel.leftMargin; \n';
544 subtitleAnchors += extraRightAnchor;
547 subtitleAnchors +=
'right: parent.right; \n';
549 subtitleAnchors +=
'right: titleLabel.right; \n';
553 attributesAnchors = subtitleAnchors +
'top: subtitleLabel.bottom;\n';
554 subtitleAnchors +=
'top: titleLabel.bottom;\n';
556 attributesAnchors = subtitleAnchors +
'top: titleLabel.bottom;\n';
561 var titleLabelVisibleExtra = (headerAsOverlay ?
'&& overlayLoader.active':
'');
562 var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra).arg(titleWidth);
567 var containerCode = [];
568 var containerHeight =
'titleLabel.height';
569 containerCode.push(titleCode);
571 subtitleCode = kSubtitleLabelCode.arg(subtitleAnchors).arg(titleColor);
572 containerCode.push(subtitleCode);
573 containerHeight +=
' + subtitleLabel.height';
576 containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
579 attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
580 containerCode.push(attributesCode);
581 containerHeight +=
' + attributesRow.height';
584 if (hasTitleContainer) {
586 titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
589 titleSubtitleCode = titleCode;
591 titleSubtitleCode += subtitleCode;
594 titleSubtitleCode += attributesCode;
600 var rowCode = [mascotCode, titleSubtitleCode];
601 if (mascotShapeCode !=
'') {
602 rowCode.unshift(mascotShapeCode);
604 code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
606 code += mascotShapeCode + mascotCode + titleSubtitleCode;
610 var summaryTopAnchor;
611 if (isHorizontal && hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
612 else if (headerAsOverlay && hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
613 else if (hasHeaderRow) summaryTopAnchor =
'row.bottom';
614 else if (hasTitleContainer) summaryTopAnchor =
'headerTitleContainer.bottom';
615 else if (hasMascot) summaryTopAnchor =
'mascotImage.bottom';
616 else if (hasAttributes) summaryTopAnchor =
'attributesRow.bottom';
617 else if (hasSubtitle) summaryTopAnchor =
'subtitleLabel.bottom';
618 else if (hasTitle) summaryTopAnchor =
'titleLabel.bottom';
619 else if (hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
620 else summaryTopAnchor =
'parent.top';
624 summaryColor = summaryColorWithBackground;
626 summaryColor =
'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
629 var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ?
'anchors.margins' :
'0');
631 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
634 var touchdownAnchors;
636 touchdownAnchors =
'fill: backgroundLoader';
637 }
else if (touchdownOnArtShape) {
638 touchdownAnchors =
'fill: artShapeHolder';
640 touchdownAnchors =
'fill: root'
642 code += kTouchdownCode.arg(touchdownAnchors);
644 var implicitHeight =
'implicitHeight: ';
646 implicitHeight +=
'summary.y + summary.height + units.gu(1);\n';
647 }
else if (headerAsOverlay) {
648 implicitHeight +=
'artShapeHolder.height;\n';
649 }
else if (hasHeaderRow) {
650 implicitHeight +=
'row.y + row.height + units.gu(1);\n';
651 }
else if (hasMascot) {
652 implicitHeight +=
'mascotImage.y + mascotImage.height;\n';
653 }
else if (hasTitleContainer) {
654 implicitHeight +=
'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
655 }
else if (hasAttributes) {
656 implicitHeight +=
'attributesRow.y + attributesRow.height + units.gu(1);\n';
657 }
else if (hasSubtitle) {
658 implicitHeight +=
'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
659 }
else if (hasTitle) {
660 implicitHeight +=
'titleLabel.y + titleLabel.height + units.gu(1);\n';
662 implicitHeight +=
'artShapeHolder.height;\n';
668 code += implicitHeight +
'}\n';
673 function createCardComponent(parent,
template, components) {
674 var imports =
'import QtQuick 2.4; \n\
675 import Ubuntu.Components 1.3; \n\
676 import Ubuntu.Settings.Components 0.1; \n\
678 import Utils 0.1;\n';
679 var card = cardString(
template, components);
680 var code = imports +
'Component {\n' + card +
'}\n';
683 return Qt.createQmlObject(code, parent,
"createCardComponent");
685 console.error(
"ERROR: Invalid component created.");
686 console.error(
"Template:");
687 console.error(JSON.stringify(
template));
688 console.error(
"Components:");
689 console.error(JSON.stringify(components));
690 console.error(
"Code:");