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
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
2020-09-22 14:45:09 +00:00
|
|
|
import "../../../../shared/status"
|
2020-08-03 17:17:03 +00:00
|
|
|
import "./"
|
|
|
|
|
|
|
|
PopupMenu {
|
|
|
|
property bool isProfile: false
|
2020-08-27 23:26:12 +00:00
|
|
|
property bool isSticker: false
|
2020-12-08 12:34:02 +00:00
|
|
|
property bool emojiOnly: false
|
2021-02-23 10:18:09 +00:00
|
|
|
property string linkUrls: ""
|
2021-02-01 21:29:35 +00:00
|
|
|
property alias emojiContainer: emojiContainer
|
2020-08-03 17:17:03 +00:00
|
|
|
|
|
|
|
id: messageContextMenu
|
|
|
|
width: messageContextMenu.isProfile ? profileHeader.width : emojiContainer.width
|
|
|
|
|
2020-10-02 13:02:56 +00:00
|
|
|
property var identicon: ""
|
|
|
|
property var userName: ""
|
|
|
|
property string nickname: ""
|
|
|
|
property var fromAuthor: ""
|
|
|
|
property var text: ""
|
2021-02-01 20:37:50 +00:00
|
|
|
property var emojiReactionsReactedByUser: []
|
2021-02-23 10:18:09 +00:00
|
|
|
subMenuIcons: [
|
|
|
|
{
|
|
|
|
source: Qt.resolvedUrl("../../../../shared/img/copy-to-clipboard-icon"),
|
|
|
|
width: 16,
|
|
|
|
height: 16
|
|
|
|
}
|
|
|
|
]
|
2020-10-02 13:02:56 +00:00
|
|
|
|
2021-02-01 20:37:50 +00:00
|
|
|
function show(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, emojiReactionsModel) {
|
2020-10-02 13:02:56 +00:00
|
|
|
userName = userNameParam || ""
|
|
|
|
nickname = nicknameParam || ""
|
|
|
|
fromAuthor = fromAuthorParam || ""
|
|
|
|
identicon = identiconParam || ""
|
|
|
|
text = textParam || ""
|
2021-02-01 20:37:50 +00:00
|
|
|
let newEmojiReactions = []
|
|
|
|
if (!!emojiReactionsModel) {
|
|
|
|
emojiReactionsModel.forEach(function (emojiReaction) {
|
|
|
|
newEmojiReactions[emojiReaction.emojiId] = emojiReaction.currentUserReacted
|
|
|
|
})
|
|
|
|
}
|
|
|
|
emojiReactionsReactedByUser = newEmojiReactions
|
|
|
|
|
2021-02-23 10:18:09 +00:00
|
|
|
const numLinkUrls = messageContextMenu.linkUrls.split(" ").length
|
|
|
|
copyLinkMenu.enabled = numLinkUrls > 1
|
2021-03-17 12:41:24 +00:00
|
|
|
copyLinkAction.enabled = !!messageContextMenu.linkUrls && numLinkUrls === 1 && !emojiOnly && !messageContextMenu.isProfile
|
2020-10-02 13:02:56 +00:00
|
|
|
popup();
|
|
|
|
}
|
|
|
|
|
2020-08-03 17:17:03 +00:00
|
|
|
Item {
|
|
|
|
id: emojiContainer
|
2020-12-08 12:34:02 +00:00
|
|
|
visible: messageContextMenu.emojiOnly || !messageContextMenu.isProfile
|
2020-08-03 17:17:03 +00:00
|
|
|
width: emojiRow.width
|
|
|
|
height: visible ? emojiRow.height : 0
|
|
|
|
|
|
|
|
Row {
|
|
|
|
id: emojiRow
|
|
|
|
spacing: Style.current.smallPadding
|
|
|
|
leftPadding: Style.current.smallPadding
|
|
|
|
rightPadding: Style.current.smallPadding
|
2020-12-08 12:34:02 +00:00
|
|
|
bottomPadding: messageContextMenu.emojiOnly ? 0 : Style.current.padding
|
2020-08-03 17:17:03 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: reactionModel
|
|
|
|
delegate: EmojiReaction {
|
|
|
|
source: "../../../img/" + filename
|
|
|
|
emojiId: model.emojiId
|
2021-02-01 20:37:50 +00:00
|
|
|
reactedByUser: !!messageContextMenu.emojiReactionsReactedByUser[model.emojiId]
|
2020-08-12 17:58:19 +00:00
|
|
|
closeModal: function () {
|
|
|
|
messageContextMenu.close()
|
|
|
|
}
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property bool hovered: false
|
|
|
|
|
|
|
|
id: profileHeader
|
|
|
|
visible: messageContextMenu.isProfile
|
|
|
|
width: 200
|
|
|
|
height: visible ? profileImage.height + username.height + Style.current.padding : 0
|
2021-04-13 10:21:15 +00:00
|
|
|
color: hovered ? Style.current.backgroundHover : Style.current.transparent
|
2020-08-03 17:17:03 +00:00
|
|
|
|
2020-09-22 14:45:09 +00:00
|
|
|
StatusImageIdenticon {
|
2020-08-03 17:17:03 +00:00
|
|
|
id: profileImage
|
2020-10-02 13:02:56 +00:00
|
|
|
source: identicon
|
2020-08-03 17:17:03 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: username
|
2021-02-15 16:25:07 +00:00
|
|
|
text: Utils.removeStatusEns(userName)
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 3
|
2020-08-03 17:17:03 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2021-02-15 16:25:07 +00:00
|
|
|
wrapMode: Text.Wrap
|
2020-08-03 17:17:03 +00:00
|
|
|
anchors.top: profileImage.bottom
|
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: {
|
|
|
|
profileHeader.hovered = true
|
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
profileHeader.hovered = false
|
|
|
|
}
|
|
|
|
onClicked: {
|
2020-10-02 13:02:56 +00:00
|
|
|
openProfilePopup(userName, fromAuthor, identicon);
|
2020-09-17 14:26:26 +00:00
|
|
|
messageContextMenu.close()
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
anchors.bottom: viewProfileAction.top
|
2020-12-08 12:34:02 +00:00
|
|
|
visible: !messageContextMenu.emojiOnly
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
|
2021-02-23 10:18:09 +00:00
|
|
|
Action {
|
|
|
|
id: copyLinkAction
|
|
|
|
text: qsTr("Copy link")
|
|
|
|
onTriggered: {
|
|
|
|
chatsModel.copyToClipboard(linkUrls.split(" ")[0])
|
|
|
|
messageContextMenu.close()
|
|
|
|
}
|
|
|
|
icon.source: "../../../../shared/img/copy-to-clipboard-icon"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
|
|
|
|
PopupMenu {
|
|
|
|
id: copyLinkMenu
|
|
|
|
title: qsTr("Copy link")
|
2021-04-07 17:36:30 +00:00
|
|
|
|
2021-02-23 10:18:09 +00:00
|
|
|
Repeater {
|
|
|
|
id: linksRepeater
|
|
|
|
model: messageContextMenu.linkUrls.split(" ")
|
|
|
|
delegate: MenuItem {
|
2021-04-07 17:36:30 +00:00
|
|
|
id: popupMenuItem
|
2021-02-23 10:18:09 +00:00
|
|
|
text: modelData
|
|
|
|
onTriggered: {
|
|
|
|
chatsModel.copyToClipboard(modelData)
|
|
|
|
messageContextMenu.close()
|
|
|
|
}
|
2021-04-07 17:36:30 +00:00
|
|
|
contentItem: StyledText {
|
|
|
|
text: popupMenuItem.text
|
|
|
|
font: popupMenuItem.font
|
|
|
|
color: Style.current.textColor
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
|
|
|
implicitWidth: 220
|
|
|
|
implicitHeight: 34
|
2021-04-09 13:46:37 +00:00
|
|
|
color: popupMenuItem.highlighted ? Style.current.backgroundHover: Style.current.transparent
|
2021-04-07 17:36:30 +00:00
|
|
|
}
|
2021-02-23 10:18:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 17:17:03 +00:00
|
|
|
Action {
|
|
|
|
id: viewProfileAction
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "View Profile"
|
2020-08-03 17:17:03 +00:00
|
|
|
text: qsTrId("view-profile")
|
2020-09-17 14:26:26 +00:00
|
|
|
onTriggered: {
|
2021-01-13 07:42:32 +00:00
|
|
|
openProfilePopup(userName, fromAuthor, identicon, "", nickname);
|
2020-09-17 14:26:26 +00:00
|
|
|
messageContextMenu.close()
|
|
|
|
}
|
2020-08-03 17:17:03 +00:00
|
|
|
icon.source: "../../../img/profileActive.svg"
|
2020-08-14 12:08:09 +00:00
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
2021-03-17 12:41:24 +00:00
|
|
|
enabled: !emojiOnly && !copyLinkAction.enabled
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
Action {
|
|
|
|
text: messageContextMenu.isProfile ?
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Send message"
|
|
|
|
qsTrId("send-message") :
|
2020-08-03 17:17:03 +00:00
|
|
|
//% "Reply to"
|
|
|
|
qsTrId("reply-to")
|
2020-09-17 14:26:26 +00:00
|
|
|
onTriggered: {
|
2020-12-10 11:41:28 +00:00
|
|
|
if (messageContextMenu.isProfile) {
|
|
|
|
appMain.changeAppSection(Constants.chat)
|
2021-05-10 15:30:36 +00:00
|
|
|
chatsModel.joinPrivateChat(fromAuthor, "")
|
2020-12-10 11:41:28 +00:00
|
|
|
} else {
|
|
|
|
showReplyArea()
|
|
|
|
}
|
2020-09-17 14:26:26 +00:00
|
|
|
messageContextMenu.close()
|
|
|
|
}
|
2020-08-03 17:17:03 +00:00
|
|
|
icon.source: "../../../img/messageActive.svg"
|
2020-08-14 12:08:09 +00:00
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
2020-12-08 12:34:02 +00:00
|
|
|
enabled: !isSticker && !emojiOnly
|
2020-08-03 17:17:03 +00:00
|
|
|
}
|
|
|
|
}
|