Skip to content

Commit

Permalink
Fix image scaling on image open
Browse files Browse the repository at this point in the history
  • Loading branch information
curoviyxru committed Nov 4, 2023
1 parent f4d89cc commit 32f81be
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions qml/control/ImageViewer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ Item {
id: imageViewer

property int scaling: Math.min(100, Math.min(Math.floor(imageViewer.width / innerImage.sourceSize.width * 100), Math.floor(imageViewer.height / innerImage.sourceSize.height * 100)))
property url imageSource
onImageSourceChanged: {
scaling = Math.min(100, Math.min(Math.floor(imageViewer.width / innerImage.sourceSize.width * 100), Math.floor(imageViewer.height / innerImage.sourceSize.height * 100)))
}
property alias imageSource: innerImage.source

//TODO loading spinner

Expand Down Expand Up @@ -93,9 +90,14 @@ Item {

Image {
id: innerImage
source: imageSource
smooth: true

onStatusChanged: {
if (innerImage.status == Image.Ready) {
scaling = Math.min(100, Math.min(Math.floor(imageViewer.width / innerImage.sourceSize.width * 100), Math.floor(imageViewer.height / innerImage.sourceSize.height * 100)))
}
}

width: sourceSize.width * scaling / 100
height: sourceSize.height * scaling / 100

Expand Down

0 comments on commit 32f81be

Please sign in to comment.