2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-01-12 17:03:39 +03:00
|
|
|
import QtQuick 2.6
|
2019-11-30 03:43:39 +03:00
|
|
|
import im.nheko 1.0
|
2019-10-20 13:39:47 +03:00
|
|
|
|
2020-01-11 16:07:51 +03:00
|
|
|
Item {
|
2020-10-08 22:11:21 +03:00
|
|
|
property alias modelData: model.data
|
|
|
|
property alias isReply: model.isReply
|
|
|
|
property real implicitWidth: (chooser.child && chooser.child.implicitWidth) ? chooser.child.implicitWidth : width
|
|
|
|
|
|
|
|
height: chooser.childrenRect.height
|
|
|
|
|
|
|
|
// Workaround to have an assignable global property
|
|
|
|
Item {
|
|
|
|
id: model
|
|
|
|
|
|
|
|
property var data
|
|
|
|
property bool isReply: false
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChooser {
|
|
|
|
id: chooser
|
|
|
|
|
|
|
|
//role: "type" //< not supported in our custom implementation, have to use roleValue
|
|
|
|
roleValue: model.data.type
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.UnknownMessage
|
|
|
|
|
|
|
|
Placeholder {
|
|
|
|
text: "Unretrieved event"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.TextMessage
|
|
|
|
|
|
|
|
TextMessage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.NoticeMessage
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.EmoteMessage
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
formatted: TimelineManager.escapeEmoji(modelData.userName) + " " + model.data.formattedBody
|
|
|
|
color: TimelineManager.userColor(modelData.userId, colors.window)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.ImageMessage
|
|
|
|
|
|
|
|
ImageMessage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.Sticker
|
|
|
|
|
|
|
|
ImageMessage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.FileMessage
|
|
|
|
|
|
|
|
FileMessage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.VideoMessage
|
|
|
|
|
|
|
|
PlayableMediaMessage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.AudioMessage
|
|
|
|
|
|
|
|
PlayableMediaMessage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
text: model.data.roomName ? qsTr("room name changed to: %1").arg(model.data.roomName) : qsTr("removed room name")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.Topic
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: model.data.roomTopic ? qsTr("topic changed to: %1").arg(model.data.roomTopic) : qsTr("removed topic")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.RoomCreate
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: qsTr("%1 created and configured room: %2").arg(model.data.userName).arg(model.data.roomId)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.CallInvite
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: {
|
|
|
|
switch (model.data.callType) {
|
|
|
|
case "voice":
|
|
|
|
return qsTr("%1 placed a voice call.").arg(model.data.userName);
|
|
|
|
case "video":
|
|
|
|
return qsTr("%1 placed a video call.").arg(model.data.userName);
|
|
|
|
default:
|
|
|
|
return qsTr("%1 placed a call.").arg(model.data.userName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.CallAnswer
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: qsTr("%1 answered the call.").arg(model.data.userName)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.CallHangUp
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: qsTr("%1 ended the call.").arg(model.data.userName)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.CallCandidates
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: qsTr("Negotiating call...")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
// TODO: make a more complex formatter for the power levels.
|
|
|
|
roleValue: MtxEvent.PowerLevels
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: TimelineManager.timeline.formatPowerLevelEvent(model.data.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.RoomJoinRules
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: TimelineManager.timeline.formatJoinRuleEvent(model.data.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.RoomHistoryVisibility
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: TimelineManager.timeline.formatHistoryVisibilityEvent(model.data.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.RoomGuestAccess
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: TimelineManager.timeline.formatGuestAccessEvent(model.data.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.Member
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: TimelineManager.timeline.formatMemberEvent(model.data.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationRequest
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationRequest"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationStart
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationStart"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationReady
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationReady"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationCancel
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationCancel"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationKey
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationKey"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationMac
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationMac"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationDone
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationDone"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationDone
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationDone"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: MtxEvent.KeyVerificationAccept
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
text: "KeyVerificationAccept"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
Placeholder {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-20 13:39:47 +03:00
|
|
|
}
|