2020-11-30 17:03:52 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
property string selectedImage // selectedImage is for us to be able to analyze it before setting it as current
|
|
|
|
property string uploadError
|
|
|
|
|
|
|
|
id: popup
|
|
|
|
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Profile picture"
|
|
|
|
title: qsTrId("profile-picture")
|
2020-11-30 17:03:52 +00:00
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
onSelectedImageChanged: {
|
|
|
|
if (!selectedImage) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cropImageModal.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
RoundedImage {
|
|
|
|
id: profilePic
|
|
|
|
source: profileModel.profile.largeImage
|
|
|
|
width: 160
|
|
|
|
height: 160
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
border.width: 1
|
|
|
|
border.color: Style.current.border
|
|
|
|
onClicked: imageDialog.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
visible: !!uploadError
|
|
|
|
text: uploadError
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: profilePic.bottom
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
font.pixelSize: 13
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
anchors.topMargin: 13
|
|
|
|
font.weight: Font.Thin
|
|
|
|
color: Style.current.danger
|
|
|
|
}
|
|
|
|
|
2021-02-10 20:37:17 +00:00
|
|
|
ImageCropperModal {
|
2020-11-30 17:03:52 +00:00
|
|
|
id: cropImageModal
|
|
|
|
|
2021-02-10 20:37:17 +00:00
|
|
|
selectedImage: popup.selectedImage
|
|
|
|
onCropFinished: {
|
|
|
|
uploadError = profileModel.uploadNewProfilePic(selectedImage, aX, aY, bX, bY)
|
2020-11-30 17:03:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
2021-01-13 19:15:52 +00:00
|
|
|
width: parent.width
|
|
|
|
height: uploadBtn.height
|
2020-11-30 17:03:52 +00:00
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
visible: profileModel.profile.hasIdentityImage
|
|
|
|
type: "secondary"
|
|
|
|
flat: true
|
|
|
|
color: Style.current.danger
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Remove"
|
|
|
|
text: qsTrId("remove")
|
2020-11-30 17:03:52 +00:00
|
|
|
anchors.right: uploadBtn.left
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
onClicked: {
|
|
|
|
uploadError = profileModel.deleteProfilePic()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: uploadBtn
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Upload"
|
|
|
|
text: qsTrId("upload")
|
2020-11-30 17:03:52 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
onClicked: {
|
|
|
|
imageDialog.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
id: imageDialog
|
|
|
|
//% "Please choose an image"
|
|
|
|
title: qsTrId("please-choose-an-image")
|
|
|
|
folder: shortcuts.pictures
|
|
|
|
nameFilters: [
|
|
|
|
//% "Image files (*.jpg *.jpeg *.png)"
|
|
|
|
qsTrId("image-files----jpg---jpeg---png-")
|
|
|
|
]
|
|
|
|
onAccepted: {
|
|
|
|
selectedImage = imageDialog.fileUrls[0]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|