on xenial help sign in
Remove outer Item of CroppedImageMinimumSourceSize
1a09225Albert Astals Cid
plugins/Dash/CardCreator.js+4−4
@@ -68,7 +68,7 @@ var kArtShapeHolderCode = 'Item { \n\
68 objectName: "artShape"; \n\
68 objectName: "artShape"; \n\
69 property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
69 property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
70 visible: image.status == Image.Ready; \n\
70 visible: image.status == Image.Ready; \n\
71− readonly property alias image: artImage.image; \n\
71+ readonly property alias image: artImage; \n\
72 property alias borderSource: artShapeShape.borderSource; \n\
72 property alias borderSource: artShapeShape.borderSource; \n\
73 ShaderEffectSource { \n\
73 ShaderEffectSource { \n\
74 id: artShapeSource; \n\
74 id: artShapeSource; \n\
@@ -195,11 +195,11 @@ var kMascotShapeLoaderCode = 'Loader { \n\
195 id: mascotShapeLoader; \n\
195 id: mascotShapeLoader; \n\
196 objectName: "mascotShapeLoader"; \n\
196 objectName: "mascotShapeLoader"; \n\
197 asynchronous: root.asynchronous; \n\
197 asynchronous: root.asynchronous; \n\
198− active: mascotImage.image.status === Image.Ready; \n\
198+ active: mascotImage.status === Image.Ready; \n\
199 visible: showHeader && active && status == Loader.Ready; \n\
199 visible: showHeader && active && status == Loader.Ready; \n\
200 width: units.gu(6); \n\
200 width: units.gu(6); \n\
201 height: units.gu(5.625); \n\
201 height: units.gu(5.625); \n\
202− sourceComponent: UbuntuShape { image: mascotImage.image } \n\
202+ sourceComponent: UbuntuShape { image: mascotImage } \n\
203 anchors { %1 } \n\
203 anchors { %1 } \n\
204 }\n';
204 }\n';
205
205
@@ -476,7 +476,7 @@ function cardString(template, components) {
476 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
476 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
477 var fallback = components["mascot"] && components["mascot"]["fallback"] || "";
477 var fallback = components["mascot"] && components["mascot"]["fallback"] || "";
478 if (fallback !== "") {
478 if (fallback !== "") {
479− code += 'Connections { target: mascotImage.image; onStatusChanged: if (mascotImage.image.status === Image.Error) mascotImage.source = "%1"; } \n'.arg(fallback);
479+ code += 'Connections { target: mascotImage; onStatusChanged: if (mascotImage.status === Image.Error) mascotImage.source = "%1"; } \n'.arg(fallback);
480 }
480 }
481 }
481 }
482
482
plugins/Dash/CroppedImageMinimumSourceSize.qml+5−17
@@ -16,24 +16,12 @@
16
16
17import QtQuick 2.3
17import QtQuick 2.3
18
18
19−Item {
19+Image {
20 id: root
20 id: root
21
21
22− property alias image: innerImage
22+ fillMode: Image.PreserveAspectCrop
23− property alias source: innerImage.source
24− property alias asynchronous: innerImage.asynchronous
25− property alias verticalAlignment: innerImage.verticalAlignment
26− property alias horizontalAlignment: innerImage.horizontalAlignment
27− property alias fillMode: innerImage.fillMode
28
23
29− Image {
30− id: innerImage
31−
32− anchors.fill: parent
33− fillMode: Image.PreserveAspectCrop
34−
35− readonly property real itemAspectRatio: width / height
24+ readonly property real itemAspectRatio: width / height
36− readonly property real imageAspectRatio: implicitWidth / implicitHeight
25+ readonly property real imageAspectRatio: implicitWidth / implicitHeight
37− sourceSize: (imageAspectRatio > itemAspectRatio) ? Qt.size(0, height) : Qt.size(width, 0)
26+ sourceSize: (imageAspectRatio > itemAspectRatio) ? Qt.size(0, height) : Qt.size(width, 0)
38− }
39}
27}
tests/plugins/Dash/cardcreator/1.res+1−1
@@ -32,7 +32,7 @@ Item {
32 objectName: "artShape";
32 objectName: "artShape";
33 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
33 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
34 visible: image.status == Image.Ready;
34 visible: image.status == Image.Ready;
35− readonly property alias image: artImage.image;
35+ readonly property alias image: artImage;
36 property alias borderSource: artShapeShape.borderSource;
36 property alias borderSource: artShapeShape.borderSource;
37 ShaderEffectSource {
37 ShaderEffectSource {
38 id: artShapeSource;
38 id: artShapeSource;
tests/plugins/Dash/cardcreator/3.res+1−1
@@ -32,7 +32,7 @@ Item {
32 objectName: "artShape";
32 objectName: "artShape";
33 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
33 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
34 visible: image.status == Image.Ready;
34 visible: image.status == Image.Ready;
35− readonly property alias image: artImage.image;
35+ readonly property alias image: artImage;
36 property alias borderSource: artShapeShape.borderSource;
36 property alias borderSource: artShapeShape.borderSource;
37 ShaderEffectSource {
37 ShaderEffectSource {
38 id: artShapeSource;
38 id: artShapeSource;
tests/plugins/Dash/cardcreator/4.res+2−2
@@ -34,11 +34,11 @@ Loader {
34 id: mascotShapeLoader;
34 id: mascotShapeLoader;
35 objectName: "mascotShapeLoader";
35 objectName: "mascotShapeLoader";
36 asynchronous: root.asynchronous;
36 asynchronous: root.asynchronous;
37− active: mascotImage.image.status === Image.Ready;
37+ active: mascotImage.status === Image.Ready;
38 visible: showHeader && active && status == Loader.Ready;
38 visible: showHeader && active && status == Loader.Ready;
39 width: units.gu(6);
39 width: units.gu(6);
40 height: units.gu(5.625);
40 height: units.gu(5.625);
41− sourceComponent: UbuntuShape { image: mascotImage.image }
41+ sourceComponent: UbuntuShape { image: mascotImage }
42 anchors { verticalCenter: parent.verticalCenter; }
42 anchors { verticalCenter: parent.verticalCenter; }
43 }
43 }
44
44
tests/plugins/Dash/cardcreator/5.res+1−1
@@ -32,7 +32,7 @@ Item {
32 objectName: "artShape";
32 objectName: "artShape";
33 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
33 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
34 visible: image.status == Image.Ready;
34 visible: image.status == Image.Ready;
35− readonly property alias image: artImage.image;
35+ readonly property alias image: artImage;
36 property alias borderSource: artShapeShape.borderSource;
36 property alias borderSource: artShapeShape.borderSource;
37 ShaderEffectSource {
37 ShaderEffectSource {
38 id: artShapeSource;
38 id: artShapeSource;
tests/plugins/Dash/tst_CroppedImageMinimumSourceSize.qml+6−6
@@ -41,16 +41,16 @@ Rectangle {
41 when: windowShown
41 when: windowShown
42
42
43 function test_croppedSource() {
43 function test_croppedSource() {
44− tryCompare(cimss.image.sourceSize, "width", 100);
44+ tryCompare(cimss.sourceSize, "width", 100);
45− tryCompare(cimss.image.sourceSize, "height", 0);
45+ tryCompare(cimss.sourceSize, "height", 0);
46
46
47 cimss.width = 40;
47 cimss.width = 40;
48− tryCompare(cimss.image.sourceSize, "width", 0);
48+ tryCompare(cimss.sourceSize, "width", 0);
49− tryCompare(cimss.image.sourceSize, "height", 100);
49+ tryCompare(cimss.sourceSize, "height", 100);
50
50
51 cimss.width = 100;
51 cimss.width = 100;
52− tryCompare(cimss.image.sourceSize, "width", 100);
52+ tryCompare(cimss.sourceSize, "width", 100);
53− tryCompare(cimss.image.sourceSize, "height", 0);
53+ tryCompare(cimss.sourceSize, "height", 0);
54 }
54 }
55 }
55 }
56}
56}