nheko/resources/qml/TimelineRow.qml

131 lines
3.7 KiB
QML
Raw Normal View History

2021-03-05 00:35:15 +01:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
2021-03-05 00:35:15 +01:00
// SPDX-License-Identifier: GPL-3.0-or-later
2020-10-08 21:11:21 +02:00
import "./delegates"
import "./emoji"
2021-02-14 01:28:28 +01:00
import QtQuick 2.12
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
import im.nheko 1.0
2020-07-26 02:06:38 +02:00
Item {
2020-10-08 21:11:21 +02:00
anchors.left: parent.left
anchors.right: parent.right
height: row.height
Rectangle {
2021-05-13 08:23:56 +02:00
color: (Settings.messageHoverHighlight && hoverHandler.hovered) ? Nheko.colors.alternateBase : "transparent"
anchors.fill: row
}
2021-02-14 01:28:28 +01:00
HoverHandler {
id: hoverHandler
2021-01-19 03:25:56 +01:00
2021-02-14 01:28:28 +01:00
acceptedDevices: PointerDevice.GenericPointer
}
TapHandler {
acceptedButtons: Qt.RightButton
onSingleTapped: messageContextMenu.show(model.id, model.type, model.isSender, model.isEncrypted, model.isEditable, contentItem.child.hoveredLink, contentItem.child.copyText)
2021-04-11 22:24:39 +02:00
gesturePolicy: TapHandler.ReleaseWithinBounds
2021-02-14 01:28:28 +01:00
}
TapHandler {
onLongPressed: messageContextMenu.show(model.id, model.type, model.isSender, model.isEncrypted, model.isEditable, contentItem.child.hoveredLink, contentItem.child.copyText)
onDoubleTapped: chat.model.reply = model.id
2021-04-11 22:24:39 +02:00
gesturePolicy: TapHandler.ReleaseWithinBounds
2020-10-08 21:11:21 +02:00
}
RowLayout {
id: row
anchors.rightMargin: 1
2021-05-13 11:32:20 +02:00
anchors.leftMargin: Nheko.avatarSize + 16
2020-10-08 21:11:21 +02:00
anchors.left: parent.left
anchors.right: parent.right
Column {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
spacing: 4
Layout.topMargin: 1
Layout.bottomMargin: 1
2020-10-08 21:11:21 +02:00
// fancy reply, if this is a reply
Reply {
visible: model.replyTo
modelData: chat.model.getDump(model.replyTo, model.id)
2021-05-13 08:23:56 +02:00
userColor: TimelineManager.userColor(modelData.userId, Nheko.colors.base)
2020-10-08 21:11:21 +02: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: room.isEncrypted
2020-10-08 21:11:21 +02:00
encrypted: model.isEncrypted
trust: model.trustlevel
2020-10-08 21:11:21 +02:00
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
Layout.preferredWidth: 16
2020-10-08 21:11:21 +02:00
}
Image {
2021-03-05 17:22:42 +01:00
visible: model.isEdited || model.id == chat.model.edit
2021-01-31 22:41:43 +01:00
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
Layout.preferredWidth: 16
height: 16
2021-01-31 22:41:43 +01:00
width: 16
sourceSize.width: 16
sourceSize.height: 16
2021-05-13 08:23:56 +02:00
source: "image://colorimage/:/icons/icons/ui/edit.png?" + ((model.id == chat.model.edit) ? Nheko.colors.highlight : Nheko.colors.buttonText)
ToolTip.visible: editHovered.hovered
ToolTip.text: qsTr("Edited")
HoverHandler {
id: editHovered
}
2020-10-08 21:11:21 +02:00
}
Label {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
2021-03-05 17:44:49 +01:00
text: model.timestamp.toLocaleTimeString(Locale.ShortFormat)
2020-10-08 21:11:21 +02:00
width: Math.max(implicitWidth, text.length * fontMetrics.maximumCharacterWidth)
2021-05-13 08:23:56 +02:00
color: Nheko.inactiveColors.text
2021-02-14 01:28:28 +01:00
ToolTip.visible: ma.hovered
2020-10-08 21:11:21 +02:00
ToolTip.text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate)
2021-02-14 01:28:28 +01:00
HoverHandler {
2020-10-08 21:11:21 +02:00
id: ma
}
}
}
}