2021-01-25 20:50:42 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
2021-10-14 20:30:51 +00:00
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-01-25 20:50:42 +00:00
|
|
|
|
|
|
|
Rectangle {
|
2021-07-16 15:02:47 +00:00
|
|
|
id: buttonsContainer
|
2021-01-25 20:50:42 +00:00
|
|
|
property bool parentIsHovered: false
|
2022-02-24 12:15:02 +00:00
|
|
|
property bool isChatBlocked: false
|
2021-01-25 20:50:42 +00:00
|
|
|
property int containerMargin: 2
|
2021-03-24 17:30:15 +00:00
|
|
|
property int contentType: 2
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool isCurrentUser: false
|
|
|
|
property bool isMessageActive: false
|
2021-07-16 15:02:47 +00:00
|
|
|
property var messageContextMenu
|
2021-08-06 15:44:57 +00:00
|
|
|
property bool showMoreButton: true
|
2022-02-01 18:45:28 +00:00
|
|
|
property bool isInPinnedPopup: false
|
2021-12-17 12:53:10 +00:00
|
|
|
property bool activityCenterMsg
|
|
|
|
property bool placeholderMsg
|
2021-10-01 15:58:36 +00:00
|
|
|
property string fromAuthor
|
2022-02-01 18:45:28 +00:00
|
|
|
property bool editBtnActive: false
|
2022-01-12 12:55:26 +00:00
|
|
|
signal replyClicked(string messageId, string author)
|
2021-10-01 15:58:36 +00:00
|
|
|
signal hoverChanged(bool hovered)
|
|
|
|
signal setMessageActive(string messageId, bool active)
|
2021-11-02 19:58:48 +00:00
|
|
|
signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker)
|
2021-01-25 20:50:42 +00:00
|
|
|
|
2022-02-24 12:15:02 +00:00
|
|
|
visible: !buttonsContainer.isChatBlocked &&
|
|
|
|
!buttonsContainer.placeholderMsg && !buttonsContainer.activityCenterMsg &&
|
2021-06-10 19:20:43 +00:00
|
|
|
(buttonsContainer.parentIsHovered || isMessageActive)
|
2021-12-09 12:53:40 +00:00
|
|
|
&& contentType !== Constants.messageContentType.transactionType
|
2021-01-25 20:50:42 +00:00
|
|
|
width: buttonRow.width + buttonsContainer.containerMargin * 2
|
|
|
|
height: 36
|
|
|
|
radius: Style.current.radius
|
2021-02-18 19:07:23 +00:00
|
|
|
color: Style.current.modalBackground
|
2021-01-25 20:50:42 +00:00
|
|
|
z: 52
|
|
|
|
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
width: buttonsContainer.width
|
|
|
|
height: buttonsContainer.height
|
|
|
|
x: buttonsContainer.x
|
|
|
|
y: buttonsContainer.y + 10
|
|
|
|
visible: buttonsContainer.visible
|
|
|
|
source: buttonsContainer
|
|
|
|
horizontalOffset: 0
|
|
|
|
verticalOffset: 2
|
|
|
|
radius: 10
|
|
|
|
samples: 15
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: buttonsContainer
|
|
|
|
acceptedButtons: Qt.NoButton
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: {
|
|
|
|
buttonsContainer.hoverChanged(true)
|
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
buttonsContainer.hoverChanged(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
id: buttonRow
|
|
|
|
spacing: buttonsContainer.containerMargin
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: buttonsContainer.containerMargin
|
|
|
|
anchors.verticalCenter: buttonsContainer.verticalCenter
|
|
|
|
height: parent.height - 2 * buttonsContainer.containerMargin
|
|
|
|
|
2022-02-01 18:45:28 +00:00
|
|
|
Loader {
|
|
|
|
active: !buttonsContainer.isInPinnedPopup
|
|
|
|
sourceComponent: StatusFlatRoundButton {
|
|
|
|
id: emojiBtn
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
icon.name: "reaction-b"
|
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
//% "Add reaction"
|
|
|
|
tooltip.text: qsTrId("add-reaction")
|
|
|
|
onClicked: {
|
|
|
|
setMessageActive(messageId, true)
|
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
buttonsContainer.messageContextMenu.parent = buttonsContainer
|
|
|
|
buttonsContainer.messageContextMenu.setXPosition = function() { return (-Math.abs(buttonsContainer.width - buttonsContainer.messageContextMenu.emojiContainer.width))}
|
|
|
|
buttonsContainer.messageContextMenu.setYPosition = function() { return (-buttonsContainer.messageContextMenu.height - 4)}
|
|
|
|
buttonsContainer.clickMessage(false, false, false, null, true, false)
|
|
|
|
}
|
|
|
|
onHoveredChanged: buttonsContainer.hoverChanged(this.hovered)
|
2021-01-25 20:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-01 18:45:28 +00:00
|
|
|
Loader {
|
|
|
|
active: !buttonsContainer.isInPinnedPopup
|
|
|
|
sourceComponent: StatusFlatRoundButton {
|
|
|
|
id: replyBtn
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
icon.name: "reply"
|
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
//% "Reply"
|
|
|
|
tooltip.text: qsTrId("message-reply")
|
|
|
|
onClicked: {
|
|
|
|
buttonsContainer.replyClicked(messageId, fromAuthor);
|
|
|
|
if (messageContextMenu.closeParentPopup) {
|
|
|
|
messageContextMenu.closeParentPopup()
|
|
|
|
}
|
2021-07-22 07:47:15 +00:00
|
|
|
}
|
2022-02-01 18:45:28 +00:00
|
|
|
onHoveredChanged: buttonsContainer.hoverChanged(this.hovered)
|
2021-01-25 20:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-09 09:43:23 +00:00
|
|
|
|
2021-05-25 19:34:46 +00:00
|
|
|
|
2021-06-29 14:49:32 +00:00
|
|
|
Loader {
|
|
|
|
id: editBtn
|
2022-02-01 18:45:28 +00:00
|
|
|
active: buttonsContainer.editBtnActive && !buttonsContainer.isInPinnedPopup
|
2021-10-18 10:34:16 +00:00
|
|
|
sourceComponent: StatusFlatRoundButton {
|
2021-06-29 14:49:32 +00:00
|
|
|
id: btn
|
|
|
|
width: 32
|
|
|
|
height: 32
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.source: Style.svg("edit-message")
|
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
//% "Edit"
|
|
|
|
tooltip.text: qsTrId("edit")
|
2022-01-17 18:46:46 +00:00
|
|
|
onClicked: messageStore.setEditModeOn(messageId)
|
2021-10-18 10:34:16 +00:00
|
|
|
onHoveredChanged: buttonsContainer.hoverChanged(btn.hovered)
|
2021-06-29 14:49:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusFlatRoundButton {
|
2021-05-25 19:34:46 +00:00
|
|
|
id: otherBtn
|
|
|
|
width: 32
|
|
|
|
height: 32
|
2021-12-14 14:19:55 +00:00
|
|
|
visible: buttonsContainer.showMoreButton
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "more"
|
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
//% "More"
|
|
|
|
tooltip.text: qsTrId("more")
|
2021-05-25 19:34:46 +00:00
|
|
|
onClicked: {
|
|
|
|
if (typeof isMessageActive !== "undefined") {
|
2021-05-25 19:38:18 +00:00
|
|
|
setMessageActive(messageId, true)
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
2021-08-25 20:31:00 +00:00
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
buttonsContainer.messageContextMenu.parent = buttonsContainer
|
|
|
|
buttonsContainer.messageContextMenu.setXPosition = function() { return (-Math.abs(buttonsContainer.width - 176))}
|
|
|
|
buttonsContainer.messageContextMenu.setYPosition = function() { return (-buttonsContainer.messageContextMenu.height - 4)}
|
2021-12-14 14:19:55 +00:00
|
|
|
buttonsContainer.clickMessage(false, isSticker, false, null, false, true);
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
2021-10-18 10:34:16 +00:00
|
|
|
onHoveredChanged: buttonsContainer.hoverChanged(this.hovered)
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
2021-01-25 20:50:42 +00:00
|
|
|
}
|
|
|
|
}
|