mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
127 lines
3.4 KiB
QML
127 lines
3.4 KiB
QML
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import "./delegates"
|
|
import "./emoji"
|
|
import QtQuick 2.12
|
|
import QtQuick.Controls 2.3
|
|
import QtQuick.Layouts 1.2
|
|
import QtQuick.Window 2.2
|
|
import im.nheko 1.0
|
|
|
|
Item {
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
height: row.height
|
|
|
|
Rectangle {
|
|
color: (Settings.messageHoverHighlight && hoverHandler.hovered) ? colors.alternateBase : "transparent"
|
|
anchors.fill: row
|
|
}
|
|
|
|
HoverHandler {
|
|
id: hoverHandler
|
|
|
|
acceptedDevices: PointerDevice.GenericPointer
|
|
}
|
|
|
|
TapHandler {
|
|
acceptedButtons: Qt.RightButton
|
|
onSingleTapped: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row)
|
|
}
|
|
|
|
TapHandler {
|
|
onLongPressed: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row)
|
|
onDoubleTapped: chat.model.reply = model.id
|
|
}
|
|
|
|
RowLayout {
|
|
id: row
|
|
|
|
anchors.rightMargin: 1
|
|
anchors.leftMargin: avatarSize + 16
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
|
|
Column {
|
|
Layout.fillWidth: true
|
|
Layout.alignment: Qt.AlignTop
|
|
spacing: 4
|
|
Layout.topMargin: 1
|
|
Layout.bottomMargin: 1
|
|
|
|
// fancy reply, if this is a reply
|
|
Reply {
|
|
visible: model.replyTo
|
|
modelData: chat.model.getDump(model.replyTo, model.id)
|
|
userColor: TimelineManager.userColor(modelData.userId, colors.base)
|
|
}
|
|
|
|
// 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
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
Layout.preferredHeight: 16
|
|
Layout.preferredWidth: 16
|
|
}
|
|
|
|
Image {
|
|
visible: model.isEdited || model.id == chat.model.edit
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
Layout.preferredHeight: 16
|
|
Layout.preferredWidth: 16
|
|
height: 16
|
|
width: 16
|
|
sourceSize.width: 16
|
|
sourceSize.height: 16
|
|
source: "image://colorimage/:/icons/icons/ui/edit.png?" + ((model.id == chat.model.edit) ? colors.highlight : colors.buttonText)
|
|
ToolTip.visible: editHovered.hovered
|
|
ToolTip.text: qsTr("Edited")
|
|
|
|
HoverHandler {
|
|
id: editHovered
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
text: model.timestamp.toLocaleTimeString(Locale.ShortFormat)
|
|
width: Math.max(implicitWidth, text.length * fontMetrics.maximumCharacterWidth)
|
|
color: inactiveColors.text
|
|
ToolTip.visible: ma.hovered
|
|
ToolTip.text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate)
|
|
|
|
HoverHandler {
|
|
id: ma
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|