2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-09-15 20:10:43 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-08-30 14:01:34 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.popups 1.0
|
2021-12-21 20:52:17 +00:00
|
|
|
import shared.stores 1.0
|
2022-03-09 10:27:32 +00:00
|
|
|
import shared.controls.chat 1.0
|
2020-06-04 10:30:49 +00:00
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
import StatusQ.Core 0.1
|
2021-08-30 14:01:34 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
StatusModal {
|
2020-06-04 10:30:49 +00:00
|
|
|
id: popup
|
2020-10-02 13:02:56 +00:00
|
|
|
|
|
|
|
property Popup parentPopup
|
|
|
|
|
2022-01-17 14:56:19 +00:00
|
|
|
property var profileStore
|
2021-12-31 12:29:51 +00:00
|
|
|
property var contactsStore
|
|
|
|
|
|
|
|
property string userPublicKey: ""
|
|
|
|
property string userDisplayName: ""
|
|
|
|
property string userName: ""
|
|
|
|
property string userNickname: ""
|
|
|
|
property string userEnsName: ""
|
|
|
|
property string userIcon: ""
|
|
|
|
property string text: ""
|
|
|
|
|
|
|
|
property bool userIsEnsVerified: false
|
|
|
|
property bool userIsBlocked: false
|
2021-07-22 17:08:37 +00:00
|
|
|
property bool isCurrentUser: false
|
2022-01-04 12:06:05 +00:00
|
|
|
property bool isAddedContact: false
|
2020-06-17 21:43:26 +00:00
|
|
|
|
2020-08-10 11:56:16 +00:00
|
|
|
signal blockButtonClicked(name: string, address: string)
|
2020-12-02 09:10:22 +00:00
|
|
|
signal unblockButtonClicked(name: string, address: string)
|
2020-08-10 12:15:57 +00:00
|
|
|
signal removeButtonClicked(address: string)
|
2020-08-10 11:56:16 +00:00
|
|
|
|
2020-12-02 09:10:22 +00:00
|
|
|
signal contactUnblocked(publicKey: string)
|
2020-10-02 14:37:51 +00:00
|
|
|
signal contactBlocked(publicKey: string)
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
function openPopup(publicKey, openNicknamePopup) {
|
2021-12-31 12:29:51 +00:00
|
|
|
// All this should be improved more, but for now we leave it like this.
|
|
|
|
let contactDetails = Utils.getContactDetailsAsJson(publicKey)
|
|
|
|
userPublicKey = publicKey
|
|
|
|
userDisplayName = contactDetails.displayName
|
|
|
|
userName = contactDetails.alias
|
|
|
|
userNickname = contactDetails.localNickname
|
|
|
|
userEnsName = contactDetails.name
|
2022-03-30 15:30:28 +00:00
|
|
|
userIcon = contactDetails.displayIcon
|
2021-12-31 12:29:51 +00:00
|
|
|
userIsEnsVerified = contactDetails.ensVerified
|
|
|
|
userIsBlocked = contactDetails.isBlocked
|
2022-01-04 12:06:05 +00:00
|
|
|
isAddedContact = contactDetails.isContact
|
2021-12-31 12:29:51 +00:00
|
|
|
|
|
|
|
text = "" // this is most likely unneeded
|
2022-01-17 14:56:19 +00:00
|
|
|
isCurrentUser = popup.profileStore.pubkey === publicKey
|
2021-12-31 12:29:51 +00:00
|
|
|
showFooter = !isCurrentUser
|
2020-06-17 21:43:26 +00:00
|
|
|
popup.open()
|
2022-03-15 15:55:18 +00:00
|
|
|
|
|
|
|
if (openNicknamePopup) {
|
|
|
|
nicknamePopup.open()
|
|
|
|
}
|
2020-06-17 21:43:26 +00:00
|
|
|
}
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
header.title: userDisplayName + qsTr("'s Profile")
|
2022-03-30 07:09:39 +00:00
|
|
|
header.subTitle: userIsEnsVerified ? userName : Utils.getElidedCompressedPk(userPublicKey)
|
2021-08-30 14:01:34 +00:00
|
|
|
header.subTitleElide: Text.ElideMiddle
|
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int contentSpacing: 5
|
|
|
|
readonly property int contentMargins: 16
|
|
|
|
}
|
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
headerActionButton: StatusFlatRoundButton {
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 20
|
|
|
|
icon.name: "qr"
|
2021-09-07 13:31:48 +00:00
|
|
|
onClicked: contentItem.qrCodePopup.open()
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
Component {
|
|
|
|
id: contactTopComponent
|
2020-06-23 19:04:08 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
ProfileHeader {
|
|
|
|
displayName: popup.userDisplayName
|
|
|
|
pubkey: popup.userPublicKey
|
|
|
|
icon: popup.isCurrentUser ? popup.profileStore.icon : popup.userIcon
|
2021-08-30 14:01:34 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
displayNameVisible: false
|
|
|
|
pubkeyVisible: false
|
|
|
|
compact: false
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
imageOverlay: Item {
|
|
|
|
visible: popup.isCurrentUser
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
StatusFlatRoundButton {
|
|
|
|
width: 24
|
|
|
|
height: 24
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
bottom: parent.bottom
|
|
|
|
rightMargin: -8
|
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
icon.name: "pencil"
|
|
|
|
icon.color: Theme.palette.directColor1
|
|
|
|
icon.width: 12.5
|
|
|
|
icon.height: 12.5
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
onClicked: Global.openChangeProfilePicPopup()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
contentItem: ColumnLayout {
|
|
|
|
id: modalContent
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
property alias qrCodePopup: qrCodePopup
|
|
|
|
property alias unblockContactConfirmationDialog: unblockContactConfirmationDialog
|
|
|
|
property alias blockContactConfirmationDialog: blockContactConfirmationDialog
|
|
|
|
property alias removeContactConfirmationDialog: removeContactConfirmationDialog
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.margins: d.contentMargins
|
|
|
|
spacing: d.contentSpacing
|
|
|
|
clip: true
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
Item {
|
|
|
|
implicitHeight: d.contentSpacing
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
Loader {
|
|
|
|
sourceComponent: contactTopComponent
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2022-02-04 10:21:05 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
StatusBanner {
|
|
|
|
visible: popup.userIsBlocked
|
|
|
|
type: StatusBanner.Type.Danger
|
|
|
|
statusText: qsTr("Blocked")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
StatusDescriptionListItem {
|
|
|
|
title: userIsEnsVerified ?
|
|
|
|
qsTr("ENS username") :
|
|
|
|
qsTr("Username")
|
|
|
|
subTitle: userIsEnsVerified ? userEnsName : userName
|
|
|
|
tooltip.text: qsTr("Copy to clipboard")
|
|
|
|
icon.name: "copy"
|
|
|
|
iconButton.onClicked: {
|
|
|
|
globalUtils.copyToClipboard(subTitle)
|
|
|
|
tooltip.visible = !tooltip.visible
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2021-08-30 14:01:34 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
StatusDescriptionListItem {
|
|
|
|
title: qsTr("Chat key")
|
|
|
|
subTitle: Utils.getCompressedPk(userPublicKey)
|
|
|
|
subTitleComponent.elide: Text.ElideMiddle
|
|
|
|
subTitleComponent.width: 320
|
|
|
|
subTitleComponent.font.family: Theme.palette.monoFont.name
|
|
|
|
tooltip.text: qsTr("Copy to clipboard")
|
|
|
|
icon.name: "copy"
|
|
|
|
iconButton.onClicked: {
|
|
|
|
globalUtils.copyToClipboard(subTitle)
|
|
|
|
tooltip.visible = !tooltip.visible
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2021-08-30 14:01:34 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
StatusDescriptionListItem {
|
|
|
|
title: qsTr("Share Profile URL")
|
|
|
|
subTitle: {
|
2022-01-17 14:56:19 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
let user = ""
|
|
|
|
if (isCurrentUser) {
|
|
|
|
user = popup.profileStore.ensName !== "" ? popup.profileStore.ensName :
|
|
|
|
(popup.profileStore.pubkey.substring(0, 5) + "..." + popup.profileStore.pubkey.substring(popup.profileStore.pubkey.length - 5))
|
|
|
|
} else if (userIsEnsVerified) {
|
|
|
|
user = userEnsName
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
|
|
|
|
if (user === ""){
|
|
|
|
user = userPublicKey.substr(0, 4) + "..." + userPublicKey.substr(userPublicKey.length - 5)
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
return Constants.userLinkPrefix + user;
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
tooltip.text: qsTr("Copy to clipboard")
|
|
|
|
icon.name: "copy"
|
|
|
|
iconButton.onClicked: {
|
|
|
|
let user = ""
|
|
|
|
if (isCurrentUser) {
|
|
|
|
user = popup.profileStore.ensName !== "" ? popup.profileStore.ensName : popup.profileStore.pubkey
|
|
|
|
} else {
|
|
|
|
user = (userEnsName !== "" ? userEnsName : userPublicKey)
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
popup.profileStore.copyToClipboard(Constants.userLinkPrefix + user)
|
|
|
|
tooltip.visible = !tooltip.visible
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2021-08-30 14:01:34 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
StatusDescriptionListItem {
|
|
|
|
visible: !isCurrentUser
|
|
|
|
title: qsTr("Chat settings")
|
|
|
|
subTitle: qsTr("Nickname")
|
|
|
|
value: userNickname ? userNickname : qsTr("None")
|
|
|
|
sensor.enabled: true
|
|
|
|
sensor.onClicked: {
|
|
|
|
nicknamePopup.open()
|
2021-08-30 14:01:34 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
Layout.fillWidth: true
|
2021-01-12 20:51:00 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
2021-01-12 20:51:00 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
// TODO: replace with StatusStackModal
|
|
|
|
ModalPopup {
|
|
|
|
id: qrCodePopup
|
|
|
|
width: 320
|
|
|
|
height: 320
|
|
|
|
Image {
|
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: globalUtils.qrCode(userPublicKey)
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
height: 212
|
|
|
|
width: 212
|
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
2020-12-04 13:51:25 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
UnblockContactConfirmationDialog {
|
|
|
|
id: unblockContactConfirmationDialog
|
|
|
|
onUnblockButtonClicked: {
|
|
|
|
popup.contactsStore.unblockContact(userPublicKey)
|
|
|
|
unblockContactConfirmationDialog.close();
|
|
|
|
popup.close()
|
|
|
|
popup.contactUnblocked(userPublicKey)
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
2020-09-15 20:10:43 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
|
|
|
popup.contactsStore.blockContact(userPublicKey)
|
|
|
|
blockContactConfirmationDialog.close();
|
|
|
|
popup.close()
|
2020-09-15 20:10:43 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
popup.contactBlocked(userPublicKey)
|
2020-09-15 20:10:43 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
2020-09-15 20:10:43 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
ConfirmationDialog {
|
|
|
|
id: removeContactConfirmationDialog
|
|
|
|
header.title: qsTr("Remove contact")
|
|
|
|
confirmationText: qsTr("Are you sure you want to remove this contact?")
|
|
|
|
onConfirmButtonClicked: {
|
|
|
|
if (isAddedContact) {
|
|
|
|
popup.contactsStore.removeContact(userPublicKey);
|
2020-09-16 16:00:21 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
removeContactConfirmationDialog.close();
|
|
|
|
popup.close();
|
2020-09-16 16:00:21 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
NicknamePopup {
|
|
|
|
id: nicknamePopup
|
|
|
|
nickname: popup.userNickname
|
|
|
|
header.subTitle: popup.header.subTitle
|
|
|
|
header.subTitleElide: popup.header.subTitleElide
|
|
|
|
onEditDone: {
|
|
|
|
if(popup.userNickname !== newNickname)
|
|
|
|
{
|
|
|
|
popup.userNickname = newNickname;
|
|
|
|
popup.contactsStore.changeContactNickname(userPublicKey, newNickname);
|
2020-09-28 14:31:00 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
popup.close()
|
2020-09-15 20:10:43 +00:00
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
// TODO: replace with StatusStackModal
|
|
|
|
SendContactRequestModal {
|
|
|
|
id: sendContactRequestModal
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: popup.width
|
|
|
|
height: popup.height
|
|
|
|
visible: false
|
|
|
|
header.title: qsTr("Send Contact Request to") + " " + userDisplayName
|
|
|
|
topComponent: contactTopComponent
|
|
|
|
onAccepted: popup.contactsStore.sendContactRequest(userPublicKey, message)
|
|
|
|
onClosed: popup.close()
|
|
|
|
}
|
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
rightButtons: [
|
|
|
|
StatusFlatButton {
|
2021-12-31 12:29:51 +00:00
|
|
|
text: userIsBlocked ?
|
2021-08-30 14:01:34 +00:00
|
|
|
qsTr("Unblock User") :
|
|
|
|
qsTr("Block User")
|
|
|
|
type: StatusBaseButton.Type.Danger
|
2020-10-02 14:37:51 +00:00
|
|
|
onClicked: {
|
2021-12-31 12:29:51 +00:00
|
|
|
if (userIsBlocked) {
|
2021-09-07 13:31:48 +00:00
|
|
|
contentItem.unblockContactConfirmationDialog.contactName = userName;
|
2021-12-31 12:29:51 +00:00
|
|
|
contentItem.unblockContactConfirmationDialog.contactAddress = userPublicKey;
|
2021-09-07 13:31:48 +00:00
|
|
|
contentItem.unblockContactConfirmationDialog.open();
|
2020-12-02 09:10:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-09-07 14:30:33 +00:00
|
|
|
contentItem.blockContactConfirmationDialog.contactName = userName;
|
2021-12-31 12:29:51 +00:00
|
|
|
contentItem.blockContactConfirmationDialog.contactAddress = userPublicKey;
|
2021-09-07 13:31:48 +00:00
|
|
|
contentItem.blockContactConfirmationDialog.open();
|
2020-10-02 14:37:51 +00:00
|
|
|
}
|
2021-08-30 14:01:34 +00:00
|
|
|
},
|
2020-06-11 08:22:20 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
StatusFlatButton {
|
2022-01-04 12:06:05 +00:00
|
|
|
visible: !userIsBlocked && isAddedContact
|
2021-08-30 14:01:34 +00:00
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
text: qsTr('Remove Contact')
|
2020-06-23 19:04:08 +00:00
|
|
|
onClicked: {
|
2021-09-07 13:31:48 +00:00
|
|
|
contentItem.removeContactConfirmationDialog.parentPopup = popup;
|
|
|
|
contentItem.removeContactConfirmationDialog.open();
|
2020-06-19 17:18:04 +00:00
|
|
|
}
|
2021-08-30 14:01:34 +00:00
|
|
|
},
|
2021-01-11 20:59:05 +00:00
|
|
|
|
|
|
|
StatusButton {
|
2022-06-20 11:54:17 +00:00
|
|
|
text: qsTr("Send Contact Request")
|
2022-01-04 12:06:05 +00:00
|
|
|
visible: !userIsBlocked && !isAddedContact
|
2022-06-20 11:54:17 +00:00
|
|
|
onClicked: sendContactRequestModal.open()
|
2021-01-12 20:51:00 +00:00
|
|
|
}
|
2021-08-30 14:01:34 +00:00
|
|
|
]
|
2020-06-04 10:30:49 +00:00
|
|
|
}
|