on xenial help sign in
Remove outer Item of CroppedImageMinimumSourceSize
commit1a09225c314a8c863c52d3e692b177d5555d1dd2 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 31 Aug 2015, 15:29 (11 years ago) parent630d245
7 files changed+20−32
plugins/Dash/CardCreator.js+4−4 plugins/Dash/CroppedImageMinimumSourceSize.qml+5−17 tests/plugins/Dash/cardcreator/1.res+1−1 tests/plugins/Dash/cardcreator/3.res+1−1 tests/plugins/Dash/cardcreator/4.res+2−2 tests/plugins/Dash/cardcreator/5.res+1−1 tests/plugins/Dash/tst_CroppedImageMinimumSourceSize.qml+6−6
plugins/Dash/CardCreator.js+4−4
@@ -68,7 +68,7 @@ var kArtShapeHolderCode = 'Item { \n\
6868 objectName: "artShape"; \n\
6969 property bool doShapeItem: components["art"]["conciergeMode"] !== true; \n\
7070 visible: image.status == Image.Ready; \n\
71− readonly property alias image: artImage.image; \n\
71+ readonly property alias image: artImage; \n\
7272 property alias borderSource: artShapeShape.borderSource; \n\
7373 ShaderEffectSource { \n\
7474 id: artShapeSource; \n\
@@ -195,11 +195,11 @@ var kMascotShapeLoaderCode = 'Loader { \n\
195195 id: mascotShapeLoader; \n\
196196 objectName: "mascotShapeLoader"; \n\
197197 asynchronous: root.asynchronous; \n\
198− active: mascotImage.image.status === Image.Ready; \n\
198+ active: mascotImage.status === Image.Ready; \n\
199199 visible: showHeader && active && status == Loader.Ready; \n\
200200 width: units.gu(6); \n\
201201 height: units.gu(5.625); \n\
202− sourceComponent: UbuntuShape { image: mascotImage.image } \n\
202+ sourceComponent: UbuntuShape { image: mascotImage } \n\
203203 anchors { %1 } \n\
204204 }\n';
205205
@@ -476,7 +476,7 @@ function cardString(template, components) {
476476 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
477477 var fallback = components["mascot"] && components["mascot"]["fallback"] || "";
478478 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);
480480 }
481481 }
482482
plugins/Dash/CroppedImageMinimumSourceSize.qml+5−17
@@ -16,24 +16,12 @@
1616
1717import QtQuick 2.3
1818
19−Item {
19+Image {
2020 id: root
2121
22− property alias image: innerImage
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
22+ fillMode: Image.PreserveAspectCrop
2823
29− Image {
30− id: innerImage
31−
32− anchors.fill: parent
33− fillMode: Image.PreserveAspectCrop
34−
35− readonly property real itemAspectRatio: width / height
36− readonly property real imageAspectRatio: implicitWidth / implicitHeight
37− sourceSize: (imageAspectRatio > itemAspectRatio) ? Qt.size(0, height) : Qt.size(width, 0)
38− }
24+ readonly property real itemAspectRatio: width / height
25+ readonly property real imageAspectRatio: implicitWidth / implicitHeight
26+ sourceSize: (imageAspectRatio > itemAspectRatio) ? Qt.size(0, height) : Qt.size(width, 0)
3927}
tests/plugins/Dash/cardcreator/1.res+1−1
@@ -32,7 +32,7 @@ Item {
3232 objectName: "artShape";
3333 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
3434 visible: image.status == Image.Ready;
35− readonly property alias image: artImage.image;
35+ readonly property alias image: artImage;
3636 property alias borderSource: artShapeShape.borderSource;
3737 ShaderEffectSource {
3838 id: artShapeSource;
tests/plugins/Dash/cardcreator/3.res+1−1
@@ -32,7 +32,7 @@ Item {
3232 objectName: "artShape";
3333 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
3434 visible: image.status == Image.Ready;
35− readonly property alias image: artImage.image;
35+ readonly property alias image: artImage;
3636 property alias borderSource: artShapeShape.borderSource;
3737 ShaderEffectSource {
3838 id: artShapeSource;
tests/plugins/Dash/cardcreator/4.res+2−2
@@ -34,11 +34,11 @@ Loader {
3434 id: mascotShapeLoader;
3535 objectName: "mascotShapeLoader";
3636 asynchronous: root.asynchronous;
37− active: mascotImage.image.status === Image.Ready;
37+ active: mascotImage.status === Image.Ready;
3838 visible: showHeader && active && status == Loader.Ready;
3939 width: units.gu(6);
4040 height: units.gu(5.625);
41− sourceComponent: UbuntuShape { image: mascotImage.image }
41+ sourceComponent: UbuntuShape { image: mascotImage }
4242 anchors { verticalCenter: parent.verticalCenter; }
4343 }
4444
tests/plugins/Dash/cardcreator/5.res+1−1
@@ -32,7 +32,7 @@ Item {
3232 objectName: "artShape";
3333 property bool doShapeItem: components["art"]["conciergeMode"] !== true;
3434 visible: image.status == Image.Ready;
35− readonly property alias image: artImage.image;
35+ readonly property alias image: artImage;
3636 property alias borderSource: artShapeShape.borderSource;
3737 ShaderEffectSource {
3838 id: artShapeSource;
tests/plugins/Dash/tst_CroppedImageMinimumSourceSize.qml+6−6
@@ -41,16 +41,16 @@ Rectangle {
4141 when: windowShown
4242
4343 function test_croppedSource() {
44− tryCompare(cimss.image.sourceSize, "width", 100);
45− tryCompare(cimss.image.sourceSize, "height", 0);
44+ tryCompare(cimss.sourceSize, "width", 100);
45+ tryCompare(cimss.sourceSize, "height", 0);
4646
4747 cimss.width = 40;
48− tryCompare(cimss.image.sourceSize, "width", 0);
49− tryCompare(cimss.image.sourceSize, "height", 100);
48+ tryCompare(cimss.sourceSize, "width", 0);
49+ tryCompare(cimss.sourceSize, "height", 100);
5050
5151 cimss.width = 100;
52− tryCompare(cimss.image.sourceSize, "width", 100);
53− tryCompare(cimss.image.sourceSize, "height", 0);
52+ tryCompare(cimss.sourceSize, "width", 100);
53+ tryCompare(cimss.sourceSize, "height", 0);
5454 }
5555 }
5656}