2023-08-25 21:43:04 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import "./delegates"
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
import QtQuick.Window 2.13
|
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
EventDelegateChooser {
|
|
|
|
id: wrapper
|
|
|
|
|
|
|
|
required property bool isStateEvent
|
2024-05-27 22:57:26 +03:00
|
|
|
property bool scrolledToThis: false
|
2023-08-25 21:43:04 +03:00
|
|
|
|
2023-10-26 22:43:05 +03:00
|
|
|
// qmllint disable required
|
2023-08-25 21:43:04 +03:00
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.TextMessage, MtxEvent.NoticeMessage, MtxEvent.ElementEffectMessage, MtxEvent.UnknownMessage,]
|
|
|
|
|
|
|
|
TextMessage {
|
|
|
|
required property string formattedBody
|
|
|
|
required property int type
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
//Layout.maximumWidth: implicitWidth
|
|
|
|
|
2023-10-10 02:10:10 +03:00
|
|
|
color: type == MtxEvent.NoticeMessage ? palette.active.buttonText : palette.active.text
|
2023-08-25 21:43:04 +03:00
|
|
|
font.italic: type == MtxEvent.NoticeMessage
|
|
|
|
formatted: formattedBody
|
|
|
|
keepFullText: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.EmoteMessage,]
|
|
|
|
|
|
|
|
TextMessage {
|
|
|
|
required property string formattedBody
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
//Layout.maximumWidth: implicitWidth
|
|
|
|
|
2023-10-10 02:10:10 +03:00
|
|
|
color: TimelineManager.userColor(userId, palette.active.base)
|
2023-08-25 21:43:04 +03:00
|
|
|
font.italic: true
|
|
|
|
formatted: TimelineManager.escapeEmoji(userName) + " " + formattedBody
|
|
|
|
keepFullText: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.CanonicalAlias, MtxEvent.ServerAcl, MtxEvent.Name, MtxEvent.Topic, MtxEvent.Avatar, MtxEvent.PinnedEvents, MtxEvent.ImagePackInRoom, MtxEvent.SpaceParent, MtxEvent.RoomCreate, MtxEvent.PowerLevels, MtxEvent.PolicyRuleUser, MtxEvent.PolicyRuleRoom, MtxEvent.PolicyRuleServer, MtxEvent.RoomJoinRules, MtxEvent.RoomHistoryVisibility, MtxEvent.RoomGuestAccess,]
|
|
|
|
|
|
|
|
TextMessage {
|
|
|
|
required property string formattedStateEvent
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
body: ''
|
2023-10-10 02:10:10 +03:00
|
|
|
color: palette.active.buttonText
|
2023-08-25 21:43:04 +03:00
|
|
|
font.italic: true
|
2023-10-09 00:52:23 +03:00
|
|
|
font.pointSize: Settings.fontSize * 0.8
|
2023-08-25 21:43:04 +03:00
|
|
|
formatted: ''
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
isOnlyEmoji: false
|
|
|
|
keepFullText: true
|
|
|
|
text: formattedStateEvent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.CallInvite,]
|
|
|
|
|
|
|
|
TextMessage {
|
|
|
|
required property string callType
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
body: formatted
|
2023-10-10 02:10:10 +03:00
|
|
|
color: palette.active.buttonText
|
2023-08-25 21:43:04 +03:00
|
|
|
font.italic: true
|
|
|
|
formatted: {
|
|
|
|
switch (callType) {
|
|
|
|
case "voice":
|
|
|
|
return qsTr("%1 placed a voice call.").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
case "video":
|
|
|
|
return qsTr("%1 placed a video call.").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
default:
|
|
|
|
return qsTr("%1 placed a call.").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isOnlyEmoji: false
|
|
|
|
keepFullText: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.CallAnswer, MtxEvent.CallReject, MtxEvent.CallSelectAnswer, MtxEvent.CallHangUp, MtxEvent.CallCandidates, MtxEvent.CallNegotiate,]
|
|
|
|
|
|
|
|
TextMessage {
|
|
|
|
required property int type
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
body: formatted
|
2023-10-10 02:10:10 +03:00
|
|
|
color: palette.active.buttonText
|
2023-08-25 21:43:04 +03:00
|
|
|
font.italic: true
|
|
|
|
formatted: {
|
|
|
|
switch (type) {
|
|
|
|
case MtxEvent.CallAnswer:
|
|
|
|
return qsTr("%1 answered the call.").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
case MtxEvent.CallReject:
|
|
|
|
return qsTr("%1 rejected the call.").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
case MtxEvent.CallSelectAnswer:
|
|
|
|
return qsTr("%1 selected answer.").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
case MtxEvent.CallHangUp:
|
|
|
|
return qsTr("%1 ended the call.").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
case MtxEvent.CallCandidates:
|
|
|
|
return qsTr("%1 is negotiating the call...").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
case MtxEvent.CallNegotiate:
|
|
|
|
return qsTr("%1 is negotiating the call...").arg(TimelineManager.escapeEmoji(userName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isOnlyEmoji: false
|
|
|
|
keepFullText: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.ImageMessage, MtxEvent.Sticker,]
|
|
|
|
|
|
|
|
ImageMessage {
|
2023-08-26 12:10:41 +03:00
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
2023-08-25 21:43:04 +03:00
|
|
|
Layout.fillWidth: true
|
2023-09-18 00:11:24 +03:00
|
|
|
//Layout.maximumWidth: tempWidth
|
|
|
|
//Layout.maximumHeight: timelineView.height / 8
|
2023-08-25 21:43:04 +03:00
|
|
|
containerHeight: timelineView.height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.FileMessage,]
|
|
|
|
|
|
|
|
FileMessage {
|
2023-08-26 12:10:41 +03:00
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
2023-08-25 21:43:04 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.VideoMessage, MtxEvent.AudioMessage,]
|
|
|
|
|
|
|
|
PlayableMediaMessage {
|
2023-08-26 12:10:41 +03:00
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
2023-08-25 21:43:04 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.Encrypted,]
|
|
|
|
|
|
|
|
Encrypted {
|
2023-08-26 12:10:41 +03:00
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
2023-08-25 21:43:04 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.Encryption,]
|
|
|
|
|
|
|
|
EncryptionEnabled {
|
2023-08-26 12:10:41 +03:00
|
|
|
required property string userId
|
|
|
|
|
2023-08-25 21:43:04 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.Redacted]
|
|
|
|
|
|
|
|
Redacted {
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.Member]
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: member
|
|
|
|
|
|
|
|
required property string formattedStateEvent
|
|
|
|
required property Room room
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
body: formatted
|
|
|
|
formatted: member.formattedStateEvent
|
|
|
|
isOnlyEmoji: false
|
2023-10-09 00:52:23 +03:00
|
|
|
isReply: EventDelegateChooser.isReply
|
2023-08-25 21:43:04 +03:00
|
|
|
isStateEvent: true
|
|
|
|
keepFullText: true
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Allow them in")
|
2023-10-09 20:32:06 +03:00
|
|
|
visible: member.room.showAcceptKnockButton(member.eventId)
|
2023-08-25 21:43:04 +03:00
|
|
|
|
2023-10-09 20:32:06 +03:00
|
|
|
onClicked: member.room.acceptKnock(member.eventId)
|
2023-08-25 21:43:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: [MtxEvent.Tombstone]
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: tombstone
|
|
|
|
|
|
|
|
required property string body
|
|
|
|
required property string eventId
|
|
|
|
required property Room room
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
NoticeMessage {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
body: formatted
|
|
|
|
formatted: qsTr("This room was replaced for the following reason: %1").arg(tombstone.body)
|
|
|
|
isOnlyEmoji: false
|
2023-10-09 00:52:23 +03:00
|
|
|
isReply: EventDelegateChooser.isReply
|
2023-08-25 21:43:04 +03:00
|
|
|
isStateEvent: true
|
|
|
|
keepFullText: true
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Go to replacement room")
|
|
|
|
|
|
|
|
onClicked: tombstone.room.joinReplacementRoom(tombstone.eventId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EventDelegateChoice {
|
|
|
|
roleValues: []
|
|
|
|
|
|
|
|
MatrixText {
|
|
|
|
required property string typeString
|
|
|
|
required property string userId
|
|
|
|
required property string userName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: "Unsupported: " + typeString
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 22:43:05 +03:00
|
|
|
// qmllint enable required
|
2023-08-25 21:43:04 +03:00
|
|
|
}
|