2020-08-03 17:17:03 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQml.Models 2.3
|
2021-08-16 09:11:43 +00:00
|
|
|
import QtQuick.Dialogs 1.0
|
2021-08-06 15:44:57 +00:00
|
|
|
|
|
|
|
import StatusQ.Popups 0.1
|
2021-10-20 22:47:23 +00:00
|
|
|
import StatusQ.Components 0.1
|
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.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.controls.chat 1.0
|
2022-06-10 11:12:03 +00:00
|
|
|
import shared.controls.chat.menuItems 1.0
|
2020-08-03 17:17:03 +00:00
|
|
|
|
2021-08-06 15:44:57 +00:00
|
|
|
StatusPopupMenu {
|
2021-10-21 00:41:54 +00:00
|
|
|
id: root
|
2021-08-06 15:44:57 +00:00
|
|
|
width: emojiContainer.visible ? emojiContainer.width : 176
|
2021-07-16 15:02:47 +00:00
|
|
|
|
2022-01-19 15:59:08 +00:00
|
|
|
property var store
|
2021-12-14 14:19:55 +00:00
|
|
|
property var reactionModel
|
|
|
|
property alias emojiContainer: emojiContainer
|
|
|
|
|
|
|
|
property string myPublicKey: ""
|
2022-01-05 15:50:03 +00:00
|
|
|
property bool amIChatAdmin: false
|
2022-05-10 16:13:36 +00:00
|
|
|
property bool pinMessageAllowedForMembers: false
|
2021-12-14 14:19:55 +00:00
|
|
|
property bool isMyMessage: {
|
|
|
|
return root.messageSenderId !== "" && root.messageSenderId == root.myPublicKey
|
|
|
|
}
|
|
|
|
|
|
|
|
property int chatType: Constants.chatType.publicChat
|
|
|
|
property string messageId: ""
|
|
|
|
property string messageSenderId: ""
|
|
|
|
property int messageContentType: Constants.messageContentType.unknownContentType
|
|
|
|
property string selectedUserPublicKey: ""
|
|
|
|
property string selectedUserDisplayName: ""
|
|
|
|
property string selectedUserIcon: ""
|
|
|
|
property string imageSource: ""
|
|
|
|
|
2020-08-03 17:17:03 +00:00
|
|
|
property bool isProfile: false
|
2021-12-14 14:19:55 +00:00
|
|
|
property bool isRightClickOnImage: false
|
|
|
|
property bool pinnedPopup: false
|
|
|
|
property bool isDebugEnabled: false
|
2022-05-17 10:40:27 +00:00
|
|
|
property bool isEmoji: false
|
2022-05-17 13:09:00 +00:00
|
|
|
property bool isSticker: false
|
2021-12-14 14:19:55 +00:00
|
|
|
property bool hideEmojiPicker: true
|
2021-05-25 19:34:46 +00:00
|
|
|
property bool pinnedMessage: false
|
2021-12-14 14:19:55 +00:00
|
|
|
property bool canPin: false
|
|
|
|
|
2021-08-25 20:31:00 +00:00
|
|
|
property var setXPosition: function() {return 0}
|
|
|
|
property var setYPosition: function() {return 0}
|
2021-12-14 14:19:55 +00:00
|
|
|
|
2022-01-05 15:50:03 +00:00
|
|
|
property var emojiReactionsReactedByUser: []
|
|
|
|
|
|
|
|
signal openProfileClicked(string publicKey)
|
2021-12-14 14:19:55 +00:00
|
|
|
signal pinMessage(string messageId)
|
|
|
|
signal unpinMessage(string messageId)
|
|
|
|
signal pinnedMessagesLimitReached(string messageId)
|
|
|
|
signal jumpToMessage(string messageId)
|
|
|
|
signal shouldCloseParentPopup()
|
2022-02-15 21:00:05 +00:00
|
|
|
signal createOneToOneChat(string communityId, string chatId, string ensName)
|
2021-12-14 14:19:55 +00:00
|
|
|
signal showReplyArea()
|
2021-12-20 14:21:35 +00:00
|
|
|
signal toggleReaction(string messageId, int emojiId)
|
2022-01-13 15:14:34 +00:00
|
|
|
signal deleteMessage(string messageId)
|
2022-01-17 18:46:46 +00:00
|
|
|
signal editClicked(string messageId)
|
2021-06-29 14:49:32 +00:00
|
|
|
|
2021-08-25 20:31:00 +00:00
|
|
|
onHeightChanged: {
|
2021-10-21 00:41:54 +00:00
|
|
|
root.y = setYPosition()
|
2021-08-25 20:31:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onWidthChanged: {
|
2021-10-21 00:41:54 +00:00
|
|
|
root.x = setXPosition()
|
2021-08-25 20:31:00 +00:00
|
|
|
}
|
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
function show(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, emojiReactionsModel) {
|
|
|
|
let newEmojiReactions = []
|
|
|
|
if (!!emojiReactionsModel) {
|
|
|
|
emojiReactionsModel.forEach(function (emojiReaction) {
|
|
|
|
newEmojiReactions[emojiReaction.emojiId] = emojiReaction.currentUserReacted
|
|
|
|
})
|
|
|
|
}
|
2022-01-05 15:50:03 +00:00
|
|
|
root.emojiReactionsReactedByUser = newEmojiReactions;
|
2021-12-08 21:20:43 +00:00
|
|
|
|
|
|
|
/* // copy link feature not ready yet
|
|
|
|
const numLinkUrls = root.linkUrls.split(" ").length
|
|
|
|
copyLinkMenu.enabled = numLinkUrls > 1
|
2022-05-17 10:40:27 +00:00
|
|
|
copyLinkAction.enabled = !!root.linkUrls && numLinkUrls === 1 && !isEmoji && !root.isProfile
|
2021-12-08 21:20:43 +00:00
|
|
|
*/
|
|
|
|
popup()
|
|
|
|
}
|
|
|
|
|
2020-08-03 17:17:03 +00:00
|
|
|
Item {
|
|
|
|
id: emojiContainer
|
|
|
|
width: emojiRow.width
|
|
|
|
height: visible ? emojiRow.height : 0
|
2022-05-17 10:40:27 +00:00
|
|
|
visible: !root.hideEmojiPicker && (root.isEmoji || !root.isProfile) && !root.pinnedPopup
|
2020-08-03 17:17:03 +00:00
|
|
|
Row {
|
|
|
|
id: emojiRow
|
2021-08-06 15:44:57 +00:00
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
leftPadding: Style.current.halfPadding
|
|
|
|
rightPadding: Style.current.halfPadding
|
2022-05-17 10:40:27 +00:00
|
|
|
bottomPadding: root.isEmoji ? 0 : Style.current.padding
|
2020-08-03 17:17:03 +00:00
|
|
|
|
|
|
|
Repeater {
|
2021-10-21 00:41:54 +00:00
|
|
|
model: root.reactionModel
|
2020-08-03 17:17:03 +00:00
|
|
|
delegate: EmojiReaction {
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg(filename)
|
2020-08-03 17:17:03 +00:00
|
|
|
emojiId: model.emojiId
|
2021-10-21 00:41:54 +00:00
|
|
|
reactedByUser: !!root.emojiReactionsReactedByUser[model.emojiId]
|
2021-10-01 15:58:36 +00:00
|
|
|
onCloseModal: {
|
2021-12-20 14:21:35 +00:00
|
|
|
root.toggleReaction(root.messageId, emojiId)
|
2021-10-21 00:41:54 +00:00
|
|
|
root.close()
|
2020-08-12 17:58:19 +00:00
|
|
|
}
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
ProfileHeader {
|
2021-08-06 15:44:57 +00:00
|
|
|
width: parent.width
|
2022-03-09 10:27:32 +00:00
|
|
|
visible: root.isProfile
|
2020-08-03 17:17:03 +00:00
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
displayName: root.selectedUserDisplayName
|
|
|
|
pubkey: root.selectedUserPublicKey
|
|
|
|
icon: root.selectedUserIcon
|
|
|
|
}
|
2020-08-03 17:17:03 +00:00
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
Item {
|
|
|
|
visible: root.isProfile
|
|
|
|
height: root.topPadding
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
anchors.bottom: viewProfileAction.top
|
2022-05-17 10:40:27 +00:00
|
|
|
visible: !root.isEmoji && !root.hideEmojiPicker && !pinnedPopup
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
|
2021-08-16 09:11:43 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
id: copyImageAction
|
|
|
|
text: qsTr("Copy image")
|
|
|
|
onTriggered: {
|
2022-01-19 15:59:08 +00:00
|
|
|
if (root.imageSource) {
|
2022-03-28 22:16:56 +00:00
|
|
|
root.store.copyImageToClipboardByUrl(root.imageSource)
|
2022-01-19 15:59:08 +00:00
|
|
|
}
|
2021-10-21 00:41:54 +00:00
|
|
|
root.close()
|
2021-08-16 09:11:43 +00:00
|
|
|
}
|
|
|
|
icon.name: "copy"
|
2022-02-01 18:45:28 +00:00
|
|
|
enabled: root.isRightClickOnImage && !root.pinnedPopup
|
2021-08-16 09:11:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
id: downloadImageAction
|
|
|
|
text: qsTr("Download image")
|
|
|
|
onTriggered: {
|
|
|
|
fileDialog.open()
|
2021-10-21 00:41:54 +00:00
|
|
|
root.close()
|
2021-08-16 09:11:43 +00:00
|
|
|
}
|
|
|
|
icon.name: "download"
|
2022-02-01 18:45:28 +00:00
|
|
|
enabled: root.isRightClickOnImage && !root.pinnedPopup
|
2021-08-16 09:11:43 +00:00
|
|
|
}
|
|
|
|
|
2022-06-10 11:12:03 +00:00
|
|
|
ViewProfileMenuItem {
|
2020-08-03 17:17:03 +00:00
|
|
|
id: viewProfileAction
|
2020-09-17 14:26:26 +00:00
|
|
|
onTriggered: {
|
2022-01-05 15:50:03 +00:00
|
|
|
root.openProfileClicked(root.selectedUserPublicKey)
|
2021-10-21 00:41:54 +00:00
|
|
|
root.close()
|
2020-09-17 14:26:26 +00:00
|
|
|
}
|
2022-02-01 18:45:28 +00:00
|
|
|
enabled: root.isProfile && !root.pinnedPopup
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
2021-06-29 14:49:32 +00:00
|
|
|
|
2022-06-10 11:12:03 +00:00
|
|
|
SendMessageMenuItem {
|
|
|
|
id: sendMessageMenuItem
|
|
|
|
enabled: root.isProfile && root.store.contactsStore.isMyMutualContact(root.selectedUserPublicKey)
|
2020-09-17 14:26:26 +00:00
|
|
|
onTriggered: {
|
2022-06-10 11:12:03 +00:00
|
|
|
root.createOneToOneChat("", root.selectedUserPublicKey, "")
|
2021-10-21 00:41:54 +00:00
|
|
|
root.close()
|
2020-09-17 14:26:26 +00:00
|
|
|
}
|
2022-06-10 11:12:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
id: replyToMenuItem
|
|
|
|
text: qsTr("Reply to")
|
2021-08-06 15:44:57 +00:00
|
|
|
icon.name: "chat"
|
2022-06-10 11:12:03 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.showReplyArea()
|
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
enabled: (!root.hideEmojiPicker &&
|
2022-05-17 10:40:27 +00:00
|
|
|
!root.isEmoji &&
|
2021-12-14 14:19:55 +00:00
|
|
|
!root.isProfile &&
|
2022-02-01 18:45:28 +00:00
|
|
|
!root.pinnedPopup &&
|
2021-12-14 14:19:55 +00:00
|
|
|
!root.isRightClickOnImage)
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
2021-07-22 07:47:15 +00:00
|
|
|
|
2021-08-06 15:44:57 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
id: editMessageAction
|
|
|
|
//% "Edit message"
|
|
|
|
text: qsTrId("edit-message")
|
|
|
|
onTriggered: {
|
2022-01-17 18:46:46 +00:00
|
|
|
editClicked(messageId)
|
2021-08-06 15:44:57 +00:00
|
|
|
}
|
|
|
|
icon.name: "edit"
|
2021-12-14 14:19:55 +00:00
|
|
|
enabled: root.isMyMessage &&
|
|
|
|
!root.hideEmojiPicker &&
|
2022-05-17 10:40:27 +00:00
|
|
|
!root.isEmoji &&
|
2022-05-17 13:09:00 +00:00
|
|
|
!root.isSticker &&
|
2021-12-14 14:19:55 +00:00
|
|
|
!root.isProfile &&
|
2022-02-01 18:45:28 +00:00
|
|
|
!root.pinnedPopup &&
|
2021-12-14 14:19:55 +00:00
|
|
|
!root.isRightClickOnImage
|
2021-07-16 15:06:52 +00:00
|
|
|
}
|
|
|
|
|
2021-11-11 16:22:03 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
id: copyMessageIdAction
|
|
|
|
text: qsTr("Copy Message Id")
|
|
|
|
icon.name: "chat"
|
2022-02-01 18:45:28 +00:00
|
|
|
enabled: root.isDebugEnabled && !pinnedPopup
|
2021-11-11 16:22:03 +00:00
|
|
|
onTriggered: {
|
2022-01-19 15:59:08 +00:00
|
|
|
root.store.copyToClipboard(SelectedMessage.messageId)
|
2021-11-11 16:22:03 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-06 15:44:57 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
id: pinAction
|
|
|
|
text: {
|
2021-12-14 14:19:55 +00:00
|
|
|
if (root.pinnedMessage) {
|
2021-08-06 15:44:57 +00:00
|
|
|
//% "Unpin"
|
|
|
|
return qsTrId("unpin")
|
|
|
|
}
|
|
|
|
//% "Pin"
|
|
|
|
return qsTrId("pin")
|
|
|
|
|
|
|
|
}
|
2021-07-22 07:47:15 +00:00
|
|
|
onTriggered: {
|
2021-12-14 14:19:55 +00:00
|
|
|
if (root.pinnedMessage) {
|
|
|
|
root.unpinMessage(root.messageId)
|
2021-08-06 15:44:57 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
if (!root.canPin) {
|
|
|
|
root.pinnedMessagesLimitReached(root.messageId)
|
2021-08-06 15:44:57 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
root.pinMessage(root.messageId)
|
2021-10-21 00:41:54 +00:00
|
|
|
root.close()
|
2021-07-22 07:47:15 +00:00
|
|
|
}
|
2021-08-06 15:44:57 +00:00
|
|
|
icon.name: "pin"
|
|
|
|
enabled: {
|
2022-05-17 10:40:27 +00:00
|
|
|
if(root.isProfile || root.isEmoji || root.isRightClickOnImage)
|
2021-08-06 15:44:57 +00:00
|
|
|
return false
|
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
switch (root.chatType) {
|
|
|
|
case Constants.chatType.publicChat:
|
|
|
|
return false
|
|
|
|
case Constants.chatType.profile:
|
|
|
|
return false
|
|
|
|
case Constants.chatType.oneToOne:
|
|
|
|
return true
|
|
|
|
case Constants.chatType.privateGroupChat:
|
2022-01-05 15:50:03 +00:00
|
|
|
return root.amIChatAdmin
|
2021-12-14 14:19:55 +00:00
|
|
|
case Constants.chatType.communityChat:
|
2022-05-10 16:13:36 +00:00
|
|
|
return root.amIChatAdmin || root.pinMessageAllowedForMembers
|
2021-12-14 14:19:55 +00:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
2021-08-06 15:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {
|
2021-12-14 14:19:55 +00:00
|
|
|
visible: deleteMessageAction.enabled &&
|
2022-01-05 15:50:03 +00:00
|
|
|
(viewProfileAction.enabled ||
|
2022-06-10 11:12:03 +00:00
|
|
|
sendMessageMenuItem.enabled ||
|
|
|
|
replyToMenuItem.enabled ||
|
2022-01-05 15:50:03 +00:00
|
|
|
editMessageAction.enabled ||
|
|
|
|
pinAction.enabled)
|
2021-07-22 07:47:15 +00:00
|
|
|
}
|
2021-08-06 15:44:57 +00:00
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-26 18:44:25 +00:00
|
|
|
id: deleteMessageAction
|
2021-12-14 14:19:55 +00:00
|
|
|
enabled: root.isMyMessage &&
|
|
|
|
!root.isProfile &&
|
2022-05-17 10:40:27 +00:00
|
|
|
!root.isEmoji &&
|
2021-12-14 14:19:55 +00:00
|
|
|
!root.pinnedPopup &&
|
|
|
|
!root.isRightClickOnImage &&
|
|
|
|
(root.messageContentType === Constants.messageContentType.messageType ||
|
|
|
|
root.messageContentType === Constants.messageContentType.stickerType ||
|
|
|
|
root.messageContentType === Constants.messageContentType.emojiType ||
|
|
|
|
root.messageContentType === Constants.messageContentType.imageType ||
|
|
|
|
root.messageContentType === Constants.messageContentType.audioType)
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Delete message"
|
|
|
|
text: qsTrId("delete-message")
|
2021-07-26 18:44:25 +00:00
|
|
|
onTriggered: {
|
2021-10-20 09:50:50 +00:00
|
|
|
if (!localAccountSensitiveSettings.showDeleteMessageWarning) {
|
2022-01-13 15:14:34 +00:00
|
|
|
deleteMessage(messageId)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Global.openPopup(deleteMessageConfirmationDialogComponent)
|
2021-07-26 18:44:25 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-06 15:44:57 +00:00
|
|
|
icon.name: "delete"
|
|
|
|
type: StatusMenuItem.Type.Danger
|
2021-07-26 18:44:25 +00:00
|
|
|
}
|
2021-08-16 12:35:24 +00:00
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-12-14 14:19:55 +00:00
|
|
|
id: jumpToAction
|
2021-10-21 00:41:54 +00:00
|
|
|
enabled: root.pinnedPopup
|
2021-08-16 12:35:24 +00:00
|
|
|
text: qsTr("Jump to")
|
|
|
|
onTriggered: {
|
2021-12-14 14:19:55 +00:00
|
|
|
root.jumpToMessage(root.messageId)
|
2021-10-21 00:41:54 +00:00
|
|
|
root.close()
|
|
|
|
root.shouldCloseParentPopup()
|
2021-08-16 12:35:24 +00:00
|
|
|
}
|
|
|
|
icon.name: "up"
|
|
|
|
}
|
2021-08-16 09:11:43 +00:00
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
id: fileDialog
|
|
|
|
title: qsTr("Please choose a directory")
|
|
|
|
selectFolder: true
|
|
|
|
modality: Qt.NonModal
|
|
|
|
onAccepted: {
|
2022-01-19 15:59:08 +00:00
|
|
|
if (root.imageSource) {
|
2022-03-28 22:16:56 +00:00
|
|
|
root.store.downloadImageByUrl(root.imageSource, fileDialog.fileUrls)
|
2022-01-19 15:59:08 +00:00
|
|
|
}
|
2021-08-16 09:11:43 +00:00
|
|
|
fileDialog.close()
|
|
|
|
}
|
|
|
|
onRejected: {
|
|
|
|
fileDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 15:14:34 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: deleteMessageConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
|
|
|
//% "Confirm deleting this message"
|
|
|
|
header.title: qsTrId("confirm-deleting-this-message")
|
|
|
|
//% "Are you sure you want to delete this message? Be aware that other clients are not guaranteed to delete the message as well."
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-delete-this-message--be-aware-that-other-clients-are-not-guaranteed-to-delete-the-message-as-well-")
|
|
|
|
height: 260
|
|
|
|
checkbox.visible: true
|
|
|
|
executeConfirm: function () {
|
|
|
|
if (checkbox.checked) {
|
|
|
|
localAccountSensitiveSettings.showDeleteMessageWarning = false
|
|
|
|
}
|
|
|
|
|
|
|
|
close()
|
|
|
|
root.deleteMessage(messageId)
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|