on xenial help sign in
better lazy image scaling
4be5ae1Nick Dedekind
qml/Components/LazyImage.qml+2
@@ -29,6 +29,7 @@ Item {
29
29
30 property real initialWidth: scaleTo == "width" || scaleTo == "fit" ? width : units.gu(10)
30 property real initialWidth: scaleTo == "width" || scaleTo == "fit" ? width : units.gu(10)
31 property real initialHeight: scaleTo == "height" || scaleTo == "fit" ? height : units.gu(10)
31 property real initialHeight: scaleTo == "height" || scaleTo == "fit" ? height : units.gu(10)
32+ property real lastScaledDimension: scaleTo == "height" || scaleTo == "fit" ? width : height
32
33
33 property alias sourceSize: image.sourceSize
34 property alias sourceSize: image.sourceSize
34 property alias fillMode: image.fillMode
35 property alias fillMode: image.fillMode
@@ -157,6 +158,7 @@ Item {
157 easing.type: Easing.Linear; duration: UbuntuAnimation.SnapDuration
158 easing.type: Easing.Linear; duration: UbuntuAnimation.SnapDuration
158 }
159 }
159 }
160 }
161+ ScriptAction { script: { lastScaledDimension = scaleTo == "height" || scaleTo == "fit" ? root.width : root.height } }
160 }
162 }
161 },
163 },
162
164
qml/Components/MediaServices/VideoPlayer.qml+3−2
@@ -67,7 +67,8 @@ Item {
67 }
67 }
68 anchors.verticalCenter: parent.verticalCenter
68 anchors.verticalCenter: parent.verticalCenter
69 scaleTo: "width"
69 scaleTo: "width"
70− initialHeight: width * 10 / 16
70+ initialHeight: lastScaledDimension
71+
71 visible: !mediaPlayer || mediaPlayer.playbackState === MediaPlayer.StoppedState
72 visible: !mediaPlayer || mediaPlayer.playbackState === MediaPlayer.StoppedState
72 }
73 }
73
74
@@ -81,7 +82,7 @@ Item {
81 return root.height;
82 return root.height;
82 }
83 }
83 var proposedHeight = mediaPlayer && mediaPlayer.metaData.resolution !== undefined ?
84 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 :
85 image.height;
86 image.height;
86 if (maximumEmbeddedHeight !== undefined && maximumEmbeddedHeight < proposedHeight) {
87 if (maximumEmbeddedHeight !== undefined && maximumEmbeddedHeight < proposedHeight) {
87 return maximumEmbeddedHeight;
88 return maximumEmbeddedHeight;