summary refs log tree commit diff
path: root/resources/qml/TimelineEvent.qml
blob: 7e60328dbf56d3186c1f2a3af960e436ce0628e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

import "./components"
import "./delegates"
import "./emoji"
import "./ui"
import "./dialogs"
import Qt.labs.platform 1.1 as Platform
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

    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

            color: type == MtxEvent.NoticeMessage ? palette.buttonText : palette.text
            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

            color: TimelineManager.userColor(userId, palette.base)
            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: ''
            color: palette.buttonText
            font.italic: true
            font.pointSize: Settings.fontSize * 0.8
            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
            color: palette.buttonText
            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
            color: palette.buttonText
            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 {
            required property string userId
            required property string userName

            Layout.fillWidth: true
            //Layout.maximumWidth: tempWidth
            //Layout.maximumHeight: timelineView.height / 8
            containerHeight: timelineView.height
        }
    }
    EventDelegateChoice {
        roleValues: [MtxEvent.FileMessage,]

        FileMessage {
            required property string userId
            required property string userName

            Layout.fillWidth: true
        }
    }
    EventDelegateChoice {
        roleValues: [MtxEvent.VideoMessage, MtxEvent.AudioMessage,]

        PlayableMediaMessage {
            required property string userId
            required property string userName

            Layout.fillWidth: true
        }
    }
    EventDelegateChoice {
        roleValues: [MtxEvent.Encrypted,]

        Encrypted {
            required property string userId
            required property string userName

            Layout.fillWidth: true
        }
    }
    EventDelegateChoice {
        roleValues: [MtxEvent.Encryption,]

        EncryptionEnabled {
            required property string userId

            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
                isReply: EventDelegateChooser.isReply
                isStateEvent: true
                keepFullText: true
            }
            Button {
                Layout.alignment: Qt.AlignHCenter
                text: qsTr("Allow them in")
                visible: member.room.showAcceptKnockButton(member.eventId)

                onClicked: member.room.acceptKnock(member.eventId)
            }
        }
    }
    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
                isReply: EventDelegateChooser.isReply
                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
        }
    }
}