summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2023-10-26 09:57:47 +0200
committerGitHub <noreply@github.com>2023-10-26 09:57:47 +0200
commit1512810303a19073a0df32a38b76537660a03b3c (patch)
treea3ab747606a732e4d8f1614af21d9365b9786489 /resources
parentFix some qml warnings (diff)
parentAdd report message functionality (diff)
downloadnheko-1512810303a19073a0df32a38b76537660a03b3c.tar.xz
Merge pull request #1539 from Nheko-Reborn/issue1410
Add report message functionality
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/MessageView.qml16
-rw-r--r--resources/qml/dialogs/ReportMessage.qml85
2 files changed, 101 insertions, 0 deletions
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index df39f3d1..80ec87c2 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -415,6 +415,12 @@ Item {
                 }
             }
         }
+        Component {
+            id: reportDialog
+
+            ReportMessage {}
+        }
+
         Platform.MenuItem {
             enabled: visible
             text: qsTr("Go to &message")
@@ -522,6 +528,16 @@ Item {
             }
         }
         Platform.MenuItem {
+            text: qsTr("Report message")
+            enabled: visible
+            onTriggered: function () {
+                var dialog = reportDialog.createObject(timelineRoot, {"eventId": messageContextMenu.eventId});
+                dialog.show();
+                dialog.forceActiveFocus();
+                timelineRoot.destroyOnClose(dialog);
+            }
+        }
+        Platform.MenuItem {
             enabled: visible
             text: qsTr("&Save as")
             visible: messageContextMenuC.eventType == MtxEvent.ImageMessage || messageContextMenuC.eventType == MtxEvent.VideoMessage || messageContextMenuC.eventType == MtxEvent.AudioMessage || messageContextMenuC.eventType == MtxEvent.FileMessage || messageContextMenuC.eventType == MtxEvent.Sticker
diff --git a/resources/qml/dialogs/ReportMessage.qml b/resources/qml/dialogs/ReportMessage.qml
new file mode 100644
index 00000000..a0b6325c
--- /dev/null
+++ b/resources/qml/dialogs/ReportMessage.qml
@@ -0,0 +1,85 @@
+// SPDX-FileCopyrightText: Nheko Contributors
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import im.nheko
+
+ApplicationWindow {
+    required property string eventId
+
+    width: 400
+    height: gl.implicitHeight + 2 * Nheko.paddingMedium
+    title: qsTr("Report message")
+
+    GridLayout {
+        id: gl
+
+        columnSpacing: Nheko.paddingMedium
+        rowSpacing: Nheko.paddingMedium
+        columns: 2
+        anchors.fill: parent
+        anchors.margins: Nheko.paddingMedium
+
+        Label {
+            Layout.columnSpan: 2
+            Layout.fillWidth: true
+            wrapMode: Label.WordWrap
+            text: qsTr("This message you are reporting will be sent to your server administrator for review. Please note that not all server administrators review reported content. You should also ask a room moderator to remove the content if necessary.")
+        }
+
+        Label {
+            text: qsTr("Enter your reason for reporting:")
+        }
+
+        TextField {
+            id: reason
+
+            Layout.fillWidth: true
+        }
+
+        Label {
+            text: qsTr("How bad is the message?")
+        }
+
+        Slider {
+            id: score
+
+            from: 0
+            to: -100
+            stepSize: 25
+            snapMode: Slider.SnapAlways
+            Layout.fillWidth: true
+        }
+
+        Item {}
+
+        Label {
+            text: {
+                if (score.value === 0)
+                    return qsTr("Not bad")
+                else if (score.value === -25)
+                    return qsTr("Mild")
+                else if (score.value === -50)
+                    return qsTr("Bad")
+                else if (score.value === -75)
+                    return qsTr("Serious")
+                else if (score.value === -100)
+                    return qsTr("Extremely serious")
+            }
+        }
+
+        DialogButtonBox {
+            Layout.columnSpan: 2
+            Layout.alignment: Qt.AlignRight
+            standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
+            onAccepted: {
+                room.reportEvent(eventId, reason.text, score.value);
+                close();
+            }
+            onRejected: close()
+        }
+    }
+}