Refactor dialogs for reporting, banning, and removing messages
This commit is contained in:
@@ -243,10 +243,7 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
|||||||
qml/MessageDelegateContextMenu.qml
|
qml/MessageDelegateContextMenu.qml
|
||||||
qml/FileDelegateContextMenu.qml
|
qml/FileDelegateContextMenu.qml
|
||||||
qml/MessageSourceSheet.qml
|
qml/MessageSourceSheet.qml
|
||||||
qml/ReportSheet.qml
|
|
||||||
qml/ConfirmEncryptionDialog.qml
|
qml/ConfirmEncryptionDialog.qml
|
||||||
qml/RemoveSheet.qml
|
|
||||||
qml/BanSheet.qml
|
|
||||||
qml/RoomSearchPage.qml
|
qml/RoomSearchPage.qml
|
||||||
qml/LocationChooser.qml
|
qml/LocationChooser.qml
|
||||||
qml/TimelineView.qml
|
qml/TimelineView.qml
|
||||||
@@ -291,6 +288,7 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
|||||||
qml/AskDirectChatConfirmation.qml
|
qml/AskDirectChatConfirmation.qml
|
||||||
qml/HoverLinkIndicator.qml
|
qml/HoverLinkIndicator.qml
|
||||||
qml/AvatarNotification.qml
|
qml/AvatarNotification.qml
|
||||||
|
qml/ReasonDialog.qml
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
QtCore
|
QtCore
|
||||||
QtQuick
|
QtQuick
|
||||||
|
|||||||
@@ -82,16 +82,23 @@ Loader {
|
|||||||
|
|
||||||
component RemoveMessageAction: Kirigami.Action {
|
component RemoveMessageAction: Kirigami.Action {
|
||||||
visible: author.isLocalMember || currentRoom.canSendState("redact")
|
visible: author.isLocalMember || currentRoom.canSendState("redact")
|
||||||
text: i18n("Remove")
|
text: i18nc("@action:button", "Remove")
|
||||||
icon.name: "edit-delete-remove"
|
icon.name: "edit-delete-remove"
|
||||||
icon.color: "red"
|
icon.color: "red"
|
||||||
onTriggered: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'RemoveSheet'), {
|
onTriggered: {
|
||||||
room: currentRoom,
|
let dialog = applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
|
||||||
eventId: eventId
|
title: i18nc("@title:dialog", "Remove Message"),
|
||||||
}, {
|
placeholder: i18nc("@info:placeholder", "Reason for removing this message"),
|
||||||
title: i18nc("@title", "Remove Message"),
|
actionText: i18nc("@action:button 'Remove' as in 'Remove this message'", "Remove"),
|
||||||
width: Kirigami.Units.gridUnit * 25
|
icon: "delete"
|
||||||
})
|
}, {
|
||||||
|
title: i18nc("@title:dialog", "Remove Message"),
|
||||||
|
width: Kirigami.Units.gridUnit * 25
|
||||||
|
});
|
||||||
|
dialog.accepted.connect(reason => {
|
||||||
|
currentRoom.redactEvent(root.eventId, reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component ReplyMessageAction: Kirigami.Action {
|
component ReplyMessageAction: Kirigami.Action {
|
||||||
@@ -108,13 +115,20 @@ Loader {
|
|||||||
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
||||||
icon.name: "dialog-warning-symbolic"
|
icon.name: "dialog-warning-symbolic"
|
||||||
visible: !author.isLocalMember
|
visible: !author.isLocalMember
|
||||||
onTriggered: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReportSheet'), {
|
onTriggered: {
|
||||||
room: currentRoom,
|
let dialog = applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
|
||||||
eventId: eventId
|
title: i18nc("@title:dialog", "Report Message"),
|
||||||
}, {
|
placeholder: i18nc("@info:placeholder", "Reason for reporting this message"),
|
||||||
title: i18nc("@title", "Report Message"),
|
icon: "dialog-warning-symbolic",
|
||||||
width: Kirigami.Units.gridUnit * 25
|
actionText: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
||||||
})
|
}, {
|
||||||
|
title: i18nc("@title", "Report Message"),
|
||||||
|
width: Kirigami.Units.gridUnit * 25
|
||||||
|
});
|
||||||
|
dialog.accepted.connect(reason => {
|
||||||
|
currentRoom.reportEvent(root.eventId, reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
|
|||||||
@@ -67,13 +67,20 @@ DelegateContextMenu {
|
|||||||
text: i18n("Remove")
|
text: i18n("Remove")
|
||||||
icon.name: "edit-delete-remove"
|
icon.name: "edit-delete-remove"
|
||||||
icon.color: "red"
|
icon.color: "red"
|
||||||
onTriggered: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'RemoveSheet'), {
|
onTriggered: {
|
||||||
room: currentRoom,
|
let dialog = applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
|
||||||
eventId: eventId
|
title: i18nc("@title:dialog", "Remove Message"),
|
||||||
}, {
|
placeholder: i18nc("@info:placeholder", "Reason for removing this message"),
|
||||||
title: i18nc("@title", "Remove Message"),
|
actionText: i18nc("@action:button 'Remove' as in 'Remove this message'", "Remove"),
|
||||||
width: Kirigami.Units.gridUnit * 25
|
icon: "delete"
|
||||||
})
|
}, {
|
||||||
|
title: i18nc("@title:dialog", "Remove Message"),
|
||||||
|
width: Kirigami.Units.gridUnit * 25
|
||||||
|
});
|
||||||
|
dialog.accepted.connect(reason => {
|
||||||
|
currentRoom.redactEvent(root.eventId, reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
DelegateContextMenu.ReportMessageAction {},
|
DelegateContextMenu.ReportMessageAction {},
|
||||||
DelegateContextMenu.ViewSourceAction {}
|
DelegateContextMenu.ViewSourceAction {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Tobias Fella <tobias.fella@kde.org>
|
// SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
@@ -12,10 +12,11 @@ import org.kde.neochat
|
|||||||
Kirigami.Page {
|
Kirigami.Page {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property NeoChatRoom room
|
required property string placeholder
|
||||||
property string userId
|
required property string actionText
|
||||||
|
required property string icon
|
||||||
|
|
||||||
title: i18n("Ban User")
|
signal accepted(reason: string)
|
||||||
|
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
@@ -24,7 +25,7 @@ Kirigami.Page {
|
|||||||
|
|
||||||
QQC2.TextArea {
|
QQC2.TextArea {
|
||||||
id: reason
|
id: reason
|
||||||
placeholderText: i18n("Reason for banning this user")
|
placeholderText: root.placeholder
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
wrapMode: TextEdit.Wrap
|
wrapMode: TextEdit.Wrap
|
||||||
|
|
||||||
@@ -40,11 +41,11 @@ Kirigami.Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
QQC2.Button {
|
QQC2.Button {
|
||||||
text: i18nc("@action:button 'Ban' as in 'Ban this user'", "Ban")
|
text: root.actionText
|
||||||
icon.name: "im-ban-user"
|
icon.name: root.icon
|
||||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
|
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.room.ban(root.userId, reason.text);
|
root.accepted(reason.text);
|
||||||
root.closeDialog();
|
root.closeDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Tobias Fella <tobias.fella@kde.org>
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Controls as QQC2
|
|
||||||
import QtQuick.Layouts
|
|
||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
|
||||||
|
|
||||||
import org.kde.neochat
|
|
||||||
|
|
||||||
Kirigami.Page {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property NeoChatRoom room
|
|
||||||
property string eventId
|
|
||||||
|
|
||||||
property string userId: ""
|
|
||||||
|
|
||||||
title: userId.length > 0 ? i18n("Remove Messages") : i18n("Remove Message")
|
|
||||||
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
topPadding: 0
|
|
||||||
bottomPadding: 0
|
|
||||||
|
|
||||||
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
|
|
||||||
background: Rectangle {
|
|
||||||
color: Kirigami.Theme.backgroundColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (root.userId.length > 0) {
|
|
||||||
root.room.deleteMessagesByUser(root.userId, reason.text);
|
|
||||||
} else {
|
|
||||||
root.room.redactEvent(root.eventId, reason.text);
|
|
||||||
}
|
|
||||||
root.closeDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QQC2.Button {
|
|
||||||
text: i18nc("@action", "Cancel")
|
|
||||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
|
|
||||||
onClicked: root.closeDialog()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Tobias Fella <tobias.fella@kde.org>
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Controls as QQC2
|
|
||||||
import QtQuick.Layouts
|
|
||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
|
||||||
|
|
||||||
import org.kde.neochat
|
|
||||||
|
|
||||||
Kirigami.Page {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property NeoChatRoom room
|
|
||||||
property string eventId
|
|
||||||
|
|
||||||
title: i18n("Report Message")
|
|
||||||
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
topPadding: 0
|
|
||||||
bottomPadding: 0
|
|
||||||
|
|
||||||
QQC2.TextArea {
|
|
||||||
id: reason
|
|
||||||
placeholderText: i18n("Reason for reporting this message")
|
|
||||||
anchors.fill: parent
|
|
||||||
wrapMode: TextEdit.Wrap
|
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
color: Kirigami.Theme.backgroundColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
footer: QQC2.ToolBar {
|
|
||||||
QQC2.DialogButtonBox {
|
|
||||||
anchors.fill: parent
|
|
||||||
Item {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
QQC2.Button {
|
|
||||||
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
|
||||||
icon.name: "dialog-warning-symbolic"
|
|
||||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
|
|
||||||
onClicked: {
|
|
||||||
root.room.reportEvent(eventId, reason.text);
|
|
||||||
root.closeDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QQC2.Button {
|
|
||||||
text: i18nc("@action", "Cancel")
|
|
||||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
|
|
||||||
onClicked: root.closeDialog()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -150,13 +150,18 @@ Kirigami.Dialog {
|
|||||||
icon.name: "im-ban-user"
|
icon.name: "im-ban-user"
|
||||||
icon.color: Kirigami.Theme.negativeTextColor
|
icon.color: Kirigami.Theme.negativeTextColor
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
(root.QQC2.ApplicationWindow.window as Kirigami.ApplicationWindow).pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'BanSheet'), {
|
let dialog = (root.QQC2.ApplicationWindow.window as Kirigami.ApplicationWindow).pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
|
||||||
room: root.room,
|
title: i18nc("@title:dialog", "Ban User"),
|
||||||
userId: root.user.id
|
placeholder: i18nc("@info:placeholder", "Reason for banning this user"),
|
||||||
|
actionText: i18nc("@action:button 'Ban' as in 'Ban this user'", "Ban"),
|
||||||
|
icon: "im-ban-user"
|
||||||
}, {
|
}, {
|
||||||
title: i18nc("@title", "Ban User"),
|
title: i18nc("@title:dialog", "Ban User"),
|
||||||
width: Kirigami.Units.gridUnit * 25
|
width: Kirigami.Units.gridUnit * 25
|
||||||
});
|
});
|
||||||
|
dialog.accepted.connect(reason => {
|
||||||
|
root.room.ban(root.user.id, reason);
|
||||||
|
});
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,17 +209,22 @@ Kirigami.Dialog {
|
|||||||
visible: root.room && (root.user.id === root.connection.localUserId || room.canSendState("redact"))
|
visible: root.room && (root.user.id === root.connection.localUserId || room.canSendState("redact"))
|
||||||
|
|
||||||
action: Kirigami.Action {
|
action: Kirigami.Action {
|
||||||
text: i18n("Remove recent messages by this user")
|
text: i18nc("@action:button", "Remove recent messages by this user")
|
||||||
icon.name: "delete"
|
icon.name: "delete"
|
||||||
icon.color: Kirigami.Theme.negativeTextColor
|
icon.color: Kirigami.Theme.negativeTextColor
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'RemoveSheet'), {
|
let dialog = applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
|
||||||
room: root.room,
|
title: i18nc("@title:dialog", "Remove Messages"),
|
||||||
userId: root.user.id
|
placeholder: i18nc("@info:placeholder", "Reason for removing this user's recent messages"),
|
||||||
|
actionText: i18nc("@action:button 'Remove' as in 'Remove these messages'", "Remove"),
|
||||||
|
icon: "delete"
|
||||||
}, {
|
}, {
|
||||||
title: i18nc("@title", "Remove Messages"),
|
title: i18nc("@title", "Remove Messages"),
|
||||||
width: Kirigami.Units.gridUnit * 25
|
width: Kirigami.Units.gridUnit * 25
|
||||||
});
|
});
|
||||||
|
dialog.accepted.connect(reason => {
|
||||||
|
root.room.deleteMessagesByUser(root.user.id, reason);
|
||||||
|
});
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user