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
|
readonly property alias bY: cropImageModal.bY
|
||||||
|
|
||||||
property string selectedImage
|
property string selectedImage
|
||||||
|
property string currentProfileImg: ""
|
||||||
property string croppedImg: ""
|
property string croppedImg: ""
|
||||||
property string uploadError
|
property string uploadError
|
||||||
|
|
||||||
signal profileImageReady(string croppedImg)
|
signal setProfileImage(string image)
|
||||||
|
|
||||||
onClosed: {
|
onClosed: {
|
||||||
popup.selectedImage = ""
|
popup.selectedImage = ""
|
||||||
|
@ -43,7 +44,7 @@ StatusModal {
|
||||||
height: 160
|
height: 160
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
image.source: popup.croppedImg
|
image.source: popup.croppedImg || popup.currentProfileImg
|
||||||
showLoadingIndicator: true
|
showLoadingIndicator: true
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: Style.current.border
|
border.color: Style.current.border
|
||||||
|
@ -73,20 +74,31 @@ StatusModal {
|
||||||
ImageCropperModal {
|
ImageCropperModal {
|
||||||
id: cropImageModal
|
id: cropImageModal
|
||||||
ratio: "1:1"
|
ratio: "1:1"
|
||||||
|
selectedImage: popup.selectedImage
|
||||||
onCropFinished: {
|
onCropFinished: {
|
||||||
popup.croppedImg = OnboardingStore.uploadImage(selectedImage, aX, aY, bX, bY);
|
popup.croppedImg = OnboardingStore.generateImage(popup.selectedImage, aX, aY, bX, bY);
|
||||||
popup.selectedImage = ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rightButtons: [
|
rightButtons: [
|
||||||
|
StatusFlatButton {
|
||||||
|
visible: !!popup.currentProfileImg
|
||||||
|
type: StatusBaseButton.Type.Danger
|
||||||
|
text: qsTr("Remove")
|
||||||
|
onClicked: {
|
||||||
|
OnboardingStore.clearImageProps()
|
||||||
|
popup.setProfileImage("")
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
},
|
||||||
StatusButton {
|
StatusButton {
|
||||||
id: uploadBtn
|
id: uploadBtn
|
||||||
text: popup.croppedImg? qsTr("Done") : qsTr("Upload")
|
text: popup.croppedImg? qsTr("Done") : qsTr("Upload")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (popup.croppedImg) {
|
if (popup.croppedImg) {
|
||||||
popup.profileImageReady(popup.croppedImg)
|
OnboardingStore.setImageProps(popup.selectedImage, aX, aY, bX, bY)
|
||||||
|
popup.setProfileImage(popup.croppedImg)
|
||||||
close();
|
close();
|
||||||
} else {
|
} else {
|
||||||
imageDialog.open();
|
imageDialog.open();
|
||||||
|
@ -101,7 +113,7 @@ StatusModal {
|
||||||
]
|
]
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if(imageDialog.fileUrls.length > 0) {
|
if(imageDialog.fileUrls.length > 0) {
|
||||||
cropImageModal.selectedImage = imageDialog.fileUrls[0];
|
popup.selectedImage = imageDialog.fileUrls[0];
|
||||||
cropImageModal.open()
|
cropImageModal.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,14 +48,20 @@ QtObject {
|
||||||
root.profileModule.upload(root.profImgUrl, root.profImgAX, root.profImgAY, root.profImgBX, root.profImgBY);
|
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.profImgUrl = source;
|
||||||
root.profImgAX = aX;
|
root.profImgAX = aX;
|
||||||
root.profImgAY = aY;
|
root.profImgAY = aY;
|
||||||
root.profImgBX = bX;
|
root.profImgBX = bX;
|
||||||
root.profImgBY = bY;
|
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() {
|
function removeImage() {
|
||||||
|
|
|
@ -100,7 +100,7 @@ Item {
|
||||||
type: StatusFlatRoundButton.Type.Secondary
|
type: StatusFlatRoundButton.Type.Secondary
|
||||||
icon.name: "add"
|
icon.name: "add"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
uploadProfilePicPopup.selectedImage = userImage.image.source
|
uploadProfilePicPopup.currentProfileImg = userImage.image.source
|
||||||
uploadProfilePicPopup.open();
|
uploadProfilePicPopup.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,8 +188,8 @@ Item {
|
||||||
UploadProfilePicModal {
|
UploadProfilePicModal {
|
||||||
id: uploadProfilePicPopup
|
id: uploadProfilePicPopup
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
onProfileImageReady: {
|
onSetProfileImage: {
|
||||||
userImage.image.source = croppedImg
|
userImage.image.source = image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue