better lazy image scaling
commit4be5ae1643c5c11ddf75a7cd2b2ef91125d5273a
authorNick Dedekind <nick.dedekind@canonical.com>
dateFri 19 Jun 2015, 17:32 (11 years ago)
parent83db16e
qml/Components/LazyImage.qml+2
@@ -29,6 +29,7 @@ Item {
2929
3030 property real initialWidth: scaleTo == "width" || scaleTo == "fit" ? width : units.gu(10)
3131 property real initialHeight: scaleTo == "height" || scaleTo == "fit" ? height : units.gu(10)
32+ property real lastScaledDimension: scaleTo == "height" || scaleTo == "fit" ? width : height
3233
3334 property alias sourceSize: image.sourceSize
3435 property alias fillMode: image.fillMode
@@ -157,6 +158,7 @@ Item {
157158 easing.type: Easing.Linear; duration: UbuntuAnimation.SnapDuration
158159 }
159160 }
161+ ScriptAction { script: { lastScaledDimension = scaleTo == "height" || scaleTo == "fit" ? root.width : root.height } }
160162 }
161163 },
162164
qml/Components/MediaServices/VideoPlayer.qml+3−2
@@ -67,7 +67,8 @@ Item {
6767 }
6868 anchors.verticalCenter: parent.verticalCenter
6969 scaleTo: "width"
70− initialHeight: width * 10 / 16
70+ initialHeight: lastScaledDimension
71+
7172 visible: !mediaPlayer || mediaPlayer.playbackState === MediaPlayer.StoppedState
7273 }
7374
@@ -81,7 +82,7 @@ Item {
8182 return root.height;
8283 }
8384 var proposedHeight = mediaPlayer && mediaPlayer.metaData.resolution !== undefined ?
84− (mediaPlayer.metaData.resolution.height / mediaPlayer.metaData.resolution.width ) * width :
85+ (mediaPlayer.metaData.resolution.height / mediaPlayer.metaData.resolution.width) * width :
8586 image.height;
8687 if (maximumEmbeddedHeight !== undefined && maximumEmbeddedHeight < proposedHeight) {
8788 return maximumEmbeddedHeight;