2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19var kBackgroundLoaderCode = 'Loader {\n\
20 id: backgroundLoader; \n\
21 objectName: "backgroundLoader"; \n\
22 anchors.fill: parent; \n\
23 asynchronous: root.asynchronous; \n\
24 visible: status == Loader.Ready; \n\
25 sourceComponent: UbuntuShape { \n\
26 objectName: "background"; \n\
28 color: getColor(0) || "white"; \n\
29 gradientColor: getColor(1) || color; \n\
30 anchors.fill: parent; \n\
31 image: backgroundImage.source ? backgroundImage : null; \n\
32 property real luminance: Style.luminance(color); \n\
33 property Image backgroundImage: Image { \n\
34 objectName: "backgroundImage"; \n\
36 if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\
37 else if (template && typeof template["card-background"] === "string") return template["card-background"]; \n\
41 function getColor(index) { \n\
42 if (cardData && typeof cardData["background"] === "object" \n\
43 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\
44 return cardData["background"]["elements"][index]; \n\
45 } else if (template && typeof template["card-background"] === "object" \n\
46 && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) { \n\
47 return template["card-background"]["elements"][index]; \n\
48 } else return undefined; \n\
53// %1 is used as anchors of artShapeHolder
54// %2 is used as image width
55// %3 is used as image height
56var 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: UbuntuShape { \n\
69 objectName: "artShape"; \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\
73 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
74 Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
75 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
76 function updateWidthHeightBindings() { \n\
77 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
78 width = root.fixedArtShapeSize.width; \n\
79 height = root.fixedArtShapeSize.height; \n\
81 width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); \n\
82 height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); \n\
86 objectName: "artImage"; \n\
87 property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
88 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; } \n\
90 asynchronous: root.asynchronous; \n\
91 fillMode: Image.PreserveAspectCrop; \n\
99var kOverlayLoaderCode = 'Loader { \n\
100 id: overlayLoader; \n\
102 left: artShapeHolder.left; \n\
103 right: artShapeHolder.right; \n\
104 bottom: artShapeHolder.bottom; \n\
106 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
107 asynchronous: root.asynchronous; \n\
108 visible: showHeader && status == Loader.Ready; \n\
109 sourceComponent: ShaderEffect { \n\
111 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
112 property real luminance: Style.luminance(overlayColor); \n\
113 property color overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
114 property var source: ShaderEffectSource { \n\
115 id: shaderSource; \n\
116 sourceItem: artShapeLoader.item; \n\
117 onVisibleChanged: if (visible) scheduleUpdate(); \n\
119 sourceRect: Qt.rect(0, artShapeLoader.height - overlay.height, artShapeLoader.width, overlay.height); \n\
122 uniform highp mat4 qt_Matrix; \n\
123 attribute highp vec4 qt_Vertex; \n\
124 attribute highp vec2 qt_MultiTexCoord0; \n\
125 varying highp vec2 coord; \n\
127 coord = qt_MultiTexCoord0; \n\
128 gl_Position = qt_Matrix * qt_Vertex; \n\
130 fragmentShader: " \n\
131 varying highp vec2 coord; \n\
132 uniform sampler2D source; \n\
133 uniform lowp float qt_Opacity; \n\
134 uniform highp vec4 overlayColor; \n\
136 lowp vec4 tex = texture2D(source, coord); \n\
137 gl_FragColor = vec4(overlayColor.r, overlayColor.g, overlayColor.b, 1) * qt_Opacity * overlayColor.a * tex.a; \n\
142// multiple row version of HeaderRowCode
143function kHeaderRowCodeGenerator() {
144var kHeaderRowCodeTemplate = 'Row { \n\
146 objectName: "outerRow"; \n\
147 property real margins: units.gu(1); \n\
148 spacing: margins; \n\
149 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
151 anchors.right: parent.right; \n\
152 anchors.margins: margins; \n\
153 anchors.rightMargin: 0; \n\
158 var args = Array.prototype.slice.call(arguments);
159 var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(',\n'));
163// multiple item version of kHeaderContainerCode
164function kHeaderContainerCodeGenerator() {
165 var headerContainerCodeTemplate = 'Item { \n\
166 id: headerTitleContainer; \n\
168 width: parent.width - x; \n\
169 implicitHeight: %2; \n\
174 var args = Array.prototype.slice.call(arguments);
175 var code = headerContainerCodeTemplate.arg(args.shift()).arg(args.shift()).arg(args.join(',\n'));
179// %1 is used as anchors of mascotShapeLoader
180var kMascotShapeLoaderCode = 'Loader { \n\
181 id: mascotShapeLoader; \n\
182 objectName: "mascotShapeLoader"; \n\
183 asynchronous: root.asynchronous; \n\
184 active: mascotImage.status === Image.Ready; \n\
185 visible: showHeader && active && status == Loader.Ready; \n\
186 width: units.gu(6); \n\
187 height: units.gu(5.625); \n\
188 sourceComponent: UbuntuShape { image: mascotImage } \n\
192// %1 is used as anchors of mascotImage
193// %2 is used as visible of mascotImage
194var kMascotImageCode = 'Image { \n\
196 objectName: "mascotImage"; \n\
198 readonly property int maxSize: Math.max(width, height) * 4; \n\
199 property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
200 source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; } \n\
201 width: units.gu(6); \n\
202 height: units.gu(5.625); \n\
203 sourceSize { width: maxSize; height: maxSize } \n\
204 fillMode: Image.PreserveAspectCrop; \n\
205 horizontalAlignment: Image.AlignHCenter; \n\
206 verticalAlignment: Image.AlignVCenter; \n\
210// %1 is used as anchors of titleLabel
211// %2 is used as color of titleLabel
212// %3 is used as extra condition for visible of titleLabel
213var kTitleLabelCode = 'Label { \n\
215 objectName: "titleLabel"; \n\
217 elide: Text.ElideRight; \n\
218 fontSize: "small"; \n\
219 wrapMode: Text.Wrap; \n\
220 maximumLineCount: 2; \n\
221 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
223 visible: showHeader %3; \n\
224 text: root.title; \n\
225 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; \n\
226 horizontalAlignment: root.headerAlignment; \n\
229// %1 is used as extra anchors of emblemIcon
230// %2 is used as color of emblemIcon
231var kEmblemIconCode = 'Icon { \n\
233 objectName: "emblemIcon"; \n\
235 bottom: titleLabel.baseline; \n\
236 right: parent.right; \n\
239 source: cardData && cardData["emblem"] || ""; \n\
242 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
245// %1 is used as anchors of touchdown effect
246var kTouchdownCode = 'UbuntuShape { \n\
248 objectName: "touchdown"; \n\
250 visible: root.pressed; \n\
251 radius: "medium"; \n\
252 borderSource: "radius_pressed.sci" \n\
255// %1 is used as anchors of subtitleLabel
256// %2 is used as color of subtitleLabel
257var kSubtitleLabelCode = 'Label { \n\
258 id: subtitleLabel; \n\
259 objectName: "subtitleLabel"; \n\
261 anchors.topMargin: units.dp(2); \n\
262 elide: Text.ElideRight; \n\
263 fontSize: "small"; \n\
264 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
266 visible: titleLabel.visible && titleLabel.text; \n\
267 text: cardData && cardData["subtitle"] || ""; \n\
268 font.weight: Font.Light; \n\
269 horizontalAlignment: root.headerAlignment; \n\
272// %1 is used as anchors of attributesRow
273// %2 is used as color of attributesRow
274var kAttributesRowCode = 'CardAttributes { \n\
275 id: attributesRow; \n\
276 objectName: "attributesRow"; \n\
279 fontScale: root.fontScale; \n\
280 model: cardData && cardData["attributes"]; \n\
283// %1 is used as top anchor of summary
284// %2 is used as topMargin anchor of summary
285// %3 is used as color of summary
286var kSummaryLabelCode = 'Label { \n\
288 objectName: "summaryLabel"; \n\
291 left: parent.left; \n\
292 right: parent.right; \n\
293 margins: units.gu(1); \n\
296 wrapMode: Text.Wrap; \n\
297 maximumLineCount: 5; \n\
298 elide: Text.ElideRight; \n\
299 text: cardData && cardData["summary"] || ""; \n\
300 height: text ? implicitHeight : 0; \n\
301 fontSize: "small"; \n\
305function cardString(template, components) {
307 code = 'AbstractButton { \n\
309 property var template; \n\
310 property var components; \n\
311 property var cardData; \n\
312 property var artShapeBorderSource: undefined; \n\
313 property real fontScale: 1.0; \n\
314 property var scopeStyle: null; \n\
315 property int headerAlignment: Text.AlignLeft; \n\
316 property int fixedHeaderHeight: -1; \n\
317 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
318 readonly property string title: cardData && cardData["title"] || ""; \n\
319 property bool asynchronous: true; \n\
320 property bool showHeader: true; \n\
321 implicitWidth: childrenRect.width; \n';
323 var hasArt = components["art"] && components["art"]["field"] || false;
324 var hasSummary = components["summary"] || false;
325 var artAndSummary = hasArt && hasSummary;
326 var isHorizontal = template["card-layout"] === "horizontal";
327 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);
328 var hasTitle = components["title"] || false;
329 var hasMascot = components["mascot"] || false;
330 var hasEmblem = components["emblem"] && !(hasMascot && template["card-size"] === "small") || false;
331 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
332 var hasSubtitle = hasTitle && components["subtitle"] || false;
333 var hasHeaderRow = hasMascot && hasTitle;
334 var hasAttributes = hasTitle && components["attributes"]["field"] || false;
337 code += kBackgroundLoaderCode;
341 code += 'onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; } \n';
342 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
344 var widthCode, heightCode;
347 artAnchors = 'left: parent.left';
348 if (hasMascot || hasTitle) {
349 widthCode = 'height * artShape.aspect'
350 heightCode = 'headerHeight + 2 * units.gu(1)';
352 // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
353 // So we define a "random" height of the image height + 2 gu for the margins
354 widthCode = 'height * artShape.aspect'
355 heightCode = 'units.gu(7.625)';
358 artAnchors = 'horizontalCenter: parent.horizontalCenter;';
359 widthCode = 'root.width'
360 heightCode = 'width / artShape.aspect';
363 code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
365 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
368 if (headerAsOverlay) {
369 code += kOverlayLoaderCode;
372 var headerVerticalAnchors;
373 if (headerAsOverlay) {
374 headerVerticalAnchors = 'bottom: artShapeHolder.bottom; \n\
375 bottomMargin: units.gu(1);\n';
379 headerVerticalAnchors = 'top: artShapeHolder.top; \n\
380 topMargin: units.gu(1);\n';
382 headerVerticalAnchors = 'top: artShapeHolder.bottom; \n\
383 topMargin: units.gu(1);\n';
386 headerVerticalAnchors = 'top: parent.top; \n\
387 topMargin: units.gu(1);\n';
390 var headerLeftAnchor;
391 var headerLeftAnchorHasMargin = false;
392 if (isHorizontal && hasArt) {
393 headerLeftAnchor = 'left: artShapeHolder.right; \n\
394 leftMargin: units.gu(1);\n';
395 headerLeftAnchorHasMargin = true;
397 headerLeftAnchor = 'left: parent.left;\n';
400 var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary;
403 code += 'readonly property int headerHeight: row.height;\n'
404 } else if (hasMascot) {
405 code += 'readonly property int headerHeight: mascotImage.height;\n'
406 } else if (hasAttributes) {
407 if (hasTitle && hasSubtitle) {
408 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
409 } else if (hasTitle) {
410 code += 'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
412 code += 'readonly property int headerHeight: attributesRow.height;\n'
414 } else if (hasSubtitle) {
415 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
416 } else if (hasTitle) {
417 code += 'readonly property int headerHeight: titleLabel.height;\n'
419 code += 'readonly property int headerHeight: 0;\n'
422 var mascotShapeCode = '';
425 var useMascotShape = !hasBackground && !headerAsOverlay;
426 var mascotAnchors = '';
428 mascotAnchors += headerLeftAnchor;
429 mascotAnchors += headerVerticalAnchors;
430 if (!headerLeftAnchorHasMargin) {
431 mascotAnchors += 'leftMargin: units.gu(1);\n'
434 mascotAnchors = 'verticalCenter: parent.verticalCenter;'
437 if (useMascotShape) {
438 mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors);
441 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
442 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
445 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")';
447 var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
448 var titleSubtitleCode = '';
451 if (headerAsOverlay) {
452 titleColor = 'root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white")';
453 } else if (hasSummary) {
454 titleColor = 'summary.color';
455 } else if (hasBackground) {
456 titleColor = summaryColorWithBackground;
458 titleColor = 'root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText';
463 var attributesAnchors;
464 var titleContainerAnchors;
465 var titleRightAnchor;
467 var extraRightAnchor = '';
468 var extraLeftAnchor = '';
469 if (!touchdownOnArtShape) {
470 extraRightAnchor = 'rightMargin: units.gu(1); \n';
471 extraLeftAnchor = 'leftMargin: units.gu(1); \n';
472 } else if (headerAsOverlay && !hasEmblem) {
473 extraRightAnchor = 'rightMargin: units.gu(1); \n';
477 titleContainerAnchors = 'verticalCenter: parent.verticalCenter; ';
479 titleContainerAnchors = 'right: parent.right; ';
480 titleContainerAnchors += headerLeftAnchor;
481 titleContainerAnchors += headerVerticalAnchors;
482 if (!headerLeftAnchorHasMargin) {
483 titleContainerAnchors += extraLeftAnchor;
487 titleRightAnchor = 'right: emblemIcon.left; \n\
488 rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
490 titleRightAnchor = 'right: parent.right; \n'
491 titleRightAnchor += extraRightAnchor;
494 if (hasTitleContainer) {
495 // Using headerTitleContainer
496 titleAnchors = titleRightAnchor;
497 titleAnchors += 'left: parent.left; \n\
499 subtitleAnchors = 'right: parent.right; \n\
500 left: parent.left; \n';
501 subtitleAnchors += extraRightAnchor;
503 attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
504 subtitleAnchors += 'top: titleLabel.bottom;\n';
506 attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
508 } else if (hasMascot) {
509 // Using row + titleContainer
510 titleAnchors = 'verticalCenter: parent.verticalCenter;\n';
512 if (headerAsOverlay) {
513 // Using anchors to the overlay
514 titleAnchors = titleRightAnchor;
515 titleAnchors += 'left: parent.left; \n\
516 leftMargin: units.gu(1); \n\
517 top: overlayLoader.top; \n\
518 topMargin: units.gu(1);\n';
520 // Using anchors to the mascot/parent
521 titleAnchors = titleRightAnchor;
522 titleAnchors += headerLeftAnchor;
523 titleAnchors += headerVerticalAnchors;
524 if (!headerLeftAnchorHasMargin) {
525 titleAnchors += extraLeftAnchor;
528 subtitleAnchors = 'left: titleLabel.left; \n\
529 leftMargin: titleLabel.leftMargin; \n';
530 subtitleAnchors += extraRightAnchor;
533 subtitleAnchors += 'right: parent.right; \n';
535 subtitleAnchors += 'right: titleLabel.right; \n';
539 attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
540 subtitleAnchors += 'top: titleLabel.bottom;\n';
542 attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
546 // code for different elements
547 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
548 var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra);
552 // code for the title container
553 var containerCode = [];
554 var containerHeight = 'titleLabel.height';
555 containerCode.push(titleCode);
557 subtitleCode = kSubtitleLabelCode.arg(subtitleAnchors).arg(titleColor);
558 containerCode.push(subtitleCode);
559 containerHeight += ' + subtitleLabel.height';
562 containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
565 attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
566 containerCode.push(attributesCode);
567 containerHeight += ' + attributesRow.height';
570 if (hasTitleContainer) {
572 titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
575 titleSubtitleCode = titleCode;
577 titleSubtitleCode += subtitleCode;
580 titleSubtitleCode += attributesCode;
586 var rowCode = [mascotCode, titleSubtitleCode];
587 if (mascotShapeCode != '') {
588 rowCode.unshift(mascotShapeCode);
590 code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
592 code += mascotShapeCode + mascotCode + titleSubtitleCode;
596 var summaryTopAnchor;
597 if (isHorizontal && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
598 else if (headerAsOverlay && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
599 else if (hasHeaderRow) summaryTopAnchor = 'row.bottom';
600 else if (hasTitleContainer) summaryTopAnchor = 'headerTitleContainer.bottom';
601 else if (hasMascot) summaryTopAnchor = 'mascotImage.bottom';
602 else if (hasAttributes) summaryTopAnchor = 'attributesRow.bottom';
603 else if (hasSubtitle) summaryTopAnchor = 'subtitleLabel.bottom';
604 else if (hasTitle) summaryTopAnchor = 'titleLabel.bottom';
605 else if (hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
606 else summaryTopAnchor = 'parent.top';
610 summaryColor = summaryColorWithBackground;
612 summaryColor = 'root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText';
615 var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ? 'anchors.margins' : '0');
617 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
620 var touchdownAnchors;
622 touchdownAnchors = 'fill: backgroundLoader';
623 } else if (touchdownOnArtShape) {
624 touchdownAnchors = 'fill: artShapeHolder';
626 touchdownAnchors = 'fill: root'
628 code += kTouchdownCode.arg(touchdownAnchors);
630 var implicitHeight = 'implicitHeight: ';
632 implicitHeight += 'summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
633 } else if (hasHeaderRow) {
634 implicitHeight += 'row.y + row.height + units.gu(1);\n';
635 } else if (hasMascot) {
636 implicitHeight += 'mascotImage.y + mascotImage.height;\n';
637 } else if (hasTitleContainer) {
638 implicitHeight += 'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
639 } else if (hasAttributes) {
640 implicitHeight += 'attributesRow.y + attributesRow.height + units.gu(1);\n';
641 } else if (hasSubtitle) {
642 implicitHeight += 'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
643 } else if (hasTitle) {
644 implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
646 implicitHeight += 'artShapeHolder.height;\n';
651 // Close the AbstractButton
652 code += implicitHeight + '}\n';
657function createCardComponent(parent, template, components) {
658 var imports = 'import QtQuick 2.2; \n\
659 import Ubuntu.Components 1.1; \n\
660 import Ubuntu.Connectivity 1.0; \n\
662 import Utils 0.1;\n';
663 var card = cardString(template, components);
664 var code = imports + 'Component {\n' + card + '}\n';
667 return Qt.createQmlObject(code, parent, "createCardComponent");
669 console.error("ERROR: Invalid component created.");
670 console.error("Template:");
671 console.error(JSON.stringify(template));
672 console.error("Components:");
673 console.error(JSON.stringify(components));
674 console.error("Code:");
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list