-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
MainReportToolPage.qml
453 lines (392 loc) · 18.4 KB
/
MainReportToolPage.qml
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
// SPDX-FileCopyrightText: 2023 Rishi Kumar <[email protected]>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick
import QtQuick.Controls 2 as QQC2
import QtQuick.Layouts
import org.kde.kirigami 2 as Kirigami
import org.kde.tokodon
import org.kde.tokodon.private
import org.kde.kirigamiaddons.formcard 1 as FormCard
import org.kde.kirigamiaddons.components 1 as KirigamiComponents
import "../PostDelegate"
Kirigami.ScrollablePage {
id: root
property var reportInfo
property int index
property var model
property var arr: []
property bool isInitial: true
property bool trigger: false
readonly property bool isAssignedModeratorSelectedAccount: root.reportInfo.assignedModerator ? root.reportInfo.assignedAccount.userLevelIdentity.id === AccountManager.selectedAccountId : false
readonly property bool assignedModerator: root.reportInfo.assignedAccount
property bool displayAttachmentPanel: root.reportInfo.statusCount || root.reportInfo.mediaAttachmentCount
function isChecked(ruleId) {
for (var i = 0; i < root.reportInfo.rules.length; i++) {
if (ruleId === root.reportInfo.rules[i].id) {
arr.push(ruleId)
return true;
}
}
return false;
}
function ammendOrDelete(inp) {
var index = arr.indexOf(inp);
if (index !== -1) {
arr.splice(index, 1);
} else {
arr.push(inp);
}
}
title: i18n("Report #%1", root.reportInfo.reportId)
actions: Kirigami.Action {
icon.name: root.reportInfo.actionTaken ? "edit-delete-remove" : "checkmark"
text: root.reportInfo.actionTaken ? i18n("Mark as unresolved") : i18n("Mark as resolved")
onTriggered: {
if (root.reportInfo.actionTaken) {
root.model.unresolveReport(root.index)
showPassiveNotification(i18n("Report Unresolved"))
} else {
root.model.resolveReport(root.index)
showPassiveNotification(i18n("Report Resolved"))
}
}
}
data: RulesModel {
id: rulesModel
account: AccountManager.selectedAccount
}
ColumnLayout {
id: profileInfo
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
Rectangle {
Layout.preferredHeight: Kirigami.Units.gridUnit * 9
Layout.fillWidth: true
clip: true
color: Kirigami.Theme.backgroundColor
Kirigami.Theme.colorSet: Kirigami.Theme.View
ProfileHeader {
backgroundUrl: root.reportInfo.targetAccount.userLevelIdentity.backgroundUrl
avatarUrl: root.reportInfo.targetAccount.userLevelIdentity.avatarUrl
displayName: root.reportInfo.targetAccount.userLevelIdentity.displayName
account: root.reportInfo.targetAccount.userLevelIdentity.account
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
RowLayout {
visible: root.reportInfo.targetAccount.userLevelIdentity.bio
spacing: 0
QQC2.Pane {
contentItem: QQC2.Label {
text: i18nc("@info Bio label of account.", "Bio")
wrapMode: Text.Wrap
}
Layout.minimumWidth: Kirigami.Units.gridUnit * 10
Layout.maximumWidth: Kirigami.Units.gridUnit * 10
Kirigami.Theme.colorSet: Kirigami.Theme.View
leftPadding: Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing
bottomPadding: 0
topPadding: 0
}
QQC2.TextArea {
text: root.reportInfo.targetAccount.userLevelIdentity.bio
textFormat: TextEdit.RichText
readOnly: true
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.smallSpacing
leftPadding: 0
rightPadding: 0
bottomPadding: 0
topPadding: 0
background: null
wrapMode: TextEdit.Wrap
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton // don't eat clicks on the Text
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
}
FormCard.FormGridContainer {
id: container
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
infoCards: [
FormCard.FormGridContainer.InfoCard {
title: root.reportInfo.targetAccount.userLevelIdentity.statusesCount
subtitle: i18nc("@info Number of Posts", "Posts")
},
FormCard.FormGridContainer.InfoCard {
title: root.reportInfo.targetAccount.userLevelIdentity.followersCount
subtitle: i18nc("@info Number of followers.", "Followers")
},
FormCard.FormGridContainer.InfoCard {
title: root.reportInfo.targetAccount.userLevelIdentity.followingCount
subtitle: i18nc("@info Row Number of accounts followed by the account", "Following")
},
FormCard.FormGridContainer.InfoCard {
title: root.reportInfo.targetAccount.joined.toLocaleString()
subtitle: i18nc("@info Time at which the reported account joined.", "Joined")
},
FormCard.FormGridContainer.InfoCard {
title: root.reportInfo.targetAccount.lastActive.toLocaleString()
subtitle: i18nc("@info The last time the reported account was active.", "Last Active")
},
FormCard.FormGridContainer.InfoCard {
title: root.reportInfo.createdAt.toLocaleString()
subtitle: i18nc("@info The current login status of the account.", "Reported")
}
]
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
visible: true
FormCard.FormTextDelegate {
visible: true
text: i18nc("@info Time at which the report was made", "Reported")
description: root.reportInfo.createdAt.toLocaleString()
}
FormCard.FormDelegateSeparator {}
FormCard.FormTextDelegate {
visible: root.reportInfo.filedAccount
text: i18n("Reported By")
description: root.reportInfo.filedAccount.userLevelIdentity.account
leadingPadding: Kirigami.Units.largeSpacing
leading: KirigamiComponents.Avatar {
source: root.reportInfo.filedAccount.userLevelIdentity.avatarUrl
implicitHeight: Kirigami.Units.gridUnit * 2
implicitWidth: Kirigami.Units.gridUnit * 2
}
}
FormCard.FormDelegateSeparator {}
FormCard.FormTextDelegate {
visible: true
text: i18n("Report Status")
description: root.reportInfo.actionTaken ? i18n("Resolved") : i18n("Unresolved")
}
FormCard.FormDelegateSeparator {}
FormCard.FormTextDelegate {
visible: root.reportInfo.actionTakenByAccount.userLevelIdentity.account
text: i18n("Action taken by")
description: root.reportInfo.actionTakenByAccount.userLevelIdentity.account
leadingPadding: Kirigami.Units.largeSpacing
leading: KirigamiComponents.Avatar {
source: root.reportInfo.actionTakenByAccount.userLevelIdentity.avatarUrl
implicitHeight: Kirigami.Units.gridUnit * 2
implicitWidth: Kirigami.Units.gridUnit * 2
}
}
FormCard.FormDelegateSeparator {}
FormCard.FormTextDelegate {
text: i18n("Assigned moderator")
description: root.reportInfo.assignedModerator ? root.reportInfo.assignedAccount.userLevelIdentity.account : i18n("No one")
leadingPadding: Kirigami.Units.largeSpacing
leading: KirigamiComponents.Avatar {
source: root.reportInfo.assignedModerator ? root.reportInfo.assignedAccount.userLevelIdentity.avatarUrl : ""
implicitHeight: Kirigami.Units.gridUnit * 2
implicitWidth: Kirigami.Units.gridUnit * 2
}
trailing: QQC2.Button {
text: assignedModerator ? (isAssignedModeratorSelectedAccount ? i18n("Unassign") : i18n("Assign to me")) : i18n("Assign to me")
icon.name: "im-user"
onClicked: assignedModerator ? (isAssignedModeratorSelectedAccount ? root.model.unassignReport(root.index) : root.model.assignReport(root.index)) : root.model.assignReport(root.index)
}
}
FormCard.FormDelegateSeparator {}
FormCard.FormTextDelegate {
visible: !root.reportInfo.targetAccount.isLocal
text: i18n("Forwarded")
description: root.reportInfo.forwarded ? i18nc("@info:The report is forwarded", "Yes") : i18nc("@info:The report is not forwarded", "No")
}
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("Category")
}
QQC2.Label {
text: i18n("The reason this account and/or content was reported will be cited in communication with the reported account")
Layout.fillWidth: true
wrapMode: Text.Wrap
Layout.leftMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
}
FormCard.FormDelegateSeparator {}
FormCard.FormRadioDelegate {
id: other
text: i18n("Other")
checked: root.reportInfo.category === "other"
onCheckedChanged: if (checked && !isInitial) {
arr = []
root.model.updateReport(index, "other", arr)
showPassiveNotification(i18n("Category changed to other"))
} else {
isInitial = false
}
}
FormCard.FormDelegateSeparator { below: other ; above: spam }
FormCard.FormRadioDelegate {
id: spam
checked: root.reportInfo.category === "spam"
text: i18n("Spam")
onCheckedChanged: if (checked && !isInitial) {
arr = []
root.model.updateReport(index, "spam", arr)
showPassiveNotification(i18n("Category changed to spam"))
} else {
isInitial = false
}
}
FormCard.FormDelegateSeparator { below: spam }
FormCard.FormRadioDelegate {
id: serverRules
checked: root.reportInfo.category === "violation"
text: i18n("Content violates one or more server rules")
onCheckedChanged: if (checked && !isInitial) {
arr = []
root.model.updateReport(index, "violation", arr)
showPassiveNotification(i18n("Category changed to rule violation"))
} else {
isInitial = false
}
}
Repeater {
id: rulesList
model: serverRules.checked ? rulesModel : []
delegate: ColumnLayout {
id: ruleLayout
required property int index
required property string text
required property string id
spacing: 0
FormCard.FormCheckDelegate {
id: ruleLabel
focusPolicy: Qt.NoFocus
hoverEnabled: false
Layout.leftMargin: Kirigami.Units.largeSpacing * 4
text: ruleLayout.text
checked: isChecked(ruleLayout.id)
Component.onCompleted: if (ruleLayout.index === rulesList.model.length -1) {
root.trigger = true
}
onCheckedChanged: if (root.trigger) {
ammendOrDelete(ruleLayout.id)
root.model.updateReport(ruleLayout.index, "violation", arr)
}
}
}
}
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("To provide more information, %1 wrote:", root.reportInfo.filedAccount.userLevelIdentity.account)
}
FormCard.FormTextDelegate {
visible: true
text: root.reportInfo.filedAccount.userLevelIdentity.account
trailing: QQC2.Label {
text: root.reportInfo.createdAt.toLocaleDateString()
}
description: root.reportInfo.comment ? root.reportInfo.comment : i18nc("@info:Account didn't provide any comment on the report ","N/A")
leadingPadding: Kirigami.Units.largeSpacing
leading: KirigamiComponents.Avatar {
source: root.reportInfo.filedAccount.userLevelIdentity.avatarUrl
implicitHeight: Kirigami.Units.gridUnit * 2
implicitWidth: Kirigami.Units.gridUnit * 2
}
}
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
visible: root.displayAttachmentPanel
FormCard.FormHeader {
title: i18n("Reported Content")
}
QQC2.Label {
text: i18n("Offending content will be cited in communication with the reported account")
Layout.leftMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
}
FormCard.FormDelegateSeparator {}
Repeater {
id: statusList
model: root.reportInfo.reportStatus
delegate: ColumnLayout {
required property var modelData
spacing: 0
Layout.fillWidth: true
Layout.bottomMargin: Kirigami.Units.largeSpacing
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.leftMargin: Kirigami.Units.gridUnit
Layout.rightMargin: Kirigami.Units.gridUnit
RowLayout {
Layout.preferredHeight: spoilerTextLabel.contentHeight + Kirigami.Units.gridUnit * 2
visible: modelData.spoilerText.length !== 0
Kirigami.Icon {
Layout.alignment: Qt.AlignVCenter
source: "data-warning"
}
QQC2.Label {
id: spoilerTextLabel
Layout.fillWidth: true
text: i18n("<b>Content Warning</b><br /> %1", modelData.spoilerText)
wrapMode: Text.Wrap
font: Config.defaultFont
}
QQC2.Button {
text: postContent.visible ? i18n("Show Less") : i18n("Show More")
onClicked: postContent.visible = !postContent.visible
}
}
PostContent {
id: postContent
content: modelData.content
expandedPost: false
secondary: false
visible: modelData.spoilerText.length === 0 || AccountManager.selectedAccount.preferences.extendSpoiler
shouldOpenInternalLinks: false
}
AttachmentGrid {
expandedPost: false
attachments: modelData.attachments
identity: modelData.authorIdentity
sensitive: true
secondary: false
inViewPort: true
visible: postContent.visible && modelData.attachments.length > 0
}
Item {
height: modelData.selected || Kirigami.Settings.tabletMode ? Kirigami.Units.mediumSpacing : Kirigami.Units.smallSpacing
}
RowLayout {
visible: true
QQC2.Label {
text: modelData.absoluteTime
elide: Text.ElideRight
color: Kirigami.Theme.disabledTextColor
}
}
}
}
}
}
}