fix(@desktop/onboarding): it's impossible to delete a profile image on the onboarding page
Fixes #5240
This commit is contained in:
parent
e9e8ced591
commit
dfefeae026
|
@ -25,10 +25,11 @@ StatusModal {
|
|||
readonly property alias bY: cropImageModal.bY
|
||||
|
||||
property string selectedImage
|
||||
property string currentProfileImg: ""
|
||||
property string croppedImg: ""
|
||||
property string uploadError
|
||||
|
||||
signal profileImageReady(string croppedImg)
|
||||
signal setProfileImage(string image)
|
||||
|
||||
onClosed: {
|
||||
popup.selectedImage = ""
|
||||
|
@ -43,7 +44,7 @@ StatusModal {
|
|||
height: 160
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
image.source: popup.croppedImg
|
||||
image.source: popup.croppedImg || popup.currentProfileImg
|
||||
showLoadingIndicator: true
|
||||
border.width: 1
|
||||
border.color: Style.current.border
|
||||
|
@ -73,20 +74,31 @@ StatusModal {
|
|||
ImageCropperModal {
|
||||
id: cropImageModal
|
||||
ratio: "1:1"
|
||||
selectedImage: popup.selectedImage
|
||||
onCropFinished: {
|
||||
popup.croppedImg = OnboardingStore.uploadImage(selectedImage, aX, aY, bX, bY);
|
||||
popup.selectedImage = ""
|
||||
popup.croppedImg = OnboardingStore.generateImage(popup.selectedImage, aX, aY, bX, bY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rightButtons: [
|
||||
StatusFlatButton {
|
||||
visible: !!popup.currentProfileImg
|
||||
type: StatusBaseButton.Type.Danger
|
||||
text: qsTr("Remove")
|
||||
onClicked: {
|
||||
OnboardingStore.clearImageProps()
|
||||
popup.setProfileImage("")
|
||||
close();
|
||||
}
|
||||
},
|
||||
StatusButton {
|
||||
id: uploadBtn
|
||||
text: popup.croppedImg? qsTr("Done") : qsTr("Upload")
|
||||
onClicked: {
|
||||
if (popup.croppedImg) {
|
||||
popup.profileImageReady(popup.croppedImg)
|
||||
OnboardingStore.setImageProps(popup.selectedImage, aX, aY, bX, bY)
|
||||
popup.setProfileImage(popup.croppedImg)
|
||||
close();
|
||||
} else {
|
||||
imageDialog.open();
|
||||
|
@ -101,7 +113,7 @@ StatusModal {
|
|||
]
|
||||
onAccepted: {
|
||||
if(imageDialog.fileUrls.length > 0) {
|
||||
cropImageModal.selectedImage = imageDialog.fileUrls[0];
|
||||
popup.selectedImage = imageDialog.fileUrls[0];
|
||||
cropImageModal.open()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,14 +48,20 @@ QtObject {
|
|||
root.profileModule.upload(root.profImgUrl, root.profImgAX, root.profImgAY, root.profImgBX, root.profImgBY);
|
||||
}
|
||||
|
||||
function uploadImage(source, aX, aY, bX, bY) {
|
||||
function setImageProps(source, aX, aY, bX, bY) {
|
||||
root.profImgUrl = source;
|
||||
root.profImgAX = aX;
|
||||
root.profImgAY = aY;
|
||||
root.profImgBX = bX;
|
||||
root.profImgBY = bY;
|
||||
}
|
||||
|
||||
return root.generateImage(source, aX, aY, bX, bY)
|
||||
function clearImageProps() {
|
||||
root.profImgUrl = "";
|
||||
root.profImgAX = 0.0;
|
||||
root.profImgAY = 0.0;
|
||||
root.profImgBX = 0.0;
|
||||
root.profImgBY = 0.0;
|
||||
}
|
||||
|
||||
function removeImage() {
|
||||
|
|
|
@ -100,7 +100,7 @@ Item {
|
|||
type: StatusFlatRoundButton.Type.Secondary
|
||||
icon.name: "add"
|
||||
onClicked: {
|
||||
uploadProfilePicPopup.selectedImage = userImage.image.source
|
||||
uploadProfilePicPopup.currentProfileImg = userImage.image.source
|
||||
uploadProfilePicPopup.open();
|
||||
}
|
||||
}
|
||||
|
@ -188,8 +188,8 @@ Item {
|
|||
UploadProfilePicModal {
|
||||
id: uploadProfilePicPopup
|
||||
anchors.centerIn: parent
|
||||
onProfileImageReady: {
|
||||
userImage.image.source = croppedImg
|
||||
onSetProfileImage: {
|
||||
userImage.image.source = image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue