2020-08-03 13:17:03 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQml.Models 2.3
|
2021-08-06 17:44:57 +02:00
|
|
|
|
|
|
|
import StatusQ.Popups 0.1
|
2021-10-21 00:47:23 +02:00
|
|
|
import StatusQ.Components 0.1
|
2021-09-28 18:04:06 +03:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
2021-10-28 23:23:30 +03:00
|
|
|
import shared.controls.chat 1.0
|
2022-06-10 13:12:03 +02:00
|
|
|
import shared.controls.chat.menuItems 1.0
|
2020-08-03 13:17:03 -04:00
|
|
|
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusMenu {
|
2021-10-21 03:41:54 +03:00
|
|
|
id: root
|
2021-07-16 18:02:47 +03:00
|
|
|
|
2022-01-19 10:59:08 -05:00
|
|
|
property var store
|
2021-12-14 15:19:55 +01:00
|
|
|
property var reactionModel
|
|
|
|
|
|
|
|
property string myPublicKey: ""
|
2022-01-05 16:50:03 +01:00
|
|
|
property bool amIChatAdmin: false
|
2023-03-20 16:59:53 +07:00
|
|
|
property bool disabledForChat: false
|
2022-07-06 15:27:04 -04:00
|
|
|
|
2023-01-20 14:01:32 -05:00
|
|
|
property int chatType: Constants.chatType.unknown
|
2021-12-14 15:19:55 +01:00
|
|
|
property string messageId: ""
|
2023-01-06 15:19:27 -05:00
|
|
|
property string unparsedText: ""
|
2021-12-14 15:19:55 +01:00
|
|
|
property string messageSenderId: ""
|
|
|
|
property int messageContentType: Constants.messageContentType.unknownContentType
|
|
|
|
|
2022-07-06 15:27:04 -04:00
|
|
|
property bool pinMessageAllowedForMembers: false
|
2023-05-09 14:31:50 +04:00
|
|
|
property bool isDebugEnabled: store && store.isDebugEnabled
|
2023-05-19 19:07:50 +03:00
|
|
|
property bool editRestricted: false
|
2021-05-25 15:34:46 -04:00
|
|
|
property bool pinnedMessage: false
|
2021-12-14 15:19:55 +01:00
|
|
|
property bool canPin: false
|
|
|
|
|
2022-06-20 17:48:38 +03:00
|
|
|
readonly property bool isMyMessage: {
|
2022-07-06 15:27:04 -04:00
|
|
|
return root.messageSenderId !== "" && root.messageSenderId === root.myPublicKey;
|
2022-06-20 17:48:38 +03:00
|
|
|
}
|
|
|
|
|
2021-12-14 15:19:55 +01:00
|
|
|
signal pinMessage(string messageId)
|
|
|
|
signal unpinMessage(string messageId)
|
|
|
|
signal pinnedMessagesLimitReached(string messageId)
|
2023-05-19 19:07:50 +03:00
|
|
|
signal showReplyArea(string messageId, string messageSenderId)
|
2021-12-20 15:21:35 +01:00
|
|
|
signal toggleReaction(string messageId, int emojiId)
|
2022-01-13 16:14:34 +01:00
|
|
|
signal deleteMessage(string messageId)
|
2022-01-17 19:46:46 +01:00
|
|
|
signal editClicked(string messageId)
|
2021-06-29 10:49:32 -04:00
|
|
|
|
2023-05-19 19:07:50 +03:00
|
|
|
width: Math.max(emojiContainer.visible ? emojiContainer.width : 0, 230)
|
2022-07-21 13:02:31 +02:00
|
|
|
|
2020-08-03 13:17:03 -04:00
|
|
|
Item {
|
|
|
|
id: emojiContainer
|
|
|
|
width: emojiRow.width
|
|
|
|
height: visible ? emojiRow.height : 0
|
2023-05-19 19:07:50 +03:00
|
|
|
visible: !root.disabledForChat
|
2023-03-20 16:59:53 +07:00
|
|
|
|
2023-05-19 19:07:50 +03:00
|
|
|
MessageReactionsRow {
|
2020-08-03 13:17:03 -04:00
|
|
|
id: emojiRow
|
2023-05-19 19:07:50 +03:00
|
|
|
reactionsModel: root.reactionModel
|
|
|
|
bottomPadding: Style.current.padding
|
|
|
|
onToggleReaction: {
|
|
|
|
root.toggleReaction(root.messageId, emojiId)
|
|
|
|
close()
|
2022-07-07 15:44:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 13:02:31 +02:00
|
|
|
StatusMenuSeparator {
|
2023-05-19 19:07:50 +03:00
|
|
|
visible: emojiContainer.visible
|
2022-06-20 17:48:38 +03:00
|
|
|
}
|
|
|
|
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusAction {
|
2022-06-10 13:12:03 +02:00
|
|
|
id: replyToMenuItem
|
|
|
|
text: qsTr("Reply to")
|
2021-08-06 17:44:57 +02:00
|
|
|
icon.name: "chat"
|
2022-06-10 13:12:03 +02:00
|
|
|
onTriggered: {
|
2023-05-19 19:07:50 +03:00
|
|
|
root.showReplyArea(root.messageId, root.messageSenderId)
|
2022-06-10 13:12:03 +02:00
|
|
|
root.close()
|
|
|
|
}
|
2023-05-19 19:07:50 +03:00
|
|
|
enabled: !root.disabledForChat
|
2020-08-03 13:17:03 -04:00
|
|
|
}
|
2021-07-22 10:47:15 +03:00
|
|
|
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusAction {
|
2021-08-06 17:44:57 +02:00
|
|
|
id: editMessageAction
|
2022-04-04 13:26:30 +02:00
|
|
|
text: qsTr("Edit message")
|
2021-08-06 17:44:57 +02:00
|
|
|
onTriggered: {
|
2022-01-17 19:46:46 +01:00
|
|
|
editClicked(messageId)
|
2021-08-06 17:44:57 +02:00
|
|
|
}
|
|
|
|
icon.name: "edit"
|
2021-12-14 15:19:55 +01:00
|
|
|
enabled: root.isMyMessage &&
|
2023-05-19 19:07:50 +03:00
|
|
|
!root.editRestricted &&
|
2023-03-20 16:59:53 +07:00
|
|
|
!root.disabledForChat
|
2021-07-16 11:06:52 -04:00
|
|
|
}
|
|
|
|
|
2023-01-06 15:19:27 -05:00
|
|
|
StatusAction {
|
|
|
|
id: copyMessageMenuItem
|
|
|
|
text: qsTr("Copy message")
|
|
|
|
icon.name: "copy"
|
|
|
|
onTriggered: {
|
|
|
|
root.store.copyToClipboard(root.unparsedText)
|
|
|
|
close()
|
|
|
|
}
|
2023-02-07 15:21:32 +01:00
|
|
|
enabled: root.messageContentType === Constants.messageContentType.messageType && replyToMenuItem.enabled
|
2023-01-06 15:19:27 -05:00
|
|
|
}
|
|
|
|
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusAction {
|
2021-11-11 12:22:03 -04:00
|
|
|
id: copyMessageIdAction
|
|
|
|
text: qsTr("Copy Message Id")
|
2023-01-06 15:19:27 -05:00
|
|
|
icon.name: "copy"
|
2023-02-07 15:21:32 +01:00
|
|
|
enabled: root.isDebugEnabled && replyToMenuItem.enabled
|
2021-11-11 12:22:03 -04:00
|
|
|
onTriggered: {
|
2023-01-06 15:19:27 -05:00
|
|
|
root.store.copyToClipboard(root.messageId)
|
2021-11-11 12:22:03 -04:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusAction {
|
2021-08-06 17:44:57 +02:00
|
|
|
id: pinAction
|
2023-05-19 19:07:50 +03:00
|
|
|
text: root.pinnedMessage ? qsTr("Unpin") : qsTr("Pin")
|
|
|
|
icon.name: root.pinnedMessage ? "unpin" : "pin"
|
2021-07-22 10:47:15 +03:00
|
|
|
onTriggered: {
|
2021-12-14 15:19:55 +01:00
|
|
|
if (root.pinnedMessage) {
|
|
|
|
root.unpinMessage(root.messageId)
|
2021-08-06 17:44:57 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-14 15:19:55 +01:00
|
|
|
if (!root.canPin) {
|
|
|
|
root.pinnedMessagesLimitReached(root.messageId)
|
2021-08-06 17:44:57 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-14 15:19:55 +01:00
|
|
|
root.pinMessage(root.messageId)
|
2021-10-21 03:41:54 +03:00
|
|
|
root.close()
|
2021-07-22 10:47:15 +03:00
|
|
|
}
|
2021-08-06 17:44:57 +02:00
|
|
|
enabled: {
|
2023-05-19 19:07:50 +03:00
|
|
|
if (root.disabledForChat)
|
2021-08-06 17:44:57 +02:00
|
|
|
return false
|
|
|
|
|
2021-12-14 15:19:55 +01:00
|
|
|
switch (root.chatType) {
|
|
|
|
case Constants.chatType.profile:
|
|
|
|
return false
|
|
|
|
case Constants.chatType.oneToOne:
|
|
|
|
return true
|
|
|
|
case Constants.chatType.privateGroupChat:
|
2022-01-05 16:50:03 +01:00
|
|
|
return root.amIChatAdmin
|
2021-12-14 15:19:55 +01:00
|
|
|
case Constants.chatType.communityChat:
|
2022-05-10 18:13:36 +02:00
|
|
|
return root.amIChatAdmin || root.pinMessageAllowedForMembers
|
2021-12-14 15:19:55 +01:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
2021-08-06 17:44:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {
|
2021-12-14 15:19:55 +01:00
|
|
|
visible: deleteMessageAction.enabled &&
|
2023-05-19 19:07:50 +03:00
|
|
|
(replyToMenuItem.enabled ||
|
2023-01-06 15:19:27 -05:00
|
|
|
copyMessageMenuItem.enabled ||
|
2023-05-19 19:07:50 +03:00
|
|
|
copyMessageIdAction ||
|
2022-01-05 16:50:03 +01:00
|
|
|
editMessageAction.enabled ||
|
|
|
|
pinAction.enabled)
|
2021-07-22 10:47:15 +03:00
|
|
|
}
|
2021-08-06 17:44:57 +02:00
|
|
|
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusAction {
|
2021-07-26 14:44:25 -04:00
|
|
|
id: deleteMessageAction
|
2022-12-26 11:25:16 -05:00
|
|
|
enabled: (root.isMyMessage || root.amIChatAdmin) &&
|
2023-03-20 16:59:53 +07:00
|
|
|
!root.disabledForChat &&
|
2021-12-14 15:19:55 +01: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 13:26:30 +02:00
|
|
|
text: qsTr("Delete message")
|
2021-08-06 17:44:57 +02:00
|
|
|
icon.name: "delete"
|
2022-12-01 19:58:37 +03:00
|
|
|
type: StatusAction.Type.Danger
|
2021-08-16 15:35:24 +03:00
|
|
|
onTriggered: {
|
2023-05-19 19:07:50 +03:00
|
|
|
root.deleteMessage(messageId)
|
2022-01-13 16:14:34 +01:00
|
|
|
}
|
|
|
|
}
|
2020-08-03 13:17:03 -04:00
|
|
|
}
|