2024-02-07 14:56:45 +00:00
|
|
|
import QtQuick 2.15
|
2024-09-06 15:55:44 +00:00
|
|
|
import QtQuick.Controls 2.15
|
2023-05-19 16:07:50 +00:00
|
|
|
|
|
|
|
import StatusQ.Popups 0.1
|
2024-05-13 08:05:53 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2023-05-19 16:07:50 +00:00
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
import shared.controls.chat 1.0
|
|
|
|
import shared.controls.chat.menuItems 1.0
|
|
|
|
|
|
|
|
StatusMenu {
|
|
|
|
id: root
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
property string publicKey: ""
|
|
|
|
property string displayName: ""
|
|
|
|
property string userIcon: ""
|
|
|
|
property int trustStatus: Constants.trustStatus.unknown
|
|
|
|
property int contactType: Constants.contactType.nonContact
|
|
|
|
property int onlineStatus: Constants.onlineStatus.unknown
|
|
|
|
property int profileType: Constants.profileType.regular
|
|
|
|
property bool ensVerified: false
|
|
|
|
property bool hasLocalNickname: false
|
2024-09-06 15:55:44 +00:00
|
|
|
property int chatType: Constants.chatType.unknown
|
|
|
|
property bool isAdmin: false
|
2024-10-22 12:39:42 +00:00
|
|
|
property var emojiHash: []
|
2024-09-06 15:55:44 +00:00
|
|
|
|
|
|
|
signal openProfileClicked
|
|
|
|
signal createOneToOneChat
|
|
|
|
signal reviewContactRequest
|
|
|
|
signal sendContactRequest
|
|
|
|
signal editNickname
|
|
|
|
signal removeNickname(string displayName)
|
|
|
|
signal unblockContact
|
|
|
|
signal markAsUntrusted
|
|
|
|
signal removeTrustStatus
|
|
|
|
signal removeContact
|
|
|
|
signal blockContact
|
2024-09-06 15:55:44 +00:00
|
|
|
signal removeFromGroup
|
2023-05-19 16:07:50 +00:00
|
|
|
|
|
|
|
ProfileHeader {
|
|
|
|
displayNameVisible: false
|
|
|
|
displayNamePlusIconsVisible: true
|
|
|
|
editButtonVisible: false
|
2024-09-06 15:55:44 +00:00
|
|
|
displayName: StatusQUtils.Emoji.parse(root.displayName, StatusQUtils.Emoji.size.verySmall)
|
|
|
|
pubkey: root.publicKey
|
2024-10-22 12:39:42 +00:00
|
|
|
emojiHash: root.emojiHash
|
2024-09-06 15:55:44 +00:00
|
|
|
icon: root.userIcon
|
|
|
|
trustStatus: root.profileType === Constants.profileType.regular ? root.trustStatus : Constants.trustStatus.unknown
|
|
|
|
isContact: root.profileType === Constants.profileType.regular ? root.contactType === Constants.contactType.contact : false
|
|
|
|
isBlocked: root.profileType === Constants.profileType.blocked
|
|
|
|
isCurrentUser: root.profileType === Constants.profileType.self
|
|
|
|
userIsEnsVerified: root.ensVerified
|
|
|
|
isBridgedAccount: root.profileType === Constants.profileType.bridged
|
2024-02-09 15:52:28 +00:00
|
|
|
Binding on onlineStatus {
|
2024-09-06 15:55:44 +00:00
|
|
|
value: root.onlineStatus
|
|
|
|
when: root.profileType !== Constants.profileType.bridged
|
2024-02-09 15:52:28 +00:00
|
|
|
}
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {
|
2024-10-24 21:39:05 +00:00
|
|
|
visible: root.profileType !== Constants.profileType.bridged
|
2023-05-19 16:07:50 +00:00
|
|
|
topPadding: root.topPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewProfileMenuItem {
|
|
|
|
id: viewProfileAction
|
2023-11-28 09:29:18 +00:00
|
|
|
objectName: "viewProfile_StatusItem"
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType !== Constants.profileType.bridged
|
2023-05-19 16:07:50 +00:00
|
|
|
onTriggered: {
|
2024-09-06 15:55:44 +00:00
|
|
|
root.openProfileClicked()
|
2023-05-19 16:07:50 +00:00
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Edit Nickname
|
|
|
|
StatusAction {
|
|
|
|
id: renameAction
|
|
|
|
objectName: "rename_StatusItem"
|
|
|
|
enabled: root.profileType === Constants.profileType.blocked || root.profileType === Constants.profileType.regular
|
|
|
|
text: root.hasLocalNickname ? qsTr("Edit nickname") : qsTr("Add nickname")
|
|
|
|
icon.name: "edit_pencil"
|
|
|
|
onTriggered: root.editNickname()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Review Contact Request
|
2024-02-29 21:01:33 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Review contact request")
|
|
|
|
objectName: "reviewContactRequest_StatusItem"
|
|
|
|
icon.name: "add-contact"
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.regular && root.contactType === Constants.contactType.contactRequestReceived
|
|
|
|
onTriggered: root.reviewContactRequest()
|
2024-02-29 21:01:33 +00:00
|
|
|
}
|
2024-02-07 14:56:45 +00:00
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Send Message
|
2023-05-19 16:07:50 +00:00
|
|
|
SendMessageMenuItem {
|
|
|
|
id: sendMessageMenuItem
|
2023-11-28 09:29:18 +00:00
|
|
|
objectName: "sendMessage_StatusItem"
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.regular && root.contactType === Constants.contactType.contact
|
2023-05-19 16:07:50 +00:00
|
|
|
onTriggered: {
|
2024-09-06 15:55:44 +00:00
|
|
|
root.createOneToOneChat()
|
2023-05-19 16:07:50 +00:00
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Send Contact Request
|
2023-05-19 16:07:50 +00:00
|
|
|
SendContactRequestMenuItem {
|
|
|
|
id: sendContactRequestMenuItem
|
2023-11-28 09:29:18 +00:00
|
|
|
objectName: "sendContactRequest_StatusItem"
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.regular && root.contactType === Constants.contactType.nonContact
|
|
|
|
onTriggered: root.sendContactRequest()
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
|
2024-02-07 14:56:45 +00:00
|
|
|
StatusMenuSeparator {
|
2024-09-06 15:55:44 +00:00
|
|
|
topPadding: root.topPadding
|
2024-10-24 21:39:05 +00:00
|
|
|
visible: root.profileType !== Constants.profileType.bridged &&
|
|
|
|
(removeNicknameAction.enabled || unblockAction.enabled || markUntrustworthyMenuItem.enabled || removeUntrustworthyMarkMenuItem.enabled || removeContactAction.enabled || blockMenuItem.enabled)
|
2024-02-07 14:56:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Remove Nickname
|
2024-02-14 12:52:54 +00:00
|
|
|
StatusAction {
|
2024-09-06 15:55:44 +00:00
|
|
|
id: removeNicknameAction
|
2024-02-14 12:52:54 +00:00
|
|
|
text: qsTr("Remove nickname")
|
|
|
|
icon.name: "delete"
|
|
|
|
type: StatusAction.Type.Danger
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: (root.profileType === Constants.profileType.blocked || root.profileType === Constants.profileType.regular) && root.hasLocalNickname
|
|
|
|
onTriggered: root.removeNickname(root.displayName)
|
2024-02-14 12:52:54 +00:00
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Unblock User
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
|
|
|
id: unblockAction
|
2023-11-28 09:29:18 +00:00
|
|
|
objectName: "unblock_StatusItem"
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.blocked
|
2024-02-07 14:56:45 +00:00
|
|
|
text: qsTr("Unblock user")
|
|
|
|
icon.name: "cancel"
|
|
|
|
type: StatusAction.Type.Danger
|
2024-09-06 15:55:44 +00:00
|
|
|
onTriggered: root.unblockContact()
|
2024-02-26 09:39:08 +00:00
|
|
|
}
|
2023-05-19 16:07:50 +00:00
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Remove from group")
|
|
|
|
objectName: "removeFromGroup_StatusItem"
|
|
|
|
icon.name: "remove-contact"
|
|
|
|
type: StatusAction.Type.Danger
|
|
|
|
enabled: root.isAdmin && root.profileType !== Constants.profileType.self && root.chatType === Constants.chatType.privateGroupChat
|
|
|
|
onTriggered: root.removeFromGroup()
|
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Mark as Untrusted
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
|
|
|
id: markUntrustworthyMenuItem
|
2023-11-28 09:29:18 +00:00
|
|
|
objectName: "markUntrustworthy_StatusItem"
|
2024-02-07 14:56:45 +00:00
|
|
|
text: qsTr("Mark as untrusted")
|
2023-05-19 16:07:50 +00:00
|
|
|
icon.name: "warning"
|
|
|
|
type: StatusAction.Type.Danger
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.regular && root.trustStatus !== Constants.trustStatus.untrustworthy
|
|
|
|
onTriggered: root.markAsUntrusted()
|
2024-02-26 18:54:05 +00:00
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Remove Untrustworthy Mark
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
|
|
|
id: removeUntrustworthyMarkMenuItem
|
2023-11-28 09:29:18 +00:00
|
|
|
objectName: "removeUntrustworthy_StatusItem"
|
2024-02-07 14:56:45 +00:00
|
|
|
text: qsTr("Remove untrusted mark")
|
2023-05-19 16:07:50 +00:00
|
|
|
icon.name: "warning"
|
2024-02-07 14:56:45 +00:00
|
|
|
type: StatusAction.Type.Danger
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.regular && root.trustStatus === Constants.trustStatus.untrustworthy
|
|
|
|
onTriggered: root.removeTrustStatus()
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Remove Contact
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
2024-09-06 15:55:44 +00:00
|
|
|
id: removeContactAction
|
2024-02-07 14:56:45 +00:00
|
|
|
text: qsTr("Remove contact")
|
2023-11-28 09:29:18 +00:00
|
|
|
objectName: "removeContact_StatusItem"
|
2023-05-19 16:07:50 +00:00
|
|
|
icon.name: "remove-contact"
|
|
|
|
type: StatusAction.Type.Danger
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.regular && root.contactType === Constants.contactType.contact
|
|
|
|
onTriggered: root.removeContact()
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
|
2024-09-06 15:55:44 +00:00
|
|
|
// Block User
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusAction {
|
|
|
|
id: blockMenuItem
|
2023-12-18 10:12:57 +00:00
|
|
|
objectName: "blockUser_StatusItem"
|
2024-02-07 14:56:45 +00:00
|
|
|
text: qsTr("Block user")
|
2023-05-19 16:07:50 +00:00
|
|
|
icon.name: "cancel"
|
|
|
|
type: StatusAction.Type.Danger
|
2024-09-06 15:55:44 +00:00
|
|
|
enabled: root.profileType === Constants.profileType.regular
|
|
|
|
onTriggered: root.blockContact()
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
}
|