2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2021-03-07 07:57:56 +03:00
|
|
|
//
|
2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
import "./delegates"
|
|
|
|
import "./emoji"
|
2021-02-14 03:28:28 +03:00
|
|
|
import QtQuick 2.12
|
2019-10-17 10:36:16 +03:00
|
|
|
import QtQuick.Controls 2.3
|
2021-01-12 17:03:39 +03:00
|
|
|
import QtQuick.Layouts 1.2
|
2021-08-04 03:27:50 +03:00
|
|
|
import QtQuick.Window 2.13
|
2019-11-30 03:43:39 +03:00
|
|
|
import im.nheko 1.0
|
2019-10-08 21:55:09 +03:00
|
|
|
|
2020-07-26 03:06:38 +03:00
|
|
|
Item {
|
2021-07-12 01:24:33 +03:00
|
|
|
id: r
|
|
|
|
|
|
|
|
required property double proportionalHeight
|
|
|
|
required property int type
|
|
|
|
required property string typeString
|
|
|
|
required property int originalWidth
|
|
|
|
required property string blurhash
|
|
|
|
required property string body
|
|
|
|
required property string formattedBody
|
|
|
|
required property string eventId
|
|
|
|
required property string filename
|
|
|
|
required property string filesize
|
|
|
|
required property string url
|
|
|
|
required property string thumbnailUrl
|
|
|
|
required property bool isOnlyEmoji
|
|
|
|
required property bool isSender
|
|
|
|
required property bool isEncrypted
|
|
|
|
required property bool isEditable
|
|
|
|
required property bool isEdited
|
|
|
|
required property string replyTo
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
2021-07-12 02:28:09 +03:00
|
|
|
required property string roomTopic
|
|
|
|
required property string roomName
|
|
|
|
required property string callType
|
2021-07-12 01:24:33 +03:00
|
|
|
required property var reactions
|
|
|
|
required property int trustlevel
|
2021-08-07 23:51:09 +03:00
|
|
|
required property int encryptionError
|
2021-07-12 01:24:33 +03:00
|
|
|
required property var timestamp
|
|
|
|
required property int status
|
2021-07-20 15:09:19 +03:00
|
|
|
required property int relatedEventCacheBuster
|
2021-07-12 01:24:33 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: row.height
|
|
|
|
|
2021-01-18 22:49:40 +03:00
|
|
|
Rectangle {
|
2021-05-13 09:23:56 +03:00
|
|
|
color: (Settings.messageHoverHighlight && hoverHandler.hovered) ? Nheko.colors.alternateBase : "transparent"
|
2021-01-18 22:49:40 +03:00
|
|
|
anchors.fill: row
|
|
|
|
}
|
|
|
|
|
2021-02-14 03:28:28 +03:00
|
|
|
HoverHandler {
|
2021-01-18 22:49:40 +03:00
|
|
|
id: hoverHandler
|
2021-01-19 05:25:56 +03:00
|
|
|
|
2021-02-14 03:28:28 +03:00
|
|
|
acceptedDevices: PointerDevice.GenericPointer
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.RightButton
|
2021-07-12 01:24:33 +03:00
|
|
|
onSingleTapped: messageContextMenu.show(eventId, type, isSender, isEncrypted, isEditable, contentItem.child.hoveredLink, contentItem.child.copyText)
|
2021-04-11 23:24:39 +03:00
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
2021-02-14 03:28:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
2021-04-02 22:39:29 +03:00
|
|
|
enabled: !Settings.mobileMode
|
2021-03-31 06:04:42 +03:00
|
|
|
onLongPressed: {
|
|
|
|
if (Settings.mobileMode)
|
|
|
|
mobileContextPopup.show(r, model);
|
|
|
|
else
|
|
|
|
messageContextMenu.show(eventId, type, isSender, isEncrypted, isEditable, contentItem.child.hoveredLink, contentItem.child.copyText)
|
|
|
|
|
|
|
|
}
|
2021-07-12 01:24:33 +03:00
|
|
|
onDoubleTapped: chat.model.reply = eventId
|
2021-04-11 23:24:39 +03:00
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
2021-04-02 22:39:29 +03:00
|
|
|
TapHandler {
|
|
|
|
enabled: Settings.mobileMode
|
|
|
|
onLongPressed: mobileContextPopup.show(timelineRowRoot, model);
|
|
|
|
}
|
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
RowLayout {
|
|
|
|
id: row
|
|
|
|
|
2021-03-05 18:47:20 +03:00
|
|
|
anchors.rightMargin: 1
|
2021-05-13 12:32:20 +03:00
|
|
|
anchors.leftMargin: Nheko.avatarSize + 16
|
2020-10-08 22:11:21 +03:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
Column {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
spacing: 4
|
2021-03-05 18:47:20 +03:00
|
|
|
Layout.topMargin: 1
|
|
|
|
Layout.bottomMargin: 1
|
2020-10-08 22:11:21 +03:00
|
|
|
|
|
|
|
// fancy reply, if this is a reply
|
|
|
|
Reply {
|
2021-07-12 23:28:01 +03:00
|
|
|
function fromModel(role) {
|
2021-07-16 12:47:49 +03:00
|
|
|
return replyTo != "" ? room.dataById(replyTo, role, r.eventId) : null;
|
2021-07-12 23:28:01 +03:00
|
|
|
}
|
|
|
|
|
2021-07-12 01:24:33 +03:00
|
|
|
visible: replyTo
|
2021-07-20 15:09:19 +03:00
|
|
|
userColor: r.relatedEventCacheBuster, TimelineManager.userColor(userId, Nheko.colors.base)
|
|
|
|
blurhash: r.relatedEventCacheBuster, fromModel(Room.Blurhash) ?? ""
|
|
|
|
body: r.relatedEventCacheBuster, fromModel(Room.Body) ?? ""
|
|
|
|
formattedBody: r.relatedEventCacheBuster, fromModel(Room.FormattedBody) ?? ""
|
2021-07-12 23:28:01 +03:00
|
|
|
eventId: fromModel(Room.EventId) ?? ""
|
2021-07-20 15:09:19 +03:00
|
|
|
filename: r.relatedEventCacheBuster, fromModel(Room.Filename) ?? ""
|
|
|
|
filesize: r.relatedEventCacheBuster, fromModel(Room.Filesize) ?? ""
|
|
|
|
proportionalHeight: r.relatedEventCacheBuster, fromModel(Room.ProportionalHeight) ?? 1
|
|
|
|
type: r.relatedEventCacheBuster, fromModel(Room.Type) ?? MtxEvent.UnknownMessage
|
|
|
|
typeString: r.relatedEventCacheBuster, fromModel(Room.TypeString) ?? ""
|
|
|
|
url: r.relatedEventCacheBuster, fromModel(Room.Url) ?? ""
|
|
|
|
originalWidth: r.relatedEventCacheBuster, fromModel(Room.OriginalWidth) ?? 0
|
|
|
|
isOnlyEmoji: r.relatedEventCacheBuster, fromModel(Room.IsOnlyEmoji) ?? false
|
|
|
|
userId: r.relatedEventCacheBuster, fromModel(Room.UserId) ?? ""
|
|
|
|
userName: r.relatedEventCacheBuster, fromModel(Room.UserName) ?? ""
|
|
|
|
thumbnailUrl: r.relatedEventCacheBuster, fromModel(Room.ThumbnailUrl) ?? ""
|
|
|
|
roomTopic: r.relatedEventCacheBuster, fromModel(Room.RoomTopic) ?? ""
|
|
|
|
roomName: r.relatedEventCacheBuster, fromModel(Room.RoomName) ?? ""
|
|
|
|
callType: r.relatedEventCacheBuster, fromModel(Room.CallType) ?? ""
|
2021-08-07 23:51:09 +03:00
|
|
|
encryptionError: r.relatedEventCacheBuster, fromModel(Room.EncryptionError) ?? ""
|
2021-07-20 15:09:19 +03:00
|
|
|
relatedEventCacheBuster: r.relatedEventCacheBuster, fromModel(Room.RelatedEventCacheBuster) ?? 0
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// actual message content
|
|
|
|
MessageDelegate {
|
|
|
|
id: contentItem
|
|
|
|
|
|
|
|
width: parent.width
|
2021-07-12 01:24:33 +03:00
|
|
|
blurhash: r.blurhash
|
|
|
|
body: r.body
|
|
|
|
formattedBody: r.formattedBody
|
|
|
|
eventId: r.eventId
|
|
|
|
filename: r.filename
|
|
|
|
filesize: r.filesize
|
|
|
|
proportionalHeight: r.proportionalHeight
|
|
|
|
type: r.type
|
|
|
|
typeString: r.typeString ?? ""
|
|
|
|
url: r.url
|
|
|
|
thumbnailUrl: r.thumbnailUrl
|
|
|
|
originalWidth: r.originalWidth
|
|
|
|
isOnlyEmoji: r.isOnlyEmoji
|
|
|
|
userId: r.userId
|
|
|
|
userName: r.userName
|
2021-07-12 02:28:09 +03:00
|
|
|
roomTopic: r.roomTopic
|
|
|
|
roomName: r.roomName
|
|
|
|
callType: r.callType
|
2021-08-07 23:51:09 +03:00
|
|
|
encryptionError: r.encryptionError
|
2021-07-20 15:09:19 +03:00
|
|
|
relatedEventCacheBuster: r.relatedEventCacheBuster
|
2021-07-12 01:24:33 +03:00
|
|
|
isReply: false
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Reactions {
|
|
|
|
id: reactionRow
|
|
|
|
|
2021-07-12 01:24:33 +03:00
|
|
|
reactions: r.reactions
|
|
|
|
eventId: r.eventId
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIndicator {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
|
|
Layout.preferredHeight: 16
|
|
|
|
width: 16
|
2021-07-12 01:24:33 +03:00
|
|
|
status: r.status
|
|
|
|
eventId: r.eventId
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
EncryptionIndicator {
|
2021-07-10 17:12:38 +03:00
|
|
|
visible: room.isEncrypted
|
2021-07-12 01:24:33 +03:00
|
|
|
encrypted: isEncrypted
|
|
|
|
trust: trustlevel
|
2020-10-08 22:11:21 +03:00
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
|
|
Layout.preferredHeight: 16
|
2021-03-05 00:59:10 +03:00
|
|
|
Layout.preferredWidth: 16
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
2021-03-05 00:59:10 +03:00
|
|
|
Image {
|
2021-07-12 01:24:33 +03:00
|
|
|
visible: isEdited || eventId == chat.model.edit
|
2021-02-01 00:41:43 +03:00
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
|
|
Layout.preferredHeight: 16
|
2021-03-05 00:59:10 +03:00
|
|
|
Layout.preferredWidth: 16
|
|
|
|
height: 16
|
2021-02-01 00:41:43 +03:00
|
|
|
width: 16
|
2021-03-05 00:59:10 +03:00
|
|
|
sourceSize.width: 16
|
|
|
|
sourceSize.height: 16
|
2021-07-12 01:24:33 +03:00
|
|
|
source: "image://colorimage/:/icons/icons/ui/edit.png?" + ((eventId == chat.model.edit) ? Nheko.colors.highlight : Nheko.colors.buttonText)
|
2021-03-05 00:59:10 +03:00
|
|
|
ToolTip.visible: editHovered.hovered
|
|
|
|
ToolTip.text: qsTr("Edited")
|
2021-02-02 20:54:45 +03:00
|
|
|
|
2021-03-05 00:59:10 +03:00
|
|
|
HoverHandler {
|
|
|
|
id: editHovered
|
2021-02-02 20:54:45 +03:00
|
|
|
}
|
2020-10-08 22:11:21 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
2021-07-12 01:24:33 +03:00
|
|
|
text: timestamp.toLocaleTimeString(Locale.ShortFormat)
|
2020-10-08 22:11:21 +03:00
|
|
|
width: Math.max(implicitWidth, text.length * fontMetrics.maximumCharacterWidth)
|
2021-05-13 09:23:56 +03:00
|
|
|
color: Nheko.inactiveColors.text
|
2021-02-14 03:28:28 +03:00
|
|
|
ToolTip.visible: ma.hovered
|
2021-07-12 01:24:33 +03:00
|
|
|
ToolTip.text: Qt.formatDateTime(timestamp, Qt.DefaultLocaleLongDate)
|
2020-10-08 22:11:21 +03:00
|
|
|
|
2021-02-14 03:28:28 +03:00
|
|
|
HoverHandler {
|
2020-10-08 22:11:21 +03:00
|
|
|
id: ma
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-08 21:55:09 +03:00
|
|
|
}
|