2022-03-07 22:59:38 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
2022-04-07 20:07:52 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2022-03-07 22:59:38 +00:00
|
|
|
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
|
2022-04-07 20:07:52 +00:00
|
|
|
StatusModal {
|
2022-03-07 22:59:38 +00:00
|
|
|
id: popup
|
2022-04-08 09:49:32 +00:00
|
|
|
|
2022-04-07 20:07:52 +00:00
|
|
|
height: 510
|
|
|
|
header.title: qsTr("Upload profile picture")
|
|
|
|
|
2022-04-08 09:49:32 +00:00
|
|
|
readonly property alias aX: cropImageModal.aX
|
|
|
|
readonly property alias aY: cropImageModal.aY
|
|
|
|
readonly property alias bX: cropImageModal.bX
|
|
|
|
readonly property alias bY: cropImageModal.bY
|
|
|
|
|
2022-03-07 22:59:38 +00:00
|
|
|
property string selectedImage
|
|
|
|
property string uploadError
|
|
|
|
|
2022-04-04 12:45:27 +00:00
|
|
|
signal accepted()
|
|
|
|
|
2022-04-07 20:07:52 +00:00
|
|
|
contentItem: Item {
|
2022-03-07 22:59:38 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
RoundedImage {
|
|
|
|
id: profilePic
|
|
|
|
source: selectedImage
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageCropperModal {
|
|
|
|
id: cropImageModal
|
|
|
|
ratio: "1:1"
|
|
|
|
onCropFinished: {
|
2022-04-04 12:45:27 +00:00
|
|
|
popup.selectedImage = selectedImage
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 20:07:52 +00:00
|
|
|
rightButtons: [
|
2022-03-07 22:59:38 +00:00
|
|
|
StatusButton {
|
|
|
|
id: uploadBtn
|
|
|
|
text: !!selectedImage ? qsTr("Done") : qsTr("Upload")
|
|
|
|
onClicked: {
|
|
|
|
if (!!selectedImage) {
|
2022-04-04 12:45:27 +00:00
|
|
|
popup.accepted()
|
2022-03-07 22:59:38 +00:00
|
|
|
close();
|
|
|
|
} else {
|
|
|
|
imageDialog.open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FileDialog {
|
|
|
|
id: imageDialog
|
|
|
|
title: qsTrId("please-choose-an-image")
|
|
|
|
folder: shortcuts.pictures
|
|
|
|
nameFilters: [
|
|
|
|
qsTrId("image-files----jpg---jpeg---png-")
|
|
|
|
]
|
|
|
|
onAccepted: {
|
2022-04-06 09:50:25 +00:00
|
|
|
if(imageDialog.fileUrls.length > 0) {
|
|
|
|
cropImageModal.selectedImage = imageDialog.fileUrls[0];
|
|
|
|
cropImageModal.open()
|
|
|
|
}
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-07 20:07:52 +00:00
|
|
|
]
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
|
|
|
|