matrixion/resources/qml/TimelineRow.qml

162 lines
4.7 KiB
QML
Raw Normal View History

2020-10-08 22:11:21 +03:00
import "./delegates"
import "./emoji"
2021-02-14 03:28:28 +03: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 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
Rectangle {
2021-02-14 03:28:28 +03:00
color: (Settings.messageHoverHighlight && hoverHandler.hovered) ? colors.alternateBase : "transparent"
anchors.fill: row
}
2021-02-14 03:28:28 +03:00
HoverHandler {
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
onSingleTapped: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row, mapToItem(timelineRoot, eventPoint.position.x, eventPoint.position.y))
}
TapHandler {
onLongPressed: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row, mapToItem(timelineRoot, point.position.x, point.position.y))
2020-10-08 22:11:21 +03:00
}
RowLayout {
id: row
anchors.leftMargin: avatarSize + 16
anchors.left: parent.left
anchors.right: parent.right
Column {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
spacing: 4
// fancy reply, if this is a reply
Reply {
visible: model.replyTo
modelData: chat.model.getDump(model.replyTo, model.id)
2020-10-26 15:50:44 +03:00
userColor: TimelineManager.userColor(modelData.userId, 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
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
}
2021-02-01 00:41:43 +03:00
ImageButton {
id: editButton
visible: (Settings.buttonsInTimeline && model.isEditable) || model.isEdited
buttonTextColor: chat.model.edit == model.id ? colors.highlight : colors.buttonText
2021-02-01 00:41:43 +03:00
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
hoverEnabled: true
image: ":/icons/icons/ui/edit.png"
ToolTip.visible: hovered
ToolTip.text: model.isEditable ? qsTr("Edit") : qsTr("Edited")
onClicked: {
if (model.isEditable)
chat.model.editAction(model.id);
}
2021-02-01 00:41:43 +03:00
}
2020-10-08 22:11:21 +03:00
EmojiButton {
id: reactButton
visible: Settings.buttonsInTimeline
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: qsTr("React")
emojiPicker: emojiPopup
event_id: model.id
}
ImageButton {
id: replyButton
visible: Settings.buttonsInTimeline
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
hoverEnabled: true
image: ":/icons/icons/ui/mail-reply.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Reply")
onClicked: chat.model.replyAction(model.id)
}
ImageButton {
id: optionsButton
visible: Settings.buttonsInTimeline
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
hoverEnabled: true
image: ":/icons/icons/ui/vertical-ellipsis.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Options")
onClicked: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, optionsButton)
2020-10-08 22:11:21 +03:00
}
Label {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
text: model.timestamp.toLocaleTimeString("HH:mm")
width: Math.max(implicitWidth, text.length * fontMetrics.maximumCharacterWidth)
color: inactiveColors.text
2021-02-14 03:28:28 +03:00
ToolTip.visible: ma.hovered
2020-10-08 22:11:21 +03:00
ToolTip.text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate)
2021-02-14 03:28:28 +03:00
HoverHandler {
2020-10-08 22:11:21 +03:00
id: ma
}
}
}
}