fix(desktop/profile): Does not apply avatar icon if quitted popup

Apply avatar icon only if the user accepts it.

Fix #5238
This commit is contained in:
Michal Iskierko 2022-04-04 14:45:27 +02:00 committed by Iuri Matias
parent 684a1ce913
commit 268f6ef4eb
3 changed files with 13 additions and 9 deletions

View File

@ -20,11 +20,10 @@ StatusModal {
property string selectedImage property string selectedImage
property string uploadError property string uploadError
onSelectedImageChanged: { signal accepted()
if (!selectedImage) {
return; onOpened: {
} selectedImage = ""
cropImageModal.open();
} }
contentItem: Item { contentItem: Item {
@ -57,9 +56,9 @@ StatusModal {
ImageCropperModal { ImageCropperModal {
id: cropImageModal id: cropImageModal
selectedImage: popup.selectedImage
ratio: "1:1" ratio: "1:1"
onCropFinished: { onCropFinished: {
popup.selectedImage = selectedImage
OnboardingStore.uploadImage(selectedImage, aX, aY, bX, bY); OnboardingStore.uploadImage(selectedImage, aX, aY, bX, bY);
} }
} }
@ -71,6 +70,7 @@ StatusModal {
text: !!selectedImage ? qsTr("Done") : qsTr("Upload") text: !!selectedImage ? qsTr("Done") : qsTr("Upload")
onClicked: { onClicked: {
if (!!selectedImage) { if (!!selectedImage) {
popup.accepted()
close(); close();
} else { } else {
imageDialog.open(); imageDialog.open();
@ -84,7 +84,8 @@ StatusModal {
qsTrId("image-files----jpg---jpeg---png-") qsTrId("image-files----jpg---jpeg---png-")
] ]
onAccepted: { onAccepted: {
selectedImage = imageDialog.fileUrls[0]; cropImageModal.selectedImage = imageDialog.fileUrls[0];
cropImageModal.open()
} }
} }
} }

View File

@ -81,7 +81,6 @@ Item {
icon.color: Theme.palette.miscColor5 icon.color: Theme.palette.miscColor5
icon.charactersLen: 2 icon.charactersLen: 2
image.isIdenticon: false image.isIdenticon: false
image.source: uploadProfilePicPopup.selectedImage
ringSettings { ringSpecModel: Utils.getColorHashAsJson(root.pubKey) } ringSettings { ringSpecModel: Utils.getColorHashAsJson(root.pubKey) }
} }
StatusRoundButton { StatusRoundButton {
@ -180,6 +179,9 @@ Item {
UploadProfilePicModal { UploadProfilePicModal {
id: uploadProfilePicPopup id: uploadProfilePicPopup
anchors.centerIn: parent anchors.centerIn: parent
onAccepted: {
userImage.image.source = uploadProfilePicPopup.selectedImage
}
} }
} }

View File

@ -67,10 +67,11 @@ Popup {
objectName: "titleText" objectName: "titleText"
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 44
font.bold: true font.bold: true
font.pixelSize: 17 font.pixelSize: 17
height: visible ? 24 : 0 height: visible ? 24 : 0
width: visible ? parent.width - 44 : 0
elide: Text.ElideRight elide: Text.ElideRight
visible: !!title visible: !!title
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter