Workaround for mipmap issue with Image

See https://bugreports-test.qt.io/browse/QTBUG-105277 for background
This commit is contained in:
Bart De Vries 2024-04-22 11:13:54 +02:00
parent acbf4c605f
commit b6da9407c7
No known key found for this signature in database
GPG Key ID: 7285665DA6E2D42B
2 changed files with 12 additions and 12 deletions

View File

@ -137,8 +137,10 @@ FocusScope {
Layout.preferredWidth: height
Layout.minimumHeight: Kirigami.Units.gridUnit * 1.5
absoluteRadius: Kirigami.Units.smallSpacing
// resizing the image is very stuttering when the header is resized; relying on mipmap to do the smoothing
imageResize: false
mipmap: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor

View File

@ -25,15 +25,6 @@ Item {
property bool isLoading: false
property int imageFillMode: Image.PreserveAspectCrop
property bool imageResize: true
property bool mipmap: false
// HACK: if mipmap has been set to true, then reset it AFTER image has
// changed, otherwise it will be ignored
onImageSourceChanged: {
if (root.mipmap) {
root.mipmap = true;
}
}
Loader {
id: imageLoader
@ -67,10 +58,17 @@ Item {
anchors.fill: parent
source: root.imageSource
fillMode: root.imageFillMode
asynchronous: true
// mipmap = smooth image at smaller sizes than original
// needs to be a fixed value; bindings will break the behaviour,
// see: https://bugreports-test.qt.io/browse/QTBUG-105277
mipmap: true
// still resizing images despite mipmap for non-resizable images
// since it gives much better (i.e. non-blurry) results
sourceSize.width: root.imageResize ? width * Screen.devicePixelRatio : 0
sourceSize.height: root.imageResize ? height * Screen.devicePixelRatio : 0
asynchronous: true
mipmap: root.mipmap
}
}