on xenial help sign in
Updated all 1.3 UbuntuShape to use new APIs where possible

Approved by: Albert Astals Cid

commit59eee29d6e4173cdf5c7cd9016f83c99cf5c252c authorAndrea Cimitan <andrea.cimitan@gmail.com> dateWed 4 Nov 2015, 14:56 (11 years ago) parent5280096e1ce4b8
24 files changed+127−182
plugins/Dash/CardCreator.js+20−46 qml/Components/LazyImage.qml+9−11 qml/Dash/CardCarousel.qml+1−1 qml/Dash/Previews/PreviewAudioPlayback.qml+1−1 qml/Dash/Previews/PreviewHeader.qml+6−6 qml/Dash/Previews/PreviewImageGallery.qml+1−1 qml/Dash/Previews/PreviewZoomableImage.qml+1−1 qml/Dash/ScopesListCategoryItem.qml+2−2 qml/Launcher/LauncherDelegate.qml+5−6 qml/Launcher/LauncherPanel.qml+2−2 qml/Notifications/Notification.qml+6−6 qml/Notifications/OptionToggle.qml+2−2 qml/Notifications/SwipeToAct.qml+8−8 qml/Stages/Splash.qml+3−4 tests/plugins/Dash/cardcreator/1.res+6−7 tests/plugins/Dash/cardcreator/2.res+7−6 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+7−6 tests/plugins/Dash/cardcreator/7.res+7−6 tests/plugins/Dash/cardcreator/8.res+6−5 tests/qmltests/Dash/Previews/tst_PreviewHeader.qml+1−1 tests/qmltests/Dash/tst_Card.qml+3−3
plugins/Dash/CardCreator.js+20−46
@@ -28,11 +28,12 @@ var kBackgroundLoaderCode = 'Loader {\n\
2828 sourceComponent: UbuntuShape { \n\
2929 objectName: "background"; \n\
3030 radius: "medium"; \n\
31− color: getColor(0) || "white"; \n\
32− gradientColor: getColor(1) || color; \n\
31+ backgroundColor: getColor(0) || "white"; \n\
32+ secondaryBackgroundColor: getColor(1) || backgroundColor; \n\
33+ backgroundMode: UbuntuShape.VerticalGradient; \n\
3334 anchors.fill: parent; \n\
34− image: backgroundImage.source ? backgroundImage : null; \n\
35− property real luminance: Style.luminance(color); \n\
35+ source: backgroundImage.source ? backgroundImage : null; \n\
36+ property real luminance: Style.luminance(backgroundColor); \n\
3637 property Image backgroundImage: Image { \n\
3738 objectName: "backgroundImage"; \n\
3839 source: { \n\
@@ -52,7 +53,7 @@ var kBackgroundLoaderCode = 'Loader {\n\
5253// %1 is used as anchors of artShapeHolder
5354// %2 is used as image width
5455// %3 is used as image height
55−var kArtShapeHolderCode = 'Item { \n\
56+var kArtShapeHolderCode = 'Item { \n\
5657 id: artShapeHolder; \n\
5758 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
5859 width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
@@ -66,10 +67,9 @@ var kArtShapeHolderCode = 'Item { \n\
6667 sourceComponent: Item { \n\
6768 id: artShape; \n\
6869 objectName: "artShape"; \n\
69− property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
70+ readonly property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
7071 visible: image.status == Image.Ready; \n\
7172 readonly property alias image: artImage; \n\
72− property alias borderSource: artShapeShape.borderSource; \n\
7373 ShaderEffectSource { \n\
7474 id: artShapeSource; \n\
7575 sourceItem: artImage; \n\
@@ -78,16 +78,17 @@ var kArtShapeHolderCode = 'Item { \n\
7878 height: 1; \n\
7979 hideSource: doShapeItem; \n\
8080 } \n\
81− Shape { \n\
81+ UbuntuShape { \n\
8282 id: artShapeShape; \n\
83− image: artShapeSource; \n\
83+ source: artShapeSource; \n\
8484 anchors.fill: parent; \n\
8585 visible: doShapeItem; \n\
8686 radius: "medium"; \n\
87+ aspect: root.artShapeStyle === "inset" ? UbuntuShape.Inset : UbuntuShape.Flat; \n\
8788 } \n\
8889 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
8990 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
90− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
91+ Component.onCompleted: { updateWidthHeightBindings(); } \n\
9192 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
9293 function updateWidthHeightBindings() { \n\
9394 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
@@ -112,44 +113,18 @@ var kArtShapeHolderCode = 'Item { \n\
112113
113114var kOverlayLoaderCode = 'Loader { \n\
114115 id: overlayLoader; \n\
115− anchors { \n\
116− left: artShapeHolder.left; \n\
117− right: artShapeHolder.right; \n\
118− bottom: artShapeHolder.bottom; \n\
119− } \n\
116+ readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
117+ anchors.fill: artShapeHolder; \n\
120118 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
121119 asynchronous: root.asynchronous; \n\
122120 visible: showHeader && status == Loader.Ready; \n\
123− sourceComponent: ShaderEffect { \n\
121+ sourceComponent: UbuntuShapeOverlay { \n\
124122 id: overlay; \n\
125− height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
126123 property real luminance: Style.luminance(overlayColor); \n\
127− property color overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
128− property var source: ShaderEffectSource { \n\
129− id: shaderSource; \n\
130− sourceItem: artShapeLoader.item; \n\
131− onVisibleChanged: if (visible) scheduleUpdate(); \n\
132− live: false; \n\
133− sourceRect: Qt.rect(0, artShapeLoader.height - overlay.height, artShapeLoader.width, overlay.height); \n\
134− } \n\
135− vertexShader: " \n\
136− uniform highp mat4 qt_Matrix; \n\
137− attribute highp vec4 qt_Vertex; \n\
138− attribute highp vec2 qt_MultiTexCoord0; \n\
139− varying highp vec2 coord; \n\
140− void main() { \n\
141− coord = qt_MultiTexCoord0; \n\
142− gl_Position = qt_Matrix * qt_Vertex; \n\
143− }"; \n\
144− fragmentShader: " \n\
145− varying highp vec2 coord; \n\
146− uniform sampler2D source; \n\
147− uniform lowp float qt_Opacity; \n\
148− uniform highp vec4 overlayColor; \n\
149− void main() { \n\
150− lowp vec4 tex = texture2D(source, coord); \n\
151− gl_FragColor = vec4(overlayColor.r, overlayColor.g, overlayColor.b, 1) * qt_Opacity * overlayColor.a * tex.a; \n\
152− }"; \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\
153128 } \n\
154129 }\n';
155130
@@ -325,7 +300,7 @@ function cardString(template, components) {
325300 id: root; \n\
326301 property var components; \n\
327302 property var cardData; \n\
328− property var artShapeBorderSource: undefined; \n\
303+ property string artShapeStyle: "inset"; \n\
329304 property real fontScale: 1.0; \n\
330305 property var scopeStyle: null; \n\
331306 property int titleAlignment: Text.AlignLeft; \n\
@@ -368,7 +343,6 @@ function cardString(template, components) {
368343 }
369344
370345 if (hasArt) {
371− code += 'onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; } \n';
372346 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
373347
374348 var widthCode, heightCode;
@@ -555,7 +529,7 @@ function cardString(template, components) {
555529 titleAnchors += 'left: parent.left; \n\
556530 leftMargin: units.gu(1); \n\
557531 top: overlayLoader.top; \n\
558− topMargin: units.gu(1);\n';
532+ topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight; \n';
559533 } else {
560534 // Using anchors to the mascot/parent
561535 titleAnchors = titleRightAnchor;
qml/Components/LazyImage.qml+9−11
@@ -31,13 +31,10 @@ Item {
3131 property real initialHeight: scaleTo == "height" || scaleTo == "fit" ? height : units.gu(10)
3232
3333 property alias sourceSize: image.sourceSize
34− property alias fillMode: image.fillMode
3534 property alias asynchronous: image.asynchronous
3635 property alias cache: image.cache
37− property alias horizontalAlignment: image.horizontalAlignment
38− property alias verticalAlignment: image.verticalAlignment
3936 property alias sourceImage: image
40− property alias borderSource: shape.borderSource
37+ property bool pressed: false
4138
4239 state: "default"
4340
@@ -53,7 +50,7 @@ Item {
5350 UbuntuShape {
5451 id: placeholder
5552 objectName: "placeholder"
56− color: "#22FFFFFF"
53+ backgroundColor: "#22FFFFFF"
5754 anchors.fill: shape
5855 visible: opacity != 0
5956
@@ -78,7 +75,7 @@ Item {
7875 }
7976 }
8077
81− UbuntuShape {
78+ UbuntuShapeOverlay {
8279 id: shape
8380 objectName: "shape"
8481 height: root.initialHeight
@@ -87,19 +84,20 @@ Item {
8784
8885 opacity: 0
8986 visible: opacity != 0
90−
91− image: Image {
87+ overlayColor: Qt.rgba(0, 0, 0, root.pressed ? 0.1 : 0)
88+ overlayRect: Qt.rect(0.0, 0.0, 1.0, 1.0)
89+ sourceFillMode: UbuntuShape.PreserveAspectCrop
90+ sourceHorizontalAlignment: UbuntuShape.AlignHCenter
91+ sourceVerticalAlignment: UbuntuShape.AlignVCenter
92+ source: Image {
9293 id: image
9394 objectName: "image"
9495
9596 property url nextSource
9697 property string format: image.implicitWidth > image.implicitHeight ? "landscape" : "portrait"
9798
98− fillMode: Image.PreserveAspectFit
9999 asynchronous: true
100100 cache: false
101− horizontalAlignment: Image.AlignHCenter
102− verticalAlignment: Image.AlignVCenter
103101 sourceSize.width: root.scaleTo == "width" ? root.width
104102 : root.scaleTo == "fit" && root.width <= root.height ? root.width
105103 : 0
qml/Dash/CardCarousel.qml+1−1
@@ -68,7 +68,7 @@ DashRenderer {
6868 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
6969 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
7070 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
71− item.artShapeBorderSource = "none";
71+ item.artShapeStyle = "flat";
7272 item.scopeStyle = cardCarousel.scopeStyle;
7373 }
7474
qml/Dash/Previews/PreviewAudioPlayback.qml+1−1
@@ -175,7 +175,7 @@ PreviewWidget {
175175 }
176176 height: units.dp(2)
177177 visible: progressBarImage.visible
178− color: UbuntuColors.orange
178+ backgroundColor: UbuntuColors.orange
179179 }
180180
181181 Image {
qml/Dash/Previews/PreviewHeader.qml+6−6
@@ -43,7 +43,7 @@ PreviewWidget {
4343 readonly property color fontColor: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
4444
4545 // Rewire the source since we may have unwired it on onStatusChanged
46− onMascotChanged: if (mascotShapeLoader.item) mascotShapeLoader.item.image.source = mascot;
46+ onMascotChanged: if (mascotShapeLoader.item) mascotShapeLoader.item.source.source = mascot;
4747
4848 implicitHeight: row.height + row.margins * 2
4949 width: parent.width
@@ -77,16 +77,16 @@ PreviewWidget {
7777
7878 sourceComponent: UbuntuShape {
7979 objectName: "mascotShape"
80− visible: image.status === Image.Ready
81− image: Image {
80+ visible: source.status === Image.Ready
81+ sourceFillMode: UbuntuShape.PreserveAspectCrop
82+ sourceHorizontalAlignment: UbuntuShape.AlignHCenter
83+ sourceVerticalAlignment: UbuntuShape.AlignVCenter
84+ source: Image {
8285 source: headerRoot.mascot
8386 width: source ? mascotShapeLoader.width : 0
8487 height: mascotShapeLoader.height
8588
8689 sourceSize { width: mascotShapeLoader.maxSize; height: mascotShapeLoader.maxSize }
87− fillMode: Image.PreserveAspectCrop
88− horizontalAlignment: Image.AlignHCenter
89− verticalAlignment: Image.AlignVCenter
9090 onStatusChanged: if (status === Image.Error) source = headerRoot.fallback;
9191 }
9292 }
qml/Dash/Previews/PreviewImageGallery.qml+1−1
@@ -62,7 +62,7 @@ PreviewWidget {
6262 source: modelData ? modelData : ""
6363 scaleTo: "height"
6464 initialWidth: units.gu(13)
65− borderSource: mouseArea.pressed ? "radius_pressed.sci" : "radius_idle.sci"
65+ pressed: mouseArea.pressed
6666
6767 MouseArea {
6868 id: mouseArea
qml/Dash/Previews/PreviewZoomableImage.qml+1−1
@@ -43,7 +43,7 @@ PreviewWidget {
4343 source: widgetData["source"]
4444 asynchronous: true
4545
46− borderSource: mouseArea.pressed ? "radius_pressed.sci" : "radius_idle.sci"
46+ pressed: mouseArea.pressed
4747
4848 MouseArea {
4949 id: mouseArea
qml/Dash/ScopesListCategoryItem.qml+2−2
@@ -49,10 +49,10 @@ MouseArea {
4949 width: units.gu(5)
5050 height: units.gu(5)
5151 visible: !hideChildren
52− image: Image {
52+ sourceFillMode: UbuntuShape.PreserveAspectCrop
53+ source: Image {
5354 id: shapeImage
5455 cache: true
55− fillMode: Image.PreserveAspectCrop
5656 sourceSize { width: shape.width; height: shape.height }
5757 }
5858 }
qml/Launcher/LauncherDelegate.qml+5−6
@@ -130,13 +130,12 @@ Item {
130130 anchors.fill: parent
131131 anchors.margins: units.gu(1)
132132 radius: "medium"
133− borderSource: "none"
134−
135− image: Image {
133+ aspect: UbuntuShape.Flat
134+ sourceFillMode: UbuntuShape.PreserveAspectCrop
135+ source: Image {
136136 id: iconImage
137137 sourceSize.width: iconShape.width
138138 sourceSize.height: iconShape.height
139− fillMode: Image.PreserveAspectCrop
140139 source: root.iconName
141140 }
142141 }
@@ -159,9 +158,9 @@ Item {
159158 }
160159 width: Math.min(root.itemWidth, Math.max(units.gu(2), countLabel.implicitWidth + units.gu(1)))
161160 height: units.gu(2)
162− color: UbuntuColors.orange
161+ backgroundColor: UbuntuColors.orange
163162 visible: root.countVisible
164− borderSource: "none"
163+ aspect: UbuntuShape.Flat
165164
166165 Label {
167166 id: countLabel
qml/Launcher/LauncherPanel.qml+2−2
@@ -61,8 +61,8 @@ Rectangle {
6161 fill: parent
6262 topMargin: -units.gu(2)
6363 }
64− borderSource: "none"
65− color: UbuntuColors.orange
64+ aspect: UbuntuShape.Flat
65+ backgroundColor: UbuntuColors.orange
6666 }
6767
6868 Image {
qml/Notifications/Notification.qml+6−6
@@ -153,10 +153,10 @@ Item {
153153 rightMargin: notification.margins
154154 topMargin: type === Notification.Confirmation ? units.gu(.5) : 0
155155 }
156− color: parent.color
156+ backgroundColor: parent.color
157157 opacity: parent.opacity
158158 radius: "medium"
159− borderSource: "none"
159+ aspect: UbuntuShape.Flat
160160 }
161161
162162 Rectangle {
@@ -358,8 +358,8 @@ Item {
358358 }
359359
360360 height: units.gu(1)
361− color: darkOnBright ? UbuntuColors.darkGrey : UbuntuColors.lightGrey
362− borderSource: "none"
361+ backgroundColor: darkOnBright ? UbuntuColors.darkGrey : UbuntuColors.lightGrey
362+ aspect: UbuntuShape.Flat
363363 radius: "small"
364364
365365 UbuntuShape {
@@ -367,8 +367,8 @@ Item {
367367 objectName: "innerBar"
368368 width: valueIndicator.width * valueIndicator.value / 100
369369 height: units.gu(1)
370− color: notification.hints["x-canonical-value-bar-tint"] === "true" ? UbuntuColors.orange : darkOnBright ? UbuntuColors.lightGrey : "white"
371− borderSource: "none"
370+ backgroundColor: notification.hints["x-canonical-value-bar-tint"] === "true" ? UbuntuColors.orange : darkOnBright ? UbuntuColors.lightGrey : "white"
371+ aspect: UbuntuShape.Flat
372372 radius: "small"
373373 }
374374 }
qml/Notifications/OptionToggle.qml+2−2
@@ -29,8 +29,8 @@ UbuntuShape {
2929
3030 signal triggered(string id)
3131
32− color: theme.palette.normal.base
33− borderSource: "none"
32+ backgroundColor: theme.palette.normal.base
33+ aspect: UbuntuShape.Flat
3434 height: expanded ? (optionToggleRepeater.count - startIndex) * itemHeight : itemHeight
3535 width: parent.width
3636 radius: "medium"
qml/Notifications/SwipeToAct.qml+8−8
@@ -98,8 +98,8 @@ Item {
9898 id: row
9999 width: parent.width
100100 height: priv.sliderHeight
101− color: priv.sliderBGColor
102− borderSource: "none"
101+ backgroundColor: priv.sliderBGColor
102+ aspect: UbuntuShape.Flat
103103 visible: !clickToAct
104104
105105 UbuntuShape {
@@ -108,8 +108,8 @@ Item {
108108 anchors.top: parent.top
109109 anchors.left: parent.left
110110 anchors.margins: priv.gap
111− color: UbuntuColors.red
112− borderSource: "none"
111+ backgroundColor: UbuntuColors.red
112+ aspect: UbuntuShape.Flat
113113
114114 state: "normal"
115115 height: units.gu(6)
@@ -187,10 +187,10 @@ Item {
187187 }
188188
189189 z: 1
190− color: priv.sliderMainColor
190+ backgroundColor: priv.sliderMainColor
191191 height: units.gu(6)
192192 width: units.gu(6)
193− borderSource: "none"
193+ aspect: UbuntuShape.Flat
194194 radius: "medium"
195195 Icon {
196196 anchors.fill: parent
@@ -226,8 +226,8 @@ Item {
226226 anchors.top: parent.top
227227 anchors.right: parent.right
228228 anchors.margins: priv.gap
229− color: UbuntuColors.green
230− borderSource: "none"
229+ backgroundColor: UbuntuColors.green
230+ aspect: UbuntuShape.Flat
231231
232232 state: "normal"
233233 height: units.gu(6)
qml/Stages/Splash.qml+3−4
@@ -117,14 +117,13 @@ Item {
117117 visible: d.showIcon
118118
119119 radius: "medium"
120− borderSource: "none"
121−
122− image: Image {
120+ aspect: UbuntuShape.Flat
121+ sourceFillMode: Image.PreserveAspectCrop
122+ source: Image {
123123 id: iconImage
124124 sourceSize.width: iconShape.width
125125 sourceSize.height: iconShape.height
126126 source: d.showIcon ? root.icon : ""
127− fillMode: Image.PreserveAspectCrop
128127 }
129128 }
130129
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;
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+7−6
@@ -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;
28− anchors.fill: parent;
29− image: backgroundImage.source ? backgroundImage : null;
30− property real luminance: Style.luminance(color);
26+ backgroundColor: getColor(0) || "white";
27+ secondaryBackgroundColor: getColor(1) || backgroundColor;
28+ backgroundMode: UbuntuShape.VerticalGradient;
29+ anchors.fill: parent;
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;
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;
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+7−6
@@ -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;
28− anchors.fill: parent;
29− image: backgroundImage.source ? backgroundImage : null;
30− property real luminance: Style.luminance(color);
26+ backgroundColor: getColor(0) || "white";
27+ secondaryBackgroundColor: getColor(1) || backgroundColor;
28+ backgroundMode: UbuntuShape.VerticalGradient;
29+ anchors.fill: parent;
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+7−6
@@ -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;
28− anchors.fill: parent;
29− image: backgroundImage.source ? backgroundImage : null;
30− property real luminance: Style.luminance(color);
26+ backgroundColor: getColor(0) || "white";
27+ secondaryBackgroundColor: getColor(1) || backgroundColor;
28+ backgroundMode: UbuntuShape.VerticalGradient;
29+ anchors.fill: parent;
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: UbuntuShape.VerticalGradient;
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/qmltests/Dash/Previews/tst_PreviewHeader.qml+1−1
@@ -149,7 +149,7 @@ Rectangle {
149149 tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
150150 var mascot = findChild(previewHeader, "mascotShape");
151151 tryCompare(mascot, "visible", true);
152− tryCompare(mascot.image, "status", Image.Ready);
152+ tryCompare(mascot.source, "status", Image.Ready);
153153 }
154154 }
155155}
tests/qmltests/Dash/tst_Card.qml+3−3
@@ -443,11 +443,11 @@ Rectangle {
443443 }
444444
445445 if (data.hasOwnProperty("color")) {
446− tryCompare(background, "color", data.color);
446+ tryCompare(background, "backgroundColor", data.color);
447447 }
448448
449449 if (data.hasOwnProperty("gradientColor")) {
450− tryCompare(background, "gradientColor", data.gradientColor);
450+ tryCompare(background, "secondaryBackgroundColor", data.gradientColor);
451451 }
452452
453453 if (data.hasOwnProperty("image")) {
@@ -520,7 +520,7 @@ Rectangle {
520520 waitForRendering(selector);
521521 waitForRendering(card);
522522
523− background.color = data.tag;
523+ background.backgroundColor = data.tag;
524524
525525 var fontColor = data.dark ? theme.palette.normal.baseText : "white";
526526