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
|
|
|
|
import QtQuick.Window 2.2
|
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 {
|
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-05-02 19:01:18 +03:00
|
|
|
onSingleTapped: messageContextMenu.show(model.id, model.type, model.isSender, model.isEncrypted, model.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-05-02 19:01:18 +03:00
|
|
|
onLongPressed: messageContextMenu.show(model.id, model.type, model.isSender, model.isEncrypted, model.isEditable, contentItem.child.hoveredLink, contentItem.child.copyText)
|
2021-02-14 03:56:46 +03:00
|
|
|
onDoubleTapped: chat.model.reply = model.id
|
2021-04-11 23:24:39 +03:00
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: row
|
|
|
|
|
2021-06-15 14:41:08 +03:00
|
|
|
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 1.5)
|
|
|
|
|
2021-03-05 18:47:20 +03:00
|
|
|
anchors.rightMargin: 1
|
2021-06-15 14:41:08 +03:00
|
|
|
anchors.leftMargin: avatarSize + Nheko.paddingMedium
|
2020-10-08 22:11:21 +03:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
Column {
|
2021-06-15 14:41:08 +03:00
|
|
|
id: messageCol
|
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
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 {
|
|
|
|
visible: model.replyTo
|
|
|
|
modelData: chat.model.getDump(model.replyTo, model.id)
|
2021-05-13 09:23:56 +03:00
|
|
|
userColor: TimelineManager.userColor(modelData.userId, Nheko.colors.base)
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// actual message content
|
|
|
|
MessageDelegate {
|
|
|
|
id: contentItem
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
modelData: model
|
|
|
|
}
|
|
|
|
|
|
|
|
Reactions {
|
|
|
|
id: reactionRow
|
|
|
|
|
|
|
|
reactions: model.reactions
|
|
|
|
eventId: model.id
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIndicator {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
|
|
Layout.preferredHeight: 16
|
|
|
|
width: 16
|
|
|
|
}
|
|
|
|
|
|
|
|
EncryptionIndicator {
|
|
|
|
visible: model.isRoomEncrypted
|
|
|
|
encrypted: model.isEncrypted
|
2021-05-07 13:19:46 +03:00
|
|
|
trust: model.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-03-05 19:22:42 +03:00
|
|
|
visible: model.isEdited || model.id == 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-05-13 09:23:56 +03:00
|
|
|
source: "image://colorimage/:/icons/icons/ui/edit.png?" + ((model.id == 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
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-06-15 14:41:08 +03:00
|
|
|
}
|
2020-10-08 22:11:21 +03:00
|
|
|
|
2021-06-15 14:41:08 +03:00
|
|
|
Label {
|
|
|
|
id: ts
|
|
|
|
|
|
|
|
property int marginPadding: Math.floor((fontMetrics.font.pixelSize - smallFontMetrics.font.pixelSize) / 2)
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: marginPadding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: (reactionRow.height > 0 ? reactionRow.height + messageCol.spacing : 0) + marginPadding
|
|
|
|
text: model.timestamp.toLocaleTimeString(Locale.ShortFormat)
|
|
|
|
width: Math.max(implicitWidth, text.length * smallFontMetrics.maximumCharacterWidth)
|
|
|
|
font.pixelSize: smallFontMetrics.font.pixelSize
|
|
|
|
color: Nheko.inactiveColors.text
|
|
|
|
ToolTip.visible: ma.hovered
|
|
|
|
ToolTip.text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate)
|
|
|
|
|
|
|
|
FontMetrics {
|
|
|
|
id: smallFontMetrics
|
|
|
|
|
|
|
|
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.6)
|
|
|
|
}
|
2020-10-08 22:11:21 +03:00
|
|
|
|
2021-06-15 14:41:08 +03:00
|
|
|
HoverHandler {
|
|
|
|
id: ma
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-08 21:55:09 +03:00
|
|
|
}
|