2020-12-10 11:47:30 +00:00
|
|
|
import QtQuick 2.3
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
import "../../../../../shared"
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-12-10 11:47:30 +00:00
|
|
|
import "../../../../../shared/status"
|
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
MouseArea {
|
2020-12-10 11:47:30 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property var clickMessage: function () {}
|
2021-07-07 15:08:05 +00:00
|
|
|
property bool hovered: containsMouse
|
|
|
|
property var container
|
2021-07-15 14:59:30 +00:00
|
|
|
property int statusAgeEpoch: 0
|
2021-08-20 09:42:15 +00:00
|
|
|
property var messageContextMenu
|
2021-07-07 15:08:05 +00:00
|
|
|
|
2020-12-10 11:47:30 +00:00
|
|
|
anchors.top: parent.top
|
2020-12-10 13:33:03 +00:00
|
|
|
anchors.topMargin: 0
|
2021-08-20 09:42:15 +00:00
|
|
|
height: (isImage ? chatImageContent.height : chatText.height) + chatName.height + 2* Style.current.padding + (emojiReactionsModel.length ? 20 : 0)
|
2020-12-10 11:47:30 +00:00
|
|
|
width: parent.width
|
2021-07-07 15:08:05 +00:00
|
|
|
hoverEnabled: true
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
propagateComposedEvents: true
|
2021-08-20 09:42:15 +00:00
|
|
|
|
|
|
|
signal addEmoji(bool isProfileClick, bool isSticker, bool isImage , var image, bool emojiOnly, bool hideEmojiPicker)
|
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
onClicked: {
|
|
|
|
mouse.accepted = false
|
2020-12-10 11:47:30 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
Rectangle {
|
|
|
|
id: rootRect
|
|
|
|
anchors.fill: parent
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: root.hovered ? Style.current.border : Style.current.background
|
2020-12-10 11:47:30 +00:00
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
UserImage {
|
|
|
|
id: chatImage
|
|
|
|
active: isMessage || isImage
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
}
|
2020-12-10 11:47:30 +00:00
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
UsernameLabel {
|
|
|
|
id: chatName
|
|
|
|
visible: chatImage.visible
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
anchors.top: chatImage.top
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
label.font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
z: 51
|
2020-12-17 10:03:53 +00:00
|
|
|
}
|
2020-12-10 11:47:30 +00:00
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
ChatTime {
|
|
|
|
id: chatTime
|
2021-07-15 14:59:30 +00:00
|
|
|
// statusAgeEpoch is used to trigger Qt property update
|
|
|
|
// since the returned string will be the same in 99% cases, this should not trigger ChatTime re-rendering
|
|
|
|
text: Utils.formatAgeFromTime(timestamp, statusAgeEpoch)
|
2021-07-07 15:08:05 +00:00
|
|
|
visible: chatName.visible
|
|
|
|
anchors.verticalCenter: chatName.verticalCenter
|
|
|
|
anchors.left: chatName.right
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
}
|
2020-12-10 11:47:30 +00:00
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
ChatText {
|
|
|
|
id: chatText
|
|
|
|
anchors.top: chatName.visible ? chatName.bottom : chatImage.top
|
|
|
|
anchors.topMargin: chatName.visible ? 6 : 0
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-12-10 11:47:30 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
Loader {
|
|
|
|
id: chatImageContent
|
|
|
|
active: isImage
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
anchors.top: chatText.bottom
|
|
|
|
z: 51
|
|
|
|
|
|
|
|
sourceComponent: Component {
|
2021-08-30 12:42:11 +00:00
|
|
|
StatusChatImage {
|
2021-07-07 15:08:05 +00:00
|
|
|
imageSource: image
|
|
|
|
imageWidth: 200
|
2021-08-25 20:31:00 +00:00
|
|
|
onClicked: imageClick(image)
|
2021-07-07 15:08:05 +00:00
|
|
|
container: root.container
|
|
|
|
}
|
2020-12-17 10:03:53 +00:00
|
|
|
}
|
2020-12-10 11:47:30 +00:00
|
|
|
}
|
2021-07-07 15:08:05 +00:00
|
|
|
|
|
|
|
StatusIconButton {
|
|
|
|
id: emojiBtn
|
|
|
|
visible: root.hovered
|
|
|
|
highlighted: visible
|
|
|
|
anchors.top: rootRect.top
|
|
|
|
anchors.topMargin: -height / 4
|
|
|
|
anchors.right: rootRect.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
|
|
|
highlightedIconColor: Style.current.secondaryText
|
|
|
|
highlightedBackgroundColor: Style.current.background
|
|
|
|
icon.name: "emoji"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 20
|
|
|
|
onClicked: {
|
2021-08-25 20:31:00 +00:00
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
messageContextMenu.parent = emojiBtn
|
|
|
|
messageContextMenu.setXPosition = function() { return -messageContextMenu.width + emojiBtn.width}
|
|
|
|
messageContextMenu.setYPosition = function() { return -messageContextMenu.height - 4}
|
2021-07-07 15:08:05 +00:00
|
|
|
root.clickMessage(false, false, false, null, true)
|
2020-12-17 10:03:53 +00:00
|
|
|
}
|
2020-12-10 11:47:30 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
DropShadow {
|
|
|
|
anchors.fill: emojiBtn
|
|
|
|
horizontalOffset: 0
|
|
|
|
verticalOffset: 2
|
|
|
|
radius: 10
|
|
|
|
samples: 12
|
|
|
|
color: "#22000000"
|
|
|
|
source: emojiBtn
|
2020-12-10 11:47:30 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
Loader {
|
|
|
|
id: emojiReactionLoader
|
2021-08-20 09:42:15 +00:00
|
|
|
active: emojiReactionsModel.length
|
2021-07-07 15:08:05 +00:00
|
|
|
sourceComponent: emojiReactionsComponent
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
anchors.top: isImage ? chatImageContent.bottom : chatText.bottom
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
}
|
2020-12-10 11:47:30 +00:00
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
Component {
|
|
|
|
id: emojiReactionsComponent
|
2021-08-20 09:42:15 +00:00
|
|
|
EmojiReactions {
|
|
|
|
onAddEmojiClicked: {
|
|
|
|
root.addEmoji(false, false, false, null, true, false);
|
2021-08-25 20:31:00 +00:00
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
messageContextMenu.parent = emojiReactionLoader
|
|
|
|
messageContextMenu.setXPosition = function() { return (messageContextMenu.parent.x + 4)}
|
|
|
|
messageContextMenu.setYPosition = function() { return (-messageContextMenu.height - 4)}
|
2021-08-20 09:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-07 15:08:05 +00:00
|
|
|
}
|
2020-12-10 13:33:03 +00:00
|
|
|
|
2021-07-07 15:08:05 +00:00
|
|
|
Separator {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
visible: !root.hovered
|
|
|
|
}
|
2020-12-10 13:33:03 +00:00
|
|
|
}
|
2020-12-10 11:47:30 +00:00
|
|
|
}
|