Allow adding a reason for deleting messages

BUG: 458911
This commit is contained in:
Tobias Fella
2022-11-18 00:56:12 +01:00
parent a695c31b2b
commit d70f77f622
7 changed files with 74 additions and 13 deletions

View File

@@ -60,10 +60,10 @@ MessageDelegateContextMenu {
text: i18n("Remove")
icon.name: "edit-delete-remove"
icon.color: "red"
onTriggered: {
currentRoom.redactEvent(eventId);
root.closeFullscreen()
}
onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/RemoveSheet.qml", {room: currentRoom, eventId: eventId}, {
title: i18nc("@title", "Remove Message"),
width: Kirigami.Units.gridUnit * 25
})
},
Kirigami.Action {
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")

View File

@@ -46,7 +46,10 @@ Loader {
text: i18n("Remove")
icon.name: "edit-delete-remove"
icon.color: "red"
onTriggered: currentRoom.redactEvent(eventId);
onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/RemoveSheet.qml", {room: currentRoom, eventId: eventId}, {
title: i18nc("@title", "Remove Message"),
width: Kirigami.Units.gridUnit * 25
})
},
Kirigami.Action {
text: i18n("Copy")

View File

@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: 2022 Tobias Fella <fella@posteo.de>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami
Kirigami.Page {
id: deleteSheet
property var room
property string eventId
property string userId: ""
title: userId.length > 0 ? i18n("Remove Messages") : i18n("Remove Message")
QQC2.TextArea {
id: reason
placeholderText: userId.length > 0 ? i18n("Reason for removing this user's recent messages") : i18n("Reason for removing this message")
anchors.fill: parent
wrapMode: TextEdit.Wrap
}
footer: QQC2.ToolBar {
QQC2.DialogButtonBox {
anchors.fill: parent
Item {
Layout.fillWidth: true
}
QQC2.Button {
text: i18nc("@action:button 'Remove' as in 'Remove this message'", "Remove")
icon.name: "delete"
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
onClicked: {
if (deleteSheet.userId.length > 0) {
deleteSheet.room.deleteMessagesByUser(deleteSheet.userId, reason.text)
} else {
deleteSheet.room.redactEvent(deleteSheet.eventId, reason.text);
}
deleteSheet.closeDialog()
}
}
QQC2.Button {
text: i18nc("@action", "Cancel")
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
onClicked: deleteSheet.closeDialog()
}
}
}
}