on xenial help sign in
Fix test card creator
commitb11778f1958b7e5554a77a736fe250c9e608babb authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 17 Jul 2015, 11:08 (11 years ago) parent21f71de
8 files changed+53−78
tests/plugins/Dash/cardcreator/1.res+6−7 tests/plugins/Dash/cardcreator/2.res+6−5 tests/plugins/Dash/cardcreator/3.res+6−7 tests/plugins/Dash/cardcreator/4.res+1−1 tests/plugins/Dash/cardcreator/5.res+16−43 tests/plugins/Dash/cardcreator/6.res+6−5 tests/plugins/Dash/cardcreator/7.res+6−5 tests/plugins/Dash/cardcreator/8.res+6−5
tests/plugins/Dash/cardcreator/1.res+6−7
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
@@ -14,7 +14,6 @@ AbstractButton {
1414 implicitWidth: childrenRect.width;
1515 enabled: true;
1616
17−onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
1817readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1918Item {
2019 id: artShapeHolder;
@@ -30,10 +29,9 @@ Item {
3029 sourceComponent: Item {
3130 id: artShape;
3231 objectName: "artShape";
33− property bool doShapeItem: components["art"]["conciergeMode"] !== true;
32+ readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true;
3433 visible: image.status == Image.Ready;
3534 readonly property alias image: artImage.image;
36− property alias borderSource: artShapeShape.borderSource;
3735 ShaderEffectSource {
3836 id: artShapeSource;
3937 sourceItem: artImage;
@@ -42,16 +40,17 @@ Item {
4240 height: 1;
4341 hideSource: doShapeItem;
4442 }
45− Shape {
43+ UbuntuShape {
4644 id: artShapeShape;
47− image: artShapeSource;
45+ source: artShapeSource;
4846 anchors.fill: parent;
4947 visible: doShapeItem;
5048 radius: "medium";
49+ aspect: root.artShapeStyle === "inset" ? UbuntuShape.Inset : UbuntuShape.Flat;
5150 }
5251 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5352 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
54− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
53+ Component.onCompleted: { updateWidthHeightBindings(); }
5554 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
5655 function updateWidthHeightBindings() {
5756 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
tests/plugins/Dash/cardcreator/2.res+6−5
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
@@ -23,11 +23,12 @@ Loader {
2323 sourceComponent: UbuntuShape {
2424 objectName: "background";
2525 radius: "medium";
26− color: getColor(0) || "white";
27− gradientColor: getColor(1) || color;
26+ backgroundColor: getColor(0) || "white";
27+ secondaryBackgroundColor: getColor(1) || backgroundColor;
28+ backgroundMode: cardData && typeof cardData["background"] === "object" && cardData["background"]["type"] === "gradient" ? UbuntuShape.VerticalGradient : UbuntuShape.SolidColor;
2829 anchors.fill: parent;
29− image: backgroundImage.source ? backgroundImage : null;
30− property real luminance: Style.luminance(color);
30+ source: backgroundImage.source ? backgroundImage : null;
31+ property real luminance: Style.luminance(backgroundColor);
3132 property Image backgroundImage: Image {
3233 objectName: "backgroundImage";
3334 source: {
tests/plugins/Dash/cardcreator/3.res+6−7
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
@@ -14,7 +14,6 @@ AbstractButton {
1414 implicitWidth: childrenRect.width;
1515 enabled: true;
1616
17−onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
1817readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1918Item {
2019 id: artShapeHolder;
@@ -30,10 +29,9 @@ Item {
3029 sourceComponent: Item {
3130 id: artShape;
3231 objectName: "artShape";
33− property bool doShapeItem: components["art"]["conciergeMode"] !== true;
32+ readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true;
3433 visible: image.status == Image.Ready;
3534 readonly property alias image: artImage.image;
36− property alias borderSource: artShapeShape.borderSource;
3735 ShaderEffectSource {
3836 id: artShapeSource;
3937 sourceItem: artImage;
@@ -42,16 +40,17 @@ Item {
4240 height: 1;
4341 hideSource: doShapeItem;
4442 }
45− Shape {
43+ UbuntuShape {
4644 id: artShapeShape;
47− image: artShapeSource;
45+ source: artShapeSource;
4846 anchors.fill: parent;
4947 visible: doShapeItem;
5048 radius: "medium";
49+ aspect: root.artShapeStyle === "inset" ? UbuntuShape.Inset : UbuntuShape.Flat;
5150 }
5251 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5352 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
54− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
53+ Component.onCompleted: { updateWidthHeightBindings(); }
5554 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
5655 function updateWidthHeightBindings() {
5756 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
tests/plugins/Dash/cardcreator/4.res+1−1
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
tests/plugins/Dash/cardcreator/5.res+16−43
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
@@ -14,7 +14,6 @@ AbstractButton {
1414 implicitWidth: childrenRect.width;
1515 enabled: false;
1616
17−onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
1817readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1918Item {
2019 id: artShapeHolder;
@@ -30,10 +29,9 @@ Item {
3029 sourceComponent: Item {
3130 id: artShape;
3231 objectName: "artShape";
33− property bool doShapeItem: components["art"]["conciergeMode"] !== true;
32+ readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true;
3433 visible: image.status == Image.Ready;
3534 readonly property alias image: artImage.image;
36− property alias borderSource: artShapeShape.borderSource;
3735 ShaderEffectSource {
3836 id: artShapeSource;
3937 sourceItem: artImage;
@@ -42,16 +40,17 @@ Item {
4240 height: 1;
4341 hideSource: doShapeItem;
4442 }
45− Shape {
43+ UbuntuShape {
4644 id: artShapeShape;
47− image: artShapeSource;
45+ source: artShapeSource;
4846 anchors.fill: parent;
4947 visible: doShapeItem;
5048 radius: "medium";
49+ aspect: root.artShapeStyle === "inset" ? UbuntuShape.Inset : UbuntuShape.Flat;
5150 }
5251 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
5352 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
54− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
53+ Component.onCompleted: { updateWidthHeightBindings(); }
5554 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
5655 function updateWidthHeightBindings() {
5756 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
@@ -75,44 +74,18 @@ Item {
7574 }
7675Loader {
7776 id: overlayLoader;
78− anchors {
79− left: artShapeHolder.left;
80− right: artShapeHolder.right;
81− bottom: artShapeHolder.bottom;
82− }
83− active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
77+ readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
78+ anchors.fill: artShapeHolder;
79+ active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
8480 asynchronous: root.asynchronous;
8581 visible: showHeader && status == Loader.Ready;
86− sourceComponent: ShaderEffect {
82+ sourceComponent: UbuntuShapeOverlay {
8783 id: overlay;
88− height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
89− property real luminance: Style.luminance(overlayColor);
90− property color overlayColor: cardData && cardData["overlayColor"] || "#99000000";
91− property var source: ShaderEffectSource {
92− id: shaderSource;
93− sourceItem: artShapeLoader.item;
94− onVisibleChanged: if (visible) scheduleUpdate();
95− live: false;
96− sourceRect: Qt.rect(0, artShapeLoader.height - overlay.height, artShapeLoader.width, overlay.height);
97− }
98− vertexShader: "
99− uniform highp mat4 qt_Matrix;
100− attribute highp vec4 qt_Vertex;
101− attribute highp vec2 qt_MultiTexCoord0;
102− varying highp vec2 coord;
103− void main() {
104− coord = qt_MultiTexCoord0;
105− gl_Position = qt_Matrix * qt_Vertex;
106− }";
107− fragmentShader: "
108− varying highp vec2 coord;
109− uniform sampler2D source;
110− uniform lowp float qt_Opacity;
111− uniform highp vec4 overlayColor;
112− void main() {
113− lowp vec4 tex = texture2D(source, coord);
114− gl_FragColor = vec4(overlayColor.r, overlayColor.g, overlayColor.b, 1) * qt_Opacity * overlayColor.a * tex.a;
115− }";
84+ property real luminance: Style.luminance(overlayColor);
85+ aspect: UbuntuShape.Flat;
86+ radius: "medium";
87+ overlayColor: cardData && cardData["overlayColor"] || "#99000000";
88+ overlayRect: Qt.rect(0, 1 - overlayLoader.overlayHeight / height, 1, 1);
11689 }
11790 }
11891readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
@@ -124,7 +97,7 @@ Label {
12497 left: parent.left;
12598 leftMargin: units.gu(1);
12699 top: overlayLoader.top;
127− topMargin: units.gu(1);
100+ topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight;
128101 }
129102 elide: Text.ElideRight;
130103 fontSize: "small";
tests/plugins/Dash/cardcreator/6.res+6−5
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
@@ -23,11 +23,12 @@ Loader {
2323 sourceComponent: UbuntuShape {
2424 objectName: "background";
2525 radius: "medium";
26− color: getColor(0) || "white";
27− gradientColor: getColor(1) || color;
26+ backgroundColor: getColor(0) || "white";
27+ secondaryBackgroundColor: getColor(1) || backgroundColor;
28+ backgroundMode: cardData && typeof cardData["background"] === "object" && cardData["background"]["type"] === "gradient" ? UbuntuShape.VerticalGradient : UbuntuShape.SolidColor;
2829 anchors.fill: parent;
29− image: backgroundImage.source ? backgroundImage : null;
30− property real luminance: Style.luminance(color);
30+ source: backgroundImage.source ? backgroundImage : null;
31+ property real luminance: Style.luminance(backgroundColor);
3132 property Image backgroundImage: Image {
3233 objectName: "backgroundImage";
3334 source: {
tests/plugins/Dash/cardcreator/7.res+6−5
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
@@ -23,11 +23,12 @@ Loader {
2323 sourceComponent: UbuntuShape {
2424 objectName: "background";
2525 radius: "medium";
26− color: getColor(0) || "white";
27− gradientColor: getColor(1) || color;
26+ backgroundColor: getColor(0) || "white";
27+ secondaryBackgroundColor: getColor(1) || backgroundColor;
28+ backgroundMode: cardData && typeof cardData["background"] === "object" && cardData["background"]["type"] === "gradient" ? UbuntuShape.VerticalGradient : UbuntuShape.SolidColor;
2829 anchors.fill: parent;
29− image: backgroundImage.source ? backgroundImage : null;
30− property real luminance: Style.luminance(color);
30+ source: backgroundImage.source ? backgroundImage : null;
31+ property real luminance: Style.luminance(backgroundColor);
3132 property Image backgroundImage: Image {
3233 objectName: "backgroundImage";
3334 source: {
tests/plugins/Dash/cardcreator/8.res+6−5
@@ -2,7 +2,7 @@ AbstractButton {
22 id: root;
33 property var components;
44 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
88 property int titleAlignment: Text.AlignLeft;
@@ -23,11 +23,12 @@ Loader {
2323 sourceComponent: UbuntuShape {
2424 objectName: "background";
2525 radius: "medium";
26− color: getColor(0) || "white";
27− gradientColor: getColor(1) || color;
26+ backgroundColor: getColor(0) || "white";
27+ secondaryBackgroundColor: getColor(1) || backgroundColor;
28+ backgroundMode: cardData && typeof cardData["background"] === "object" && cardData["background"]["type"] === "gradient" ? UbuntuShape.VerticalGradient : UbuntuShape.SolidColor;
2829 anchors.fill: parent;
29− image: backgroundImage.source ? backgroundImage : null;
30− property real luminance: Style.luminance(color);
30+ source: backgroundImage.source ? backgroundImage : null;
31+ property real luminance: Style.luminance(backgroundColor);
3132 property Image backgroundImage: Image {
3233 objectName: "backgroundImage";
3334 source: {