matrixion/qml/delegates/MessageDelegate.qml

514 lines
16 KiB
QML
Raw Permalink Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
2021-03-05 02:35:15 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.6
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.2
2022-04-14 16:28:17 +03:00
import im.nheko
import im.nheko
Item {
id: d
required property string blurhash
required property string body
2022-04-16 03:13:01 +03:00
required property string callType
property alias child: chooser.child
required property int duration
required property int encryptionError
required property string eventId
required property string filename
required property string filesize
2022-04-16 03:13:01 +03:00
property bool fitsMetadata: (chooser.child && chooser.child.fitsMetadata) ? chooser.child.fitsMetadata : false
required property string formattedBody
required property bool isOnlyEmoji
2022-04-16 03:13:01 +03:00
required property bool isReply
required property bool isStateEvent
2022-04-16 03:13:01 +03:00
property int metadataWidth
required property int originalWidth
required property double proportionalHeight
required property int relatedEventCacheBuster
required property string roomName
required property string roomTopic
required property string thumbnailUrl
required property int type
required property string typeString
required property string url
required property string userId
required property string userName
2020-10-08 22:11:21 +03:00
height: chooser.child ? chooser.child.height : Nheko.paddingLarge
2022-04-16 03:13:01 +03:00
implicitWidth: (chooser.child && chooser.child.implicitWidth) ? chooser.child.implicitWidth : 0
2020-10-08 22:11:21 +03:00
DelegateChooser {
id: chooser
//role: "type" //< not supported in our custom implementation, have to use roleValue
roleValue: type
//anchors.fill: parent
2022-04-16 03:13:01 +03:00
width: parent.width ? parent.width : 0 // this should get rid of "cannot read property 'width' of null"
2020-10-08 22:11:21 +03:00
DelegateChoice {
roleValue: MtxEvent.UnknownMessage
Placeholder {
text: "Unretrieved event"
2022-04-16 03:13:01 +03:00
typeString: d.typeString
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.TextMessage
TextMessage {
body: d.body
2022-04-16 03:13:01 +03:00
formatted: d.formattedBody
isOnlyEmoji: d.isOnlyEmoji
isReply: d.isReply
2022-02-14 23:07:03 +03:00
metadataWidth: d.metadataWidth
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.NoticeMessage
NoticeMessage {
body: d.body
2022-04-16 03:13:01 +03:00
formatted: d.formattedBody
isOnlyEmoji: d.isOnlyEmoji
isReply: d.isReply
isStateEvent: d.isStateEvent
2022-02-14 23:59:35 +03:00
metadataWidth: d.metadataWidth
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.EmoteMessage
NoticeMessage {
body: d.body
2022-04-16 03:13:01 +03:00
color: TimelineManager.userColor(d.userId, timelineRoot.palette.base)
formatted: TimelineManager.escapeEmoji(d.userName) + " " + d.formattedBody
isOnlyEmoji: d.isOnlyEmoji
isReply: d.isReply
isStateEvent: d.isStateEvent
2022-02-14 23:59:35 +03:00
metadataWidth: d.metadataWidth
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.ImageMessage
ImageMessage {
blurhash: d.blurhash
body: d.body
2022-04-16 03:13:01 +03:00
eventId: d.eventId
filename: d.filename
isReply: d.isReply
2022-02-14 23:07:03 +03:00
metadataWidth: d.metadataWidth
2022-04-16 03:13:01 +03:00
originalWidth: d.originalWidth
proportionalHeight: d.proportionalHeight
type: d.type
url: d.url
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Sticker
ImageMessage {
blurhash: d.blurhash
body: d.body
2022-04-16 03:13:01 +03:00
eventId: d.eventId
filename: d.filename
isReply: d.isReply
2022-02-14 23:07:03 +03:00
metadataWidth: d.metadataWidth
2022-04-16 03:13:01 +03:00
originalWidth: d.originalWidth
proportionalHeight: d.proportionalHeight
type: d.type
url: d.url
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.FileMessage
FileMessage {
eventId: d.eventId
filename: d.filename
filesize: d.filesize
2022-02-14 23:07:03 +03:00
metadataWidth: d.metadataWidth
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.VideoMessage
PlayableMediaMessage {
body: d.body
2022-03-21 02:48:27 +03:00
duration: d.duration
2022-04-16 03:13:01 +03:00
eventId: d.eventId
filesize: d.filesize
2022-02-14 23:07:03 +03:00
metadataWidth: d.metadataWidth
2022-04-16 03:13:01 +03:00
originalWidth: d.originalWidth
proportionalHeight: d.proportionalHeight
thumbnailUrl: d.thumbnailUrl
type: d.type
url: d.url
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.AudioMessage
PlayableMediaMessage {
body: d.body
2022-03-21 02:48:27 +03:00
duration: d.duration
2022-04-16 03:13:01 +03:00
eventId: d.eventId
filesize: d.filesize
2022-02-14 23:07:03 +03:00
metadataWidth: d.metadataWidth
2022-04-16 03:13:01 +03:00
originalWidth: d.originalWidth
proportionalHeight: d.proportionalHeight
thumbnailUrl: d.thumbnailUrl
type: d.type
url: d.url
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Redacted
2021-11-29 03:59:57 +03:00
Redacted {
2022-02-14 23:07:03 +03:00
metadataWidth: d.metadataWidth
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Redaction
Pill {
isStateEvent: d.isStateEvent
2022-04-16 03:13:01 +03:00
text: qsTr("%1 removed a message").arg(d.userName)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Encryption
Pill {
isStateEvent: d.isStateEvent
2022-04-16 03:13:01 +03:00
text: qsTr("%1 enabled encryption").arg(d.userName)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Encrypted
Encrypted {
encryptionError: d.encryptionError
eventId: d.eventId
}
}
2020-10-08 22:11:21 +03:00
DelegateChoice {
roleValue: MtxEvent.Name
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.roomName ? qsTr("%2 changed the room name to: %1").arg(d.roomName).arg(d.userName) : qsTr("%1 removed the room name").arg(d.userName)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Topic
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.roomTopic ? qsTr("%2 changed the topic to: %1").arg(d.roomTopic).arg(d.userName) : qsTr("%1 removed the topic").arg(d.userName)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Avatar
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 changed the room avatar").arg(d.userName)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
}
}
2021-12-11 08:10:41 +03:00
DelegateChoice {
roleValue: MtxEvent.PinnedEvents
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 changed the pinned messages.").arg(d.userName)
2021-12-11 08:10:41 +03:00
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2021-12-11 08:10:41 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.ImagePackInRoom
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.relatedEventCacheBuster, room.formatImagePackEvent(d.eventId)
2021-12-11 08:10:41 +03:00
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2021-12-11 08:10:41 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CanonicalAlias
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 changed the addresses for this room.").arg(d.userName)
2021-12-11 08:10:41 +03:00
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2021-12-11 08:10:41 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.SpaceParent
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 changed the parent spaces for this room.").arg(d.userName)
2021-12-11 08:10:41 +03:00
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2021-12-11 08:10:41 +03:00
}
}
DelegateChoice {
2020-10-08 22:11:21 +03:00
roleValue: MtxEvent.RoomCreate
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 created and configured room: %2").arg(d.userName).arg(room.roomId)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CallInvite
NoticeMessage {
body: formatted
formatted: {
2021-07-12 02:28:09 +03:00
switch (d.callType) {
2020-10-08 22:11:21 +03:00
case "voice":
return qsTr("%1 placed a voice call.").arg(d.userName);
2020-10-08 22:11:21 +03:00
case "video":
return qsTr("%1 placed a video call.").arg(d.userName);
2020-10-08 22:11:21 +03:00
default:
return qsTr("%1 placed a call.").arg(d.userName);
2020-10-08 22:11:21 +03:00
}
}
2022-04-16 03:13:01 +03:00
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CallAnswer
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 answered the call.").arg(d.userName)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CallHangUp
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 ended the call.").arg(d.userName)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CallCandidates
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: qsTr("%1 is negotiating the call...").arg(d.userName)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.PowerLevels
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.relatedEventCacheBuster, room.formatPowerLevelEvent(d.eventId)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.RoomJoinRules
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.relatedEventCacheBuster, room.formatJoinRuleEvent(d.eventId)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.RoomHistoryVisibility
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.relatedEventCacheBuster, room.formatHistoryVisibilityEvent(d.eventId)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.RoomGuestAccess
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.relatedEventCacheBuster, room.formatGuestAccessEvent(d.eventId)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Member
ColumnLayout {
2022-04-11 05:18:16 +03:00
width: parent?.width
NoticeMessage {
2022-04-16 03:13:01 +03:00
Layout.fillWidth: true
body: formatted
2022-04-16 03:13:01 +03:00
formatted: d.relatedEventCacheBuster, room.formatMemberEvent(d.eventId)
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
}
Button {
2022-04-11 05:18:16 +03:00
palette: timelineRoot.palette
text: qsTr("Allow them in")
2022-04-16 03:13:01 +03:00
visible: d.relatedEventCacheBuster, room.showAcceptKnockButton(d.eventId)
onClicked: room.acceptKnock(eventId)
}
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationRequest
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationRequest"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationStart
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationStart"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationReady
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationReady"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationCancel
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationCancel"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationKey
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationKey"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationMac
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationMac"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationDone
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationDone"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationDone
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationDone"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationAccept
NoticeMessage {
body: formatted
2022-04-16 03:13:01 +03:00
formatted: "KeyVerificationAccept"
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
Placeholder {
typeString: d.typeString
2020-10-08 22:11:21 +03:00
}
}
}
}