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\
32 switch (root.backgroundShapeStyle) { \n\
33 case "inset": return UbuntuShape.Inset; \n\
34 case "shadow": return UbuntuShape.DropShadow; \n\
36 case "flat": return UbuntuShape.Flat; \n\
39 backgroundColor: getColor(0) || "white"; \n\
40 secondaryBackgroundColor: getColor(1) || backgroundColor; \n\
41 backgroundMode: UbuntuShape.VerticalGradient; \n\
42 anchors.fill: parent; \n\
43 source: backgroundImage.source ? backgroundImage : null; \n\
44 property real luminance: Style.luminance(backgroundColor); \n\
45 property Image backgroundImage: Image { \n\
46 objectName: "backgroundImage"; \n\
48 if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\
52 function getColor(index) { \n\
53 if (cardData && typeof cardData["background"] === "object" \n\
54 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\
55 return cardData["background"]["elements"][index]; \n\
56 } else return index === 0 ? %2 : %3; \n\
64 var kArtShapeHolderCode =
'Item { \n\
65 id: artShapeHolder; \n\
66 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
67 width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
70 id: artShapeLoader; \n\
71 objectName: "artShapeLoader"; \n\
72 active: cardData && cardData["art"] || false; \n\
73 asynchronous: root.asynchronous; \n\
74 visible: status == Loader.Ready; \n\
75 sourceComponent: Item { \n\
77 objectName: "artShape"; \n\
78 readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
79 visible: image.status == Image.Ready; \n\
80 readonly property alias image: artImage; \n\
81 ShaderEffectSource { \n\
82 id: artShapeSource; \n\
83 sourceItem: artImage; \n\
84 anchors.centerIn: parent; \n\
87 hideSource: doShapeItem; \n\
90 anchors.fill: parent; \n\
91 visible: artShape.doShapeItem; \n\
92 sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; \n\
94 id: artShapeShapeComponent; \n\
96 source: artShapeSource; \n\
97 sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
100 switch (root.artShapeStyle) { \n\
101 case "inset": return UbuntuShape.Inset; \n\
102 case "shadow": return UbuntuShape.DropShadow; \n\
104 case "flat": return UbuntuShape.Flat; \n\
110 id: artShapeIconComponent; \n\
111 ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; } \n\
114 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
115 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
116 Component.onCompleted: { updateWidthHeightBindings(); } \n\
117 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
118 function updateWidthHeightBindings() { \n\
119 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
120 width = root.fixedArtShapeSize.width; \n\
121 height = root.fixedArtShapeSize.height; \n\
123 width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); \n\
124 height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); \n\
127 CroppedImageMinimumSourceSize { \n\
129 objectName: "artImage"; \n\
130 source: cardData && cardData["art"] || ""; \n\
131 asynchronous: root.asynchronous; \n\
142 var kAudioButtonCode =
'AbstractButton { \n\
144 anchors.fill: %1; \n\
147 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || ""; \n\
149 anchors.fill: parent; \n\
150 visible: parent.pressed; \n\
151 radius: "medium"; \n\
154 anchors.fill: parent; \n\
155 anchors.margins: parent.height > units.gu(5) ? units.gu(2) : 0; \n\
157 name: DashAudioPlayer.playing && AudioUrlComparer.compare(parent.source, DashAudioPlayer.currentSource) ? "media-playback-pause" : "media-playback-start"; \n\
160 if (AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)) { \n\
161 if (DashAudioPlayer.playing) { \n\
162 DashAudioPlayer.pause(); \n\
164 DashAudioPlayer.play(); \n\
167 var playlist = (cardData["quickPreviewData"] && cardData["quickPreviewData"]["playlist"]) || null; \n\
168 DashAudioPlayer.playSource(source, playlist); \n\
171 onPressAndHold: { \n\
172 root.pressAndHold(); \n\
176 var kOverlayLoaderCode =
'Loader { \n\
177 id: overlayLoader; \n\
178 readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
179 anchors.fill: artShapeHolder; \n\
180 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
181 asynchronous: root.asynchronous; \n\
182 visible: showHeader && status == Loader.Ready; \n\
183 sourceComponent: UbuntuShapeOverlay { \n\
185 property real luminance: Style.luminance(overlayColor); \n\
186 aspect: UbuntuShape.Flat; \n\
187 radius: "medium"; \n\
188 overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
189 overlayRect: Qt.rect(0, 1 - overlayLoader.overlayHeight / height, 1, 1); \n\
194 function kHeaderRowCodeGenerator() {
195 var kHeaderRowCodeTemplate =
'Row { \n\
197 objectName: "outerRow"; \n\
198 property real margins: units.gu(1); \n\
199 spacing: margins; \n\
200 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
202 anchors.right: parent.right; \n\
203 anchors.margins: margins; \n\
204 anchors.rightMargin: 0; \n\
209 var args = Array.prototype.slice.call(arguments);
210 var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(
',\n'));
215 function kHeaderContainerCodeGenerator() {
216 var headerContainerCodeTemplate =
'Item { \n\
217 id: headerTitleContainer; \n\
219 width: parent.width - x; \n\
220 implicitHeight: %2; \n\
225 var args = Array.prototype.slice.call(arguments);
226 var code = headerContainerCodeTemplate.arg(args.shift()).arg(args.shift()).arg(args.join(
',\n'));
231 var kMascotShapeLoaderCode =
'Loader { \n\
232 id: mascotShapeLoader; \n\
233 objectName: "mascotShapeLoader"; \n\
234 asynchronous: root.asynchronous; \n\
235 active: mascotImage.status === Image.Ready; \n\
236 visible: showHeader && active && status == Loader.Ready; \n\
237 width: units.gu(6); \n\
238 height: units.gu(5.625); \n\
239 sourceComponent: UbuntuShape { image: mascotImage } \n\
245 var kMascotImageCode =
'CroppedImageMinimumSourceSize { \n\
247 objectName: "mascotImage"; \n\
249 source: cardData && cardData["mascot"] || ""; \n\
250 width: units.gu(6); \n\
251 height: units.gu(5.625); \n\
252 horizontalAlignment: Image.AlignHCenter; \n\
253 verticalAlignment: Image.AlignVCenter; \n\
261 var kTitleLabelCode =
'Label { \n\
263 objectName: "titleLabel"; \n\
265 elide: Text.ElideRight; \n\
266 fontSize: "small"; \n\
267 wrapMode: Text.Wrap; \n\
268 maximumLineCount: 2; \n\
269 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
271 visible: showHeader %3; \n\
273 text: root.title; \n\
274 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; \n\
275 horizontalAlignment: root.titleAlignment; \n\
282 var kEmblemIconCode =
'Icon { \n\
284 objectName: "emblemIcon"; \n\
286 bottom: titleLabel.baseline; \n\
287 right: parent.right; \n\
290 source: cardData && cardData["emblem"] || ""; \n\
292 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
293 width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; \n\
297 var kTouchdownCode =
'UbuntuShape { \n\
299 objectName: "touchdown"; \n\
301 visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; \n\
302 radius: "medium"; \n\
303 borderSource: "radius_pressed.sci" \n\
308 var kSubtitleLabelCode =
'Label { \n\
309 id: subtitleLabel; \n\
310 objectName: "subtitleLabel"; \n\
312 anchors.topMargin: units.dp(2); \n\
313 elide: Text.ElideRight; \n\
314 maximumLineCount: 1; \n\
315 fontSize: "x-small"; \n\
316 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
318 visible: titleLabel.visible && titleLabel.text; \n\
319 text: cardData && cardData["subtitle"] || ""; \n\
320 font.weight: Font.Light; \n\
325 var kAttributesRowCode =
'CardAttributes { \n\
326 id: attributesRow; \n\
327 objectName: "attributesRow"; \n\
330 fontScale: root.fontScale; \n\
331 model: cardData && cardData["attributes"]; \n\
337 var kSummaryLabelCode =
'Label { \n\
339 objectName: "summaryLabel"; \n\
342 left: parent.left; \n\
343 right: parent.right; \n\
344 margins: units.gu(1); \n\
347 wrapMode: Text.Wrap; \n\
348 maximumLineCount: 5; \n\
349 elide: Text.ElideRight; \n\
350 text: cardData && cardData["summary"] || ""; \n\
351 height: text ? implicitHeight : 0; \n\
352 fontSize: "small"; \n\
359 var kAudioProgressBarCode =
'CardAudioProgress { \n\
360 id: audioProgressBar; \n\
361 duration: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["duration"]) || 0; \n\
362 source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || ""; \n\
366 right: parent.right; \n\
367 margins: units.gu(1); \n\
372 function cardString(
template, components) {
375 var templateInteractive = (
template == null ?
true : (
template[
"non-interactive"] !== undefined ? !
template[
"non-interactive"] :
true)) ?
"true" :
"false";
377 code =
'AbstractButton { \n\
379 property var components; \n\
380 property var cardData; \n\
381 property string artShapeStyle: "inset"; \n\
382 property string backgroundShapeStyle: "inset"; \n\
383 property real fontScale: 1.0; \n\
384 property var scopeStyle: null; \n\
385 property int titleAlignment: Text.AlignLeft; \n\
386 property int fixedHeaderHeight: -1; \n\
387 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
388 readonly property string title: cardData && cardData["title"] || ""; \n\
389 property bool asynchronous: true; \n\
390 property bool showHeader: true; \n\
391 implicitWidth: childrenRect.width; \n\
393 \n'.arg(templateInteractive);
395 var hasArt = components[
"art"] && components[
"art"][
"field"] ||
false;
396 var hasSummary = components[
"summary"] ||
false;
397 var artAndSummary = hasArt && hasSummary && components[
"art"][
"conciergeMode"] !==
true;
398 var isHorizontal =
template[
"card-layout"] ===
"horizontal";
399 var hasBackground = (!isHorizontal && (
template[
"card-background"] || components[
"background"] || artAndSummary)) ||
400 (hasSummary && (
template[
"card-background"] || components[
"background"]));
401 var hasTitle = components[
"title"] ||
false;
402 var hasMascot = components[
"mascot"] ||
false;
403 var hasEmblem = components[
"emblem"] && !(hasMascot &&
template[
"card-size"] ===
"small") ||
false;
404 var headerAsOverlay = hasArt &&
template &&
template[
"overlay"] ===
true && (hasTitle || hasMascot);
405 var hasSubtitle = hasTitle && components[
"subtitle"] ||
false;
406 var hasHeaderRow = hasMascot && hasTitle;
407 var hasAttributes = hasTitle && components[
"attributes"] && components[
"attributes"][
"field"] ||
false;
408 var isAudio =
template[
"quick-preview-type"] ===
"audio";
414 if (hasSummary) isAudio =
false;
415 if (!isHorizontal) isAudio =
false;
416 if (hasMascot) isAudio =
false;
417 if (hasEmblem) isAudio =
false;
418 if (headerAsOverlay) isAudio =
false;
419 if (hasAttributes) isAudio =
false;
423 var templateCardBackground = (
template && typeof
template[
"card-background"] ===
"string") ?
template[
"card-background"] :
"";
424 var backgroundElements0;
425 var backgroundElements1;
426 if (
template && typeof
template[
"card-background"] ===
"object" && (
template[
"card-background"][
"type"] ===
"color" ||
template[
"card-background"][
"type"] ===
"gradient")) {
427 if (
template[
"card-background"][
"elements"][0] !== undefined) {
428 backgroundElements0 =
'"%1"'.arg(
template[
"card-background"][
"elements"][0]);
430 if (
template[
"card-background"][
"elements"][1] !== undefined) {
431 backgroundElements1 =
'"%1"'.arg(
template[
"card-background"][
"elements"][1]);
434 code += kBackgroundLoaderCode.arg(templateCardBackground).arg(backgroundElements0).arg(backgroundElements1);
438 code +=
'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
440 var widthCode, heightCode;
443 artAnchors =
'left: parent.left';
444 if (hasMascot || hasTitle) {
445 widthCode =
'height * artShape.aspect'
446 heightCode =
'headerHeight + 2 * units.gu(1)';
450 widthCode =
'height * artShape.aspect'
451 heightCode =
'units.gu(7.625)';
454 artAnchors =
'horizontalCenter: parent.horizontalCenter;';
455 widthCode =
'root.width'
456 heightCode =
'width / artShape.aspect';
459 code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
460 var fallback = components[
"art"] && components[
"art"][
"fallback"] ||
"";
461 if (fallback !==
"") {
462 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);
465 code +=
'readonly property size artShapeSize: Qt.size(-1, -1);\n'
468 if (headerAsOverlay) {
469 code += kOverlayLoaderCode;
472 var headerVerticalAnchors;
473 if (headerAsOverlay) {
474 headerVerticalAnchors =
'bottom: artShapeHolder.bottom; \n\
475 bottomMargin: units.gu(1);\n';
479 headerVerticalAnchors =
'top: artShapeHolder.top; \n\
480 topMargin: units.gu(1);\n';
482 headerVerticalAnchors =
'top: artShapeHolder.bottom; \n\
483 topMargin: units.gu(1);\n';
486 headerVerticalAnchors =
'top: parent.top; \n\
487 topMargin: units.gu(1);\n';
491 var headerLeftAnchor;
492 var headerLeftAnchorHasMargin =
false;
493 if (isHorizontal && hasArt) {
494 headerLeftAnchor =
'left: artShapeHolder.right; \n\
495 leftMargin: units.gu(1);\n';
496 headerLeftAnchorHasMargin =
true;
497 }
else if (isHorizontal && isAudio) {
498 headerLeftAnchor =
'left: audioButton.right; \n\
499 leftMargin: units.gu(1);\n';
500 headerLeftAnchorHasMargin =
true;
502 headerLeftAnchor =
'left: parent.left;\n';
505 var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary && !isAudio;
508 code +=
'readonly property int headerHeight: row.height;\n'
509 }
else if (hasMascot) {
510 code +=
'readonly property int headerHeight: mascotImage.height;\n'
511 }
else if (hasAttributes) {
512 if (hasTitle && hasSubtitle) {
513 code +=
'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
514 }
else if (hasTitle) {
515 code +=
'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
517 code +=
'readonly property int headerHeight: attributesRow.height;\n'
519 }
else if (isAudio) {
521 code +=
'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + audioProgressBar.height + audioProgressBar.anchors.topMargin;\n'
522 }
else if (hasTitle) {
523 code +=
'readonly property int headerHeight: titleLabel.height + audioProgressBar.height + audioProgressBar.anchors.topMargin;\n'
525 code +=
'readonly property int headerHeight: audioProgressBar.height;\n'
527 }
else if (hasSubtitle) {
528 code +=
'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
529 }
else if (hasTitle) {
530 code +=
'readonly property int headerHeight: titleLabel.height;\n'
532 code +=
'readonly property int headerHeight: 0;\n'
535 var mascotShapeCode =
'';
538 var useMascotShape = !hasBackground && !headerAsOverlay;
539 var mascotAnchors =
'';
541 mascotAnchors += headerLeftAnchor;
542 mascotAnchors += headerVerticalAnchors;
543 if (!headerLeftAnchorHasMargin) {
544 mascotAnchors +=
'leftMargin: units.gu(1);\n'
547 mascotAnchors =
'verticalCenter: parent.verticalCenter;'
550 if (useMascotShape) {
551 mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors);
554 var mascotImageVisible = useMascotShape ?
'false' :
'showHeader';
555 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
556 var fallback = components[
"mascot"] && components[
"mascot"][
"fallback"] ||
"";
557 if (fallback !==
"") {
558 code +=
'Connections { target: mascotImage; onStatusChanged: if (mascotImage.status === Image.Error) mascotImage.source = "%1"; } \n'.arg(fallback);
562 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")';
564 var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
565 var titleSubtitleCode =
'';
568 if (headerAsOverlay) {
569 titleColor =
'root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white")';
570 }
else if (hasSummary) {
571 titleColor =
'summary.color';
572 }
else if (hasBackground) {
573 titleColor = summaryColorWithBackground;
575 titleColor =
'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
580 var attributesAnchors;
581 var titleContainerAnchors;
582 var titleRightAnchor;
583 var titleWidth =
"undefined";
585 var extraRightAnchor =
'';
586 var extraLeftAnchor =
'';
587 if (!touchdownOnArtShape) {
588 extraRightAnchor =
'rightMargin: units.gu(1); \n';
589 extraLeftAnchor =
'leftMargin: units.gu(1); \n';
590 }
else if (headerAsOverlay && !hasEmblem) {
591 extraRightAnchor =
'rightMargin: units.gu(1); \n';
595 titleContainerAnchors =
'verticalCenter: parent.verticalCenter; ';
597 titleContainerAnchors =
'right: parent.right; ';
598 titleContainerAnchors += headerLeftAnchor;
599 titleContainerAnchors += headerVerticalAnchors;
600 if (!headerLeftAnchorHasMargin) {
601 titleContainerAnchors += extraLeftAnchor;
605 titleRightAnchor =
'right: emblemIcon.left; \n\
606 rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
608 titleRightAnchor =
'right: parent.right; \n'
609 titleRightAnchor += extraRightAnchor;
612 if (hasTitleContainer) {
614 titleAnchors = titleRightAnchor;
615 titleAnchors +=
'left: parent.left; \n\
617 subtitleAnchors =
'right: parent.right; \n\
618 left: parent.left; \n';
619 subtitleAnchors += extraRightAnchor;
621 attributesAnchors = subtitleAnchors +
'top: subtitleLabel.bottom;\n';
622 subtitleAnchors +=
'top: titleLabel.bottom;\n';
624 attributesAnchors = subtitleAnchors +
'top: titleLabel.bottom;\n';
626 }
else if (hasMascot) {
628 titleAnchors =
'verticalCenter: parent.verticalCenter;\n';
629 titleWidth =
"parent.width - x";
631 if (headerAsOverlay) {
633 titleAnchors = titleRightAnchor;
634 titleAnchors +=
'left: parent.left; \n\
635 leftMargin: units.gu(1); \n\
636 top: overlayLoader.top; \n\
637 topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight; \n';
640 titleAnchors = titleRightAnchor;
641 titleAnchors += headerLeftAnchor;
642 titleAnchors += headerVerticalAnchors;
643 if (!headerLeftAnchorHasMargin) {
644 titleAnchors += extraLeftAnchor;
647 subtitleAnchors =
'left: titleLabel.left; \n\
648 leftMargin: titleLabel.leftMargin; \n';
649 subtitleAnchors += extraRightAnchor;
652 subtitleAnchors +=
'right: parent.right; \n';
654 subtitleAnchors +=
'right: titleLabel.right; \n';
658 attributesAnchors = subtitleAnchors +
'top: subtitleLabel.bottom;\n';
659 subtitleAnchors +=
'top: titleLabel.bottom;\n';
661 attributesAnchors = subtitleAnchors +
'top: titleLabel.bottom;\n';
666 var titleLabelVisibleExtra = (headerAsOverlay ?
'&& overlayLoader.active':
'');
667 var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra).arg(titleWidth);
672 var containerCode = [];
673 var containerHeight =
'titleLabel.height';
674 containerCode.push(titleCode);
676 subtitleCode = kSubtitleLabelCode.arg(subtitleAnchors).arg(titleColor);
677 containerCode.push(subtitleCode);
678 containerHeight +=
' + subtitleLabel.height';
681 containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
684 attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
685 containerCode.push(attributesCode);
686 containerHeight +=
' + attributesRow.height';
689 if (hasTitleContainer) {
691 titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
694 titleSubtitleCode = titleCode;
696 titleSubtitleCode += subtitleCode;
699 titleSubtitleCode += attributesCode;
705 var rowCode = [mascotCode, titleSubtitleCode];
706 if (mascotShapeCode !=
'') {
707 rowCode.unshift(mascotShapeCode);
709 code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
711 code += mascotShapeCode + mascotCode + titleSubtitleCode;
715 var audioProgressBarLeftAnchor =
'audioButton.right';
716 var audioProgressBarBottomAnchor =
'audioButton.bottom';
717 var audioProgressBarTextColor =
'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
719 code += kAudioProgressBarCode.arg(audioProgressBarBottomAnchor)
720 .arg(audioProgressBarLeftAnchor)
721 .arg(audioProgressBarTextColor);
723 var audioButtonAnchorsFill;
724 var audioButtonWidth;
725 var audioButtonHeight;
727 audioButtonAnchorsFill =
'artShapeHolder';
728 audioButtonWidth =
'undefined';
729 audioButtonHeight =
'undefined';
731 audioButtonAnchorsFill =
'undefined';
732 audioButtonWidth =
'height';
733 audioButtonHeight =
'(root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1)';
735 code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight);
739 var summaryTopAnchor;
740 if (isHorizontal && hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
741 else if (headerAsOverlay && hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
742 else if (hasHeaderRow) summaryTopAnchor =
'row.bottom';
743 else if (hasTitleContainer) summaryTopAnchor =
'headerTitleContainer.bottom';
744 else if (hasMascot) summaryTopAnchor =
'mascotImage.bottom';
745 else if (hasAttributes) summaryTopAnchor =
'attributesRow.bottom';
746 else if (hasSubtitle) summaryTopAnchor =
'subtitleLabel.bottom';
747 else if (hasTitle) summaryTopAnchor =
'titleLabel.bottom';
748 else if (hasArt) summaryTopAnchor =
'artShapeHolder.bottom';
749 else summaryTopAnchor =
'parent.top';
753 summaryColor = summaryColorWithBackground;
755 summaryColor =
'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
758 var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ?
'anchors.margins' :
'0');
760 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
763 var touchdownAnchors;
765 touchdownAnchors =
'fill: backgroundLoader';
766 }
else if (touchdownOnArtShape) {
767 touchdownAnchors =
'fill: artShapeHolder';
769 touchdownAnchors =
'fill: root'
771 code += kTouchdownCode.arg(touchdownAnchors);
773 var implicitHeight =
'implicitHeight: ';
775 implicitHeight +=
'summary.y + summary.height + units.gu(1);\n';
776 }
else if (isAudio) {
777 implicitHeight +=
'audioButton.height;\n';
778 }
else if (headerAsOverlay) {
779 implicitHeight +=
'artShapeHolder.height;\n';
780 }
else if (hasHeaderRow) {
781 implicitHeight +=
'row.y + row.height + units.gu(1);\n';
782 }
else if (hasMascot) {
783 implicitHeight +=
'mascotImage.y + mascotImage.height;\n';
784 }
else if (hasTitleContainer) {
785 implicitHeight +=
'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
786 }
else if (hasAttributes) {
787 implicitHeight +=
'attributesRow.y + attributesRow.height + units.gu(1);\n';
788 }
else if (hasSubtitle) {
789 implicitHeight +=
'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
790 }
else if (hasTitle) {
791 implicitHeight +=
'titleLabel.y + titleLabel.height + units.gu(1);\n';
793 implicitHeight +=
'artShapeHolder.height;\n';
799 code += implicitHeight +
'}\n';
804 function createCardComponent(parent,
template, components) {
805 var imports =
'import QtQuick 2.4; \n\
806 import Ubuntu.Components 1.3; \n\
807 import Ubuntu.Settings.Components 0.1; \n\
809 import Utils 0.1;\n';
810 var card = cardString(
template, components);
811 var code = imports +
'Component {\n' + card +
'}\n';
814 return Qt.createQmlObject(code, parent,
"createCardComponent");
816 console.error(
"ERROR: Invalid component created.");
817 console.error(
"Template:");
818 console.error(JSON.stringify(
template));
819 console.error(
"Components:");
820 console.error(JSON.stringify(components));
821 console.error(
"Code:");