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-06 11:12:11 +00:00
|
|
|
import StatusQ.Components 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-06 11:12:11 +00:00
|
|
|
import "../stores"
|
|
|
|
|
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-14 10:10:08 +00:00
|
|
|
property string currentProfileImg: ""
|
2022-04-06 11:12:11 +00:00
|
|
|
property string croppedImg: ""
|
2022-03-07 22:59:38 +00:00
|
|
|
|
2022-04-14 10:10:08 +00:00
|
|
|
signal setProfileImage(string image)
|
2022-04-06 11:12:11 +00:00
|
|
|
|
2022-05-04 13:40:45 +00:00
|
|
|
// Internals
|
|
|
|
//
|
|
|
|
onOpened: imageEditor.userSelectedImage = false
|
|
|
|
onClosed: popup.croppedImg = ""
|
2022-04-04 12:45:27 +00:00
|
|
|
|
2022-04-07 20:07:52 +00:00
|
|
|
contentItem: Item {
|
2022-03-07 22:59:38 +00:00
|
|
|
anchors.fill: parent
|
2022-05-04 13:40:45 +00:00
|
|
|
|
|
|
|
EditCroppedImagePanel {
|
|
|
|
id: imageEditor
|
|
|
|
|
2022-03-07 22:59:38 +00:00
|
|
|
width: 160
|
|
|
|
height: 160
|
2022-05-04 13:40:45 +00:00
|
|
|
anchors.centerIn: parent
|
2022-03-07 22:59:38 +00:00
|
|
|
|
2022-05-04 13:40:45 +00:00
|
|
|
imageFileDialogTitle: qsTr("Choose an image for profile picture")
|
|
|
|
title: qsTr("Profile picture")
|
|
|
|
acceptButtonText: qsTr("Make this my profile picture")
|
2022-03-07 22:59:38 +00:00
|
|
|
|
2022-05-04 13:40:45 +00:00
|
|
|
aspectRatio: 1
|
|
|
|
|
|
|
|
dataImage: popup.currentProfileImg
|
|
|
|
|
|
|
|
NoImageUploadedPanel {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
visible: imageEditor.nothingToShow
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 20:07:52 +00:00
|
|
|
rightButtons: [
|
2022-04-14 10:10:08 +00:00
|
|
|
StatusFlatButton {
|
|
|
|
visible: !!popup.currentProfileImg
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
text: qsTr("Remove")
|
|
|
|
onClicked: {
|
|
|
|
OnboardingStore.clearImageProps()
|
|
|
|
popup.setProfileImage("")
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
},
|
2022-03-07 22:59:38 +00:00
|
|
|
StatusButton {
|
|
|
|
id: uploadBtn
|
2022-05-04 13:40:45 +00:00
|
|
|
text: imageEditor.userSelectedImage ? qsTr("Upload") : qsTr("Done")
|
2022-03-07 22:59:38 +00:00
|
|
|
onClicked: {
|
2022-05-04 13:40:45 +00:00
|
|
|
if (imageEditor.userSelectedImage) {
|
|
|
|
popup.croppedImg = OnboardingStore.generateImage(imageEditor.source,
|
|
|
|
imageEditor.cropRect.x.toFixed(),
|
|
|
|
imageEditor.cropRect.y.toFixed(),
|
|
|
|
(imageEditor.cropRect.x + imageEditor.cropRect.width).toFixed(),
|
|
|
|
(imageEditor.cropRect.y + imageEditor.cropRect.height).toFixed())
|
2022-04-14 10:10:08 +00:00
|
|
|
popup.setProfileImage(popup.croppedImg)
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
2022-05-04 13:40:45 +00:00
|
|
|
close();
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-07 20:07:52 +00:00
|
|
|
]
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
|
|
|
|