fix(MyProfileSettingsView): Temporary image cropped properly

Closes #8520
This commit is contained in:
Michał Cieślak 2022-12-01 09:37:46 +01:00 committed by Michał
parent b64dcaa14f
commit 4de8c6c313
2 changed files with 38 additions and 2 deletions

View File

@ -32,7 +32,7 @@ ColumnLayout {
property string displayName: descriptionPanel.displayName.text
property string bio: descriptionPanel.bio.text
property bool biomentricValue: biometricsSwitch.checked
property url profileLargeImage: profileHeader.icon
property url profileLargeImage: profileHeader.previewIcon
}
readonly property bool dirty: descriptionPanel.displayName.text !== profileStore.displayName ||

View File

@ -23,6 +23,7 @@ Item {
property string displayName
property string pubkey
property string icon
property url previewIcon: icon
property int trustStatus
property bool isContact: false
property bool isCurrentUser
@ -42,6 +43,10 @@ Item {
signal clicked()
signal editClicked()
Binding on previewIcon {
value: icon
}
height: visible ? contentContainer.height : 0
implicitHeight: contentContainer.implicitHeight
@ -56,6 +61,34 @@ Item {
}
}
Item {
id: tmpCroppedImageHelper
visible: false
Image {
id: tmpImage
mipmap: true
}
property var keepGrabResultAlive;
function setCroppedTmpIcon(source, x, y, width, height) {
tmpCroppedImageHelper.width = width
tmpCroppedImageHelper.height = height
tmpImage.x = -x
tmpImage.y = -y
tmpImage.source = source
tmpCroppedImageHelper.grabToImage(result => {
keepGrabResultAlive = result
root.previewIcon = result.url
tmpImage.source = ""
})
}
}
ColumnLayout {
id: contentContainer
@ -78,7 +111,7 @@ Item {
objectName: "ProfileHeader_userImage"
name: root.displayName
pubkey: root.pubkey
image: root.icon
image: root.previewIcon
interactive: false
imageWidth: d.getSize(36, 64, 160)
imageHeight: imageWidth
@ -110,6 +143,9 @@ Item {
function tempIcon(image, aX, aY, bX, bY) {
root.icon = image
root.cropRect = Qt.rect(aX, aY, bX - aX, bY - aY)
tmpCroppedImageHelper.setCroppedTmpIcon(
image, aX, aY, bX - aX, bY - aY)
}
}
}