eol
commit7ce88e921b389b8f50fe872ab68150d1d074ef06
authorAlbert Astals <albert.astals@canonical.com>
dateTue 6 May 2014, 12:10 (12 years ago)
parentc7482d0
tests/plugins/Dash/cardcreator/2.res+1−1
@@ -1 +1 @@
1−AbstractButton { id: root; property var template; property var components; property var cardData; property real fontScale: 1.0; property int headerAlignment: Text.AlignLeft; property int fixedHeaderHeight: -1; property size fixedArtShapeSize: Qt.size(-1, -1); readonly property string title: cardData && cardData["title"] || ""; property bool asynchronous: true; property bool showHeader: true; implicitWidth: childrenRect.width; Loader { id: backgroundLoader; objectName: "backgroundLoader"; anchors.fill: parent; asynchronous: root.asynchronous; visible: status == Loader.Ready; sourceComponent: UbuntuShape { objectName: "background"; radius: "medium"; color: getColor(0) || "white"; gradientColor: getColor(1) || color; anchors.fill: parent; image: backgroundImage.source ? backgroundImage : null; property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; property Image backgroundImage: Image { objectName: "backgroundImage"; source: { if (cardData && typeof cardData["background"] === "string") return cardData["background"]; else if (template && typeof template["card-background"] === "string") return template["card-background"]; else return ""; } } function getColor(index) { if (cardData && typeof cardData["background"] === "object" && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { return cardData["background"]["elements"][index]; } else if (template && typeof template["card-background"] === "object" && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) { return template["card-background"]["elements"][index]; } else return undefined; } } }readonly property size artShapeSize: Qt.size(-1, -1);readonly property int headerHeight: row.height + row.margins * 2;Row { id: row; objectName: "outerRow"; property real margins: units.gu(1); spacing: margins; anchors.top: parent.top; anchors.topMargin: units.gu(1); anchors.left: parent.left; anchors.right: parent.right; anchors.margins: margins;Image { id: mascotImage; objectName: "mascotImage"; anchors.verticalCenter: parent.verticalCenter; readonly property int maxSize: Math.max(width, height) * 4; source: cardData && cardData["mascot"]; width: units.gu(6); height: units.gu(5.625); sourceSize { width: maxSize; height: maxSize } fillMode: Image.PreserveAspectCrop; horizontalAlignment: Image.AlignHCenter; verticalAlignment: Image.AlignVCenter; visible: showHeader && true; }Column { anchors.verticalCenter: parent.verticalCenter; spacing: units.dp(2); width: parent.width - x;Label { id: titleLabel; objectName: "titleLabel"; anchors { left: parent.left; right: parent.right } elide: Text.ElideRight; fontSize: "small"; wrapMode: Text.Wrap; maximumLineCount: 2; font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"; visible: showHeader ; text: root.title; font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; horizontalAlignment: root.headerAlignment; }Label { id: subtitleLabel; objectName: "subtitleLabel"; anchors { left: parent.left; right: parent.right } elide: Text.ElideRight; fontSize: "small"; font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"; visible: titleLabel.visible && titleLabel.text; text: cardData && cardData["subtitle"] || ""; font.weight: Font.Light; horizontalAlignment: root.headerAlignment; }}}implicitHeight: row.y + row.height + units.gu(1);}
1+AbstractButton { id: root; property var template; property var components; property var cardData; property real fontScale: 1.0; property int headerAlignment: Text.AlignLeft; property int fixedHeaderHeight: -1; property size fixedArtShapeSize: Qt.size(-1, -1); readonly property string title: cardData && cardData["title"] || ""; property bool asynchronous: true; property bool showHeader: true; implicitWidth: childrenRect.width; Loader { id: backgroundLoader; objectName: "backgroundLoader"; anchors.fill: parent; asynchronous: root.asynchronous; visible: status == Loader.Ready; sourceComponent: UbuntuShape { objectName: "background"; radius: "medium"; color: getColor(0) || "white"; gradientColor: getColor(1) || color; anchors.fill: parent; image: backgroundImage.source ? backgroundImage : null; property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; property Image backgroundImage: Image { objectName: "backgroundImage"; source: { if (cardData && typeof cardData["background"] === "string") return cardData["background"]; else if (template && typeof template["card-background"] === "string") return template["card-background"]; else return ""; } } function getColor(index) { if (cardData && typeof cardData["background"] === "object" && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { return cardData["background"]["elements"][index]; } else if (template && typeof template["card-background"] === "object" && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) { return template["card-background"]["elements"][index]; } else return undefined; } } }readonly property size artShapeSize: Qt.size(-1, -1);readonly property int headerHeight: row.height + row.margins * 2;Row { id: row; objectName: "outerRow"; property real margins: units.gu(1); spacing: margins; anchors.top: parent.top; anchors.topMargin: units.gu(1); anchors.left: parent.left; anchors.right: parent.right; anchors.margins: margins;Image { id: mascotImage; objectName: "mascotImage"; anchors.verticalCenter: parent.verticalCenter; readonly property int maxSize: Math.max(width, height) * 4; source: cardData && cardData["mascot"]; width: units.gu(6); height: units.gu(5.625); sourceSize { width: maxSize; height: maxSize } fillMode: Image.PreserveAspectCrop; horizontalAlignment: Image.AlignHCenter; verticalAlignment: Image.AlignVCenter; visible: showHeader && true; }Column { anchors.verticalCenter: parent.verticalCenter; spacing: units.dp(2); width: parent.width - x;Label { id: titleLabel; objectName: "titleLabel"; anchors { left: parent.left; right: parent.right } elide: Text.ElideRight; fontSize: "small"; wrapMode: Text.Wrap; maximumLineCount: 2; font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"; visible: showHeader ; text: root.title; font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; horizontalAlignment: root.headerAlignment; }Label { id: subtitleLabel; objectName: "subtitleLabel"; anchors { left: parent.left; right: parent.right } elide: Text.ElideRight; fontSize: "small"; font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"; visible: titleLabel.visible && titleLabel.text; text: cardData && cardData["subtitle"] || ""; font.weight: Font.Light; horizontalAlignment: root.headerAlignment; }}}implicitHeight: row.y + row.height + units.gu(1);}
tests/plugins/Dash/cardcreator/2.tst+1−1
@@ -1,3 +1,3 @@
11template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"}}
3−result: 2.res
3+result: 2.res
tests/plugins/Dash/cardcreator/3.tst+1−1
@@ -1,3 +1,3 @@
11template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
22components: {"art":{"aspect-ratio":0.75,"field":"art","fill-mode":"crop"},"subtitle":{"field":"price"},"title":{"field":"title"}}
3−result: 3.res
3+result: 3.res