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-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
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusMenu {
|
2021-10-21 00:41:54 +00:00
|
|
|
id: root
|
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 string myPublicKey: ""
|
2022-01-05 15:50:03 +00:00
|
|
|
property bool amIChatAdmin: false
|
2023-03-20 09:59:53 +00:00
|
|
|
property bool disabledForChat: false
|
2022-07-06 19:27:04 +00:00
|
|
|
|
2023-01-20 19:01:32 +00:00
|
|
|
property int chatType: Constants.chatType.unknown
|
2021-12-14 14:19:55 +00:00
|
|
|
property string messageId: ""
|
2023-01-06 20:19:27 +00:00
|
|
|
property string unparsedText: ""
|
2021-12-14 14:19:55 +00:00
|
|
|
property string messageSenderId: ""
|
|
|
|
property int messageContentType: Constants.messageContentType.unknownContentType
|
|
|
|
|
2022-07-06 19:27:04 +00:00
|
|
|
property bool pinMessageAllowedForMembers: false
|
2023-05-09 10:31:50 +00:00
|
|
|
property bool isDebugEnabled: store && store.isDebugEnabled
|
2023-05-19 16:07:50 +00:00
|
|
|
property bool editRestricted: false
|
2021-05-25 19:34:46 +00:00
|
|
|
property bool pinnedMessage: false
|
2021-12-14 14:19:55 +00:00
|
|
|
property bool canPin: false
|
|
|
|
|
2022-06-20 14:48:38 +00:00
|
|
|
readonly property bool isMyMessage: {
|
2022-07-06 19:27:04 +00:00
|
|
|
return root.messageSenderId !== "" && root.messageSenderId === root.myPublicKey;
|
2022-06-20 14:48:38 +00:00
|
|
|
}
|
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
signal pinMessage(string messageId)
|
|
|
|
signal unpinMessage(string messageId)
|
|
|
|
signal pinnedMessagesLimitReached(string messageId)
|
2023-05-19 16:07:50 +00:00
|
|
|
signal showReplyArea(string messageId, string messageSenderId)
|
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)
|
2023-12-12 02:16:06 +00:00
|
|
|
signal markMessageAsUnread(string messageId)
|
2021-06-29 14:49:32 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
width: Math.max(emojiContainer.visible ? emojiContainer.width : 0, 230)
|
2022-07-21 11:02:31 +00:00
|
|
|
|
2020-08-03 17:17:03 +00:00
|
|
|
Item {
|
|
|
|
id: emojiContainer
|
|
|
|
width: emojiRow.width
|
|
|
|
height: visible ? emojiRow.height : 0
|
2023-05-19 16:07:50 +00:00
|
|
|
visible: !root.disabledForChat
|
2023-03-20 09:59:53 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
MessageReactionsRow {
|
2020-08-03 17:17:03 +00:00
|
|
|
id: emojiRow
|
2023-05-19 16:07:50 +00:00
|
|
|
reactionsModel: root.reactionModel
|
|
|
|
bottomPadding: Style.current.padding
|
|
|
|
onToggleReaction: {
|
|
|
|
root.toggleReaction(root.messageId, emojiId)
|
|
|
|
close()
|
2022-07-07 19:44:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 11:02:31 +00:00
|
|
|
StatusMenuSeparator {
|
2023-05-19 16:07:50 +00:00
|
|
|
visible: emojiContainer.visible
|
2022-06-20 14:48:38 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-06-10 11:12:03 +00:00
|
|
|
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: {
|
2023-05-19 16:07:50 +00:00
|
|
|
root.showReplyArea(root.messageId, root.messageSenderId)
|
2022-06-10 11:12:03 +00:00
|
|
|
root.close()
|
|
|
|
}
|
2023-05-19 16:07:50 +00:00
|
|
|
enabled: !root.disabledForChat
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
2021-07-22 07:47:15 +00:00
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2021-08-06 15:44:57 +00:00
|
|
|
id: editMessageAction
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Edit message")
|
2021-08-06 15:44:57 +00:00
|
|
|
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 &&
|
2023-05-19 16:07:50 +00:00
|
|
|
!root.editRestricted &&
|
2023-03-20 09:59:53 +00:00
|
|
|
!root.disabledForChat
|
2021-07-16 15:06:52 +00:00
|
|
|
}
|
|
|
|
|
2023-01-06 20:19:27 +00:00
|
|
|
StatusAction {
|
|
|
|
id: copyMessageMenuItem
|
|
|
|
text: qsTr("Copy message")
|
|
|
|
icon.name: "copy"
|
|
|
|
onTriggered: {
|
|
|
|
root.store.copyToClipboard(root.unparsedText)
|
|
|
|
close()
|
|
|
|
}
|
2023-02-07 14:21:32 +00:00
|
|
|
enabled: root.messageContentType === Constants.messageContentType.messageType && replyToMenuItem.enabled
|
2023-01-06 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2021-11-11 16:22:03 +00:00
|
|
|
id: copyMessageIdAction
|
|
|
|
text: qsTr("Copy Message Id")
|
2023-01-06 20:19:27 +00:00
|
|
|
icon.name: "copy"
|
2023-02-07 14:21:32 +00:00
|
|
|
enabled: root.isDebugEnabled && replyToMenuItem.enabled
|
2021-11-11 16:22:03 +00:00
|
|
|
onTriggered: {
|
2023-01-06 20:19:27 +00:00
|
|
|
root.store.copyToClipboard(root.messageId)
|
2021-11-11 16:22:03 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2021-08-06 15:44:57 +00:00
|
|
|
id: pinAction
|
2023-05-19 16:07:50 +00:00
|
|
|
text: root.pinnedMessage ? qsTr("Unpin") : qsTr("Pin")
|
|
|
|
icon.name: root.pinnedMessage ? "unpin" : "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
|
|
|
enabled: {
|
2023-05-19 16:07:50 +00:00
|
|
|
if (root.disabledForChat)
|
2021-08-06 15:44:57 +00:00
|
|
|
return false
|
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
switch (root.chatType) {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-12 02:16:06 +00:00
|
|
|
StatusAction {
|
|
|
|
id: markMessageAsUnreadAction
|
|
|
|
text: qsTr("Mark as unread")
|
|
|
|
icon.name: "hide"
|
|
|
|
enabled: !root.disabledForChat
|
|
|
|
onTriggered: {
|
|
|
|
root.markMessageAsUnread(root.messageId)
|
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-06 15:44:57 +00:00
|
|
|
StatusMenuSeparator {
|
2021-12-14 14:19:55 +00:00
|
|
|
visible: deleteMessageAction.enabled &&
|
2023-05-19 16:07:50 +00:00
|
|
|
(replyToMenuItem.enabled ||
|
2023-01-06 20:19:27 +00:00
|
|
|
copyMessageMenuItem.enabled ||
|
2023-05-19 16:07:50 +00:00
|
|
|
copyMessageIdAction ||
|
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
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2021-07-26 18:44:25 +00:00
|
|
|
id: deleteMessageAction
|
2022-12-26 16:25:16 +00:00
|
|
|
enabled: (root.isMyMessage || root.amIChatAdmin) &&
|
2023-03-20 09:59:53 +00:00
|
|
|
!root.disabledForChat &&
|
2021-12-14 14:19:55 +00:00
|
|
|
(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)
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Delete message")
|
2021-08-06 15:44:57 +00:00
|
|
|
icon.name: "delete"
|
2022-12-01 16:58:37 +00:00
|
|
|
type: StatusAction.Type.Danger
|
2021-08-16 12:35:24 +00:00
|
|
|
onTriggered: {
|
2023-05-19 16:07:50 +00:00
|
|
|
root.deleteMessage(messageId)
|
2022-01-13 15:14:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|