matrixion/resources/qml/delegates/MessageDelegate.qml

472 lines
12 KiB
QML
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
2021-03-05 02:35:15 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.6
import im.nheko 1.0
Item {
id: d
required property bool isReply
2021-04-30 00:09:13 +03:00
property alias child: chooser.child
2020-10-08 22:11:21 +03:00
property real implicitWidth: (chooser.child && chooser.child.implicitWidth) ? chooser.child.implicitWidth : width
required property double proportionalHeight
required property int type
required property string typeString
required property int originalWidth
required property string blurhash
required property string body
required property string formattedBody
required property string eventId
required property string filename
required property string filesize
required property string url
required property string thumbnailUrl
required property bool isOnlyEmoji
required property string userId
required property string userName
2020-10-08 22:11:21 +03:00
height: chooser.childrenRect.height
DelegateChooser {
id: chooser
//role: "type" //< not supported in our custom implementation, have to use roleValue
roleValue: type
2020-10-08 22:11:21 +03:00
anchors.fill: parent
DelegateChoice {
roleValue: MtxEvent.UnknownMessage
Placeholder {
typeString: d.typeString
2020-10-08 22:11:21 +03:00
text: "Unretrieved event"
}
}
DelegateChoice {
roleValue: MtxEvent.TextMessage
TextMessage {
formatted: d.formattedBody
body: d.body
isOnlyEmoji: d.isOnlyEmoji
isReply: d.isReply
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.NoticeMessage
NoticeMessage {
formatted: d.formattedBody
body: d.body
isOnlyEmoji: d.isOnlyEmoji
isReply: d.isReply
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.EmoteMessage
NoticeMessage {
formatted: TimelineManager.escapeEmoji(d.userName) + " " + d.formattedBody
color: TimelineManager.userColor(d.userId, Nheko.colors.window)
body: d.body
isOnlyEmoji: d.isOnlyEmoji
isReply: d.isReply
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.ImageMessage
ImageMessage {
type: d.type
originalWidth: d.originalWidth
proportionalHeight: d.proportionalHeight
url: d.url
blurhash: d.blurhash
body: d.body
filename: d.filename
isReply: d.isReply
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Sticker
ImageMessage {
type: d.type
originalWidth: d.originalWidth
proportionalHeight: d.proportionalHeight
url: d.url
blurhash: d.blurhash
body: d.body
filename: d.filename
isReply: d.isReply
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.FileMessage
FileMessage {
eventId: d.eventId
filename: d.filename
filesize: d.filesize
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.VideoMessage
PlayableMediaMessage {
proportionalHeight: d.proportionalHeight
type: d.type
originalWidth: d.originalWidth
thumbnailUrl: d.thumbnailUrl
eventId: d.eventId
url: d.url
body: d.body
filesize: d.filesize
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.AudioMessage
PlayableMediaMessage {
proportionalHeight: d.proportionalHeight
type: d.type
originalWidth: d.originalWidth
thumbnailUrl: d.thumbnailUrl
eventId: d.eventId
url: d.url
body: d.body
filesize: d.filesize
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Redacted
Pill {
2020-11-26 11:50:37 +03:00
text: qsTr("removed")
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Redaction
Pill {
2020-11-26 11:50:37 +03:00
text: qsTr("removed")
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Encryption
Pill {
text: qsTr("Encryption enabled")
}
}
DelegateChoice {
roleValue: MtxEvent.Name
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: model.data.roomName ? qsTr("room name changed to: %1").arg(model.data.roomName) : qsTr("removed room name")
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Topic
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: model.data.roomTopic ? qsTr("topic changed to: %1").arg(model.data.roomTopic) : qsTr("removed topic")
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Avatar
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: qsTr("%1 changed the room avatar").arg(d.userName)
}
2021-07-03 23:45:36 +03:00
}
DelegateChoice {
2020-10-08 22:11:21 +03:00
roleValue: MtxEvent.RoomCreate
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: qsTr("%1 created and configured room: %2").arg(d.userName).arg(model.data.roomId)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CallInvite
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: {
2020-10-08 22:11:21 +03:00
switch (model.data.callType) {
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
}
}
}
}
DelegateChoice {
roleValue: MtxEvent.CallAnswer
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: qsTr("%1 answered the call.").arg(d.userName)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CallHangUp
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: qsTr("%1 ended the call.").arg(d.userName)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.CallCandidates
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: qsTr("Negotiating call...")
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
// TODO: make a more complex formatter for the power levels.
roleValue: MtxEvent.PowerLevels
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatPowerLevelEvent(d.eventId)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.RoomJoinRules
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatJoinRuleEvent(d.eventId)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.RoomHistoryVisibility
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatHistoryVisibilityEvent(d.eventId)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.RoomGuestAccess
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatGuestAccessEvent(d.eventId)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.Member
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatMemberEvent(d.eventId)
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationRequest
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationRequest"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationStart
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationStart"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationReady
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationReady"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationCancel
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationCancel"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationKey
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationKey"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationMac
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationMac"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationDone
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationDone"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationDone
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationDone"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
roleValue: MtxEvent.KeyVerificationAccept
NoticeMessage {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: "KeyVerificationAccept"
2020-10-08 22:11:21 +03:00
}
}
DelegateChoice {
Placeholder {
typeString: d.typeString
2020-10-08 22:11:21 +03:00
}
}
}
}