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
|
|
|
|
2020-06-04 10:30:49 +00:00
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
|
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
|
2021-08-30 14:01:34 +00:00
|
|
|
anchors.centerIn: parent
|
2020-10-02 13:02:56 +00:00
|
|
|
|
|
|
|
property Popup parentPopup
|
|
|
|
|
2020-09-17 14:26:26 +00:00
|
|
|
property var identicon: ""
|
|
|
|
property var userName: ""
|
2020-09-24 18:12:50 +00:00
|
|
|
property string nickname: ""
|
2020-09-17 14:26:26 +00:00
|
|
|
property var fromAuthor: ""
|
|
|
|
property var text: ""
|
|
|
|
property var alias: ""
|
2021-01-12 20:51:00 +00:00
|
|
|
|
|
|
|
readonly property int innerMargin: 20
|
2021-09-14 14:52:08 +00:00
|
|
|
|
2020-06-30 18:18:04 +00:00
|
|
|
property bool isEnsVerified: false
|
2020-07-09 17:12:28 +00:00
|
|
|
property bool noFooter: false
|
2020-12-02 09:10:22 +00:00
|
|
|
property bool isBlocked: false
|
2021-07-22 17:08:37 +00:00
|
|
|
property bool isCurrentUser: 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)
|
|
|
|
signal contactAdded(publicKey: string)
|
|
|
|
|
|
|
|
function openPopup(showFooter, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) {
|
2020-09-16 18:50:40 +00:00
|
|
|
userName = userNameParam || ""
|
2020-09-16 19:52:48 +00:00
|
|
|
nickname = nicknameParam || ""
|
2020-09-16 18:50:40 +00:00
|
|
|
fromAuthor = fromAuthorParam || ""
|
|
|
|
identicon = identiconParam || ""
|
|
|
|
text = textParam || ""
|
2021-06-17 13:51:59 +00:00
|
|
|
isEnsVerified = chatsModel.ensView.isEnsVerified(this.fromAuthor)
|
2020-12-06 22:15:51 +00:00
|
|
|
isBlocked = profileModel.contacts.isContactBlocked(this.fromAuthor);
|
2020-09-16 18:50:40 +00:00
|
|
|
alias = chatsModel.alias(this.fromAuthor) || ""
|
2021-07-22 17:08:37 +00:00
|
|
|
isCurrentUser = profileModel.profile.pubKey === this.fromAuthor
|
2020-10-02 13:02:56 +00:00
|
|
|
noFooter = !showFooter;
|
2020-06-17 21:43:26 +00:00
|
|
|
popup.open()
|
|
|
|
}
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
header.title: Utils.removeStatusEns(isCurrentUser ? profileModel.ens.preferredUsername || userName : userName)
|
|
|
|
header.subTitle: isEnsVerified ? alias : fromAuthor
|
|
|
|
header.subTitleElide: Text.ElideMiddle
|
|
|
|
header.image.source: identicon
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-09-02 14:40:10 +00:00
|
|
|
contentItem: Item {
|
2021-08-30 14:01:34 +00:00
|
|
|
width: popup.width
|
|
|
|
height: modalContent.height
|
2020-06-23 19:04:08 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
property alias qrCodePopup: qrCodePopup
|
|
|
|
property alias unblockContactConfirmationDialog: unblockContactConfirmationDialog
|
|
|
|
property alias blockContactConfirmationDialog: blockContactConfirmationDialog
|
|
|
|
property alias removeContactConfirmationDialog: removeContactConfirmationDialog
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: modalContent
|
2020-06-23 19:04:08 +00:00
|
|
|
anchors.top: parent.top
|
2021-08-30 14:01:34 +00:00
|
|
|
width: parent.width
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
Item {
|
|
|
|
height: 16
|
|
|
|
width: parent.width
|
|
|
|
}
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
StatusDescriptionListItem {
|
2021-09-14 14:52:08 +00:00
|
|
|
title: ((isCurrentUser && profileModel.ens.preferredUsername) || isEnsVerified) ? qsTr("ENS username") : qsTr("Username")
|
2021-08-30 14:01:34 +00:00
|
|
|
subTitle: isCurrentUser ? profileModel.ens.preferredUsername || userName : userName
|
|
|
|
tooltip.text: qsTr("Copy to clipboard")
|
|
|
|
icon.name: "copy"
|
|
|
|
iconButton.onClicked: {
|
|
|
|
chatsModel.copyToClipboard(userName)
|
|
|
|
tooltip.visible = !tooltip.visible
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusDescriptionListItem {
|
|
|
|
title: qsTr("Chat key")
|
|
|
|
subTitle: fromAuthor
|
|
|
|
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: {
|
|
|
|
chatsModel.copyToClipboard(fromAuthor)
|
|
|
|
tooltip.visible = !tooltip.visible
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusModalDivider {
|
|
|
|
topPadding: 12
|
|
|
|
bottomPadding: 16
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusDescriptionListItem {
|
|
|
|
title: qsTr("Share Profile URL")
|
|
|
|
subTitle: {
|
|
|
|
let user = ""
|
|
|
|
if (isCurrentUser) {
|
|
|
|
user = profileModel.ens.preferredUsername
|
|
|
|
} else {
|
|
|
|
if (isEnsVerified) {
|
|
|
|
user = userName.startsWith("@") ? userName.substring(1) : userName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (user === ""){
|
|
|
|
user = fromAuthor.substr(0, 4) + "..." + fromAuthor.substr(fromAuthor.length - 5)
|
|
|
|
}
|
|
|
|
return Constants.userLinkPrefix + user;
|
|
|
|
}
|
|
|
|
tooltip.text: qsTr("Copy to clipboard")
|
|
|
|
icon.name: "copy"
|
|
|
|
iconButton.onClicked: {
|
|
|
|
let user = ""
|
|
|
|
if (isCurrentUser) {
|
|
|
|
user = profileModel.ens.preferredUsername
|
|
|
|
} else {
|
|
|
|
if (isEnsVerified) {
|
|
|
|
user = userName.startsWith("@") ? userName.substring(1) : userName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (user === ""){
|
|
|
|
user = fromAuthor
|
|
|
|
}
|
|
|
|
|
|
|
|
chatsModel.copyToClipboard(Constants.userLinkPrefix + user)
|
|
|
|
tooltip.visible = !tooltip.visible
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusModalDivider {
|
|
|
|
topPadding: 8
|
|
|
|
bottomPadding: 12
|
|
|
|
}
|
2020-12-04 13:51:25 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
StatusDescriptionListItem {
|
|
|
|
title: qsTr("Chat settings")
|
|
|
|
subTitle: qsTr("Nickname")
|
|
|
|
value: nickname ? nickname : qsTr("None")
|
|
|
|
sensor.enabled: true
|
|
|
|
sensor.onClicked: {
|
|
|
|
nicknamePopup.open()
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: 16
|
|
|
|
}
|
2021-01-12 20:51:00 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 16:01:38 +00:00
|
|
|
ModalPopup {
|
2020-12-04 13:51:25 +00:00
|
|
|
id: qrCodePopup
|
2020-12-04 16:01:38 +00:00
|
|
|
width: 320
|
|
|
|
height: 320
|
2020-12-04 13:51:25 +00:00
|
|
|
Image {
|
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: profileModel.qrCode(fromAuthor)
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
height: 212
|
|
|
|
width: 212
|
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
UnblockContactConfirmationDialog {
|
|
|
|
id: unblockContactConfirmationDialog
|
|
|
|
onUnblockButtonClicked: {
|
|
|
|
profileModel.contacts.unblockContact(fromAuthor)
|
|
|
|
unblockContactConfirmationDialog.close();
|
|
|
|
popup.close()
|
|
|
|
popup.contactUnblocked(fromAuthor)
|
2021-07-22 17:08:37 +00:00
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
2020-09-15 20:10:43 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
|
|
|
profileModel.contacts.blockContact(fromAuthor)
|
|
|
|
blockContactConfirmationDialog.close();
|
|
|
|
popup.close()
|
2020-09-15 20:10:43 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
popup.contactBlocked(fromAuthor)
|
2020-09-15 20:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
ConfirmationDialog {
|
|
|
|
id: removeContactConfirmationDialog
|
2021-09-09 09:10:29 +00:00
|
|
|
header.title: qsTr("Remove contact")
|
2021-08-30 14:01:34 +00:00
|
|
|
confirmationText: qsTr("Are you sure you want to remove this contact?")
|
|
|
|
onConfirmButtonClicked: {
|
|
|
|
if (profileModel.contacts.isAdded(fromAuthor)) {
|
|
|
|
profileModel.contacts.removeContact(fromAuthor);
|
|
|
|
}
|
|
|
|
removeContactConfirmationDialog.close();
|
|
|
|
popup.close();
|
2020-09-16 16:00:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NicknamePopup {
|
|
|
|
id: nicknamePopup
|
2020-09-28 14:31:00 +00:00
|
|
|
changeUsername: function (newUsername) {
|
|
|
|
popup.userName = newUsername
|
|
|
|
}
|
|
|
|
changeNickname: function (newNickname) {
|
|
|
|
popup.nickname = newNickname
|
|
|
|
}
|
2020-09-15 20:10:43 +00:00
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
2020-06-09 10:05:25 +00:00
|
|
|
|
2021-08-30 14:01:34 +00:00
|
|
|
rightButtons: [
|
|
|
|
StatusFlatButton {
|
2021-01-11 20:59:05 +00:00
|
|
|
text: isBlocked ?
|
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: {
|
2020-12-02 09:10:22 +00:00
|
|
|
if (isBlocked) {
|
2021-09-07 13:31:48 +00:00
|
|
|
contentItem.unblockContactConfirmationDialog.contactName = userName;
|
|
|
|
contentItem.unblockContactConfirmationDialog.contactAddress = fromAuthor;
|
|
|
|
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-09-07 13:31:48 +00:00
|
|
|
contentItem.blockContactConfirmationDialog.contactAddress = fromAuthor;
|
|
|
|
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 {
|
2021-01-11 20:59:05 +00:00
|
|
|
property bool isAdded: profileModel.contacts.isAdded(fromAuthor)
|
2021-08-30 14:01:34 +00:00
|
|
|
visible: !isBlocked && isAdded
|
|
|
|
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 {
|
2021-08-30 14:01:34 +00:00
|
|
|
property bool isAdded: profileModel.contacts.isAdded(fromAuthor)
|
|
|
|
text: qsTr("Add to contacts")
|
|
|
|
visible: !isBlocked && !isAdded
|
2021-01-11 20:59:05 +00:00
|
|
|
onClicked: {
|
2021-08-30 14:01:34 +00:00
|
|
|
profileModel.contacts.addContact(fromAuthor);
|
|
|
|
popup.contactAdded(fromAuthor);
|
2021-01-12 20:51:00 +00:00
|
|
|
popup.close();
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 14:01:34 +00:00
|
|
|
]
|
2020-06-04 10:30:49 +00:00
|
|
|
}
|