Add kick to room member context menu
This commit is contained in:
@@ -10,7 +10,7 @@ Banner {
|
||||
avatar.userId: chat.userId
|
||||
avatar.displayName: chat.userInfo.display_name
|
||||
avatar.mxc: chat.userInfo.avatar_url
|
||||
labelText: qsTr("You are not part of this room anymore")
|
||||
labelText: qsTr("You are no longer part of this room")
|
||||
|
||||
buttonModel: [
|
||||
{
|
||||
|
@@ -52,6 +52,23 @@ HTileDelegate {
|
||||
text: qsTr("Copy user ID")
|
||||
onTriggered: Clipboard.text = model.id
|
||||
}
|
||||
|
||||
HMenuItemPopupSpawner {
|
||||
icon.name: "room-kick"
|
||||
icon.color: theme.colors.negativeBackground
|
||||
text: model.invited ? qsTr("Disinvite") : qsTr("Kick")
|
||||
enabled: chat.roomInfo.can_kick
|
||||
|
||||
popup: "Popups/KickPopup.qml"
|
||||
popupParent: chat
|
||||
properties: ({
|
||||
userId: chat.userId,
|
||||
roomId: chat.roomId,
|
||||
targetUserId: model.id,
|
||||
targetDisplayName: model.display_name,
|
||||
targetIsInvited: model.invited,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
40
src/gui/Popups/KickPopup.qml
Normal file
40
src/gui/Popups/KickPopup.qml
Normal file
@@ -0,0 +1,40 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import "../Base"
|
||||
|
||||
BoxPopup {
|
||||
summary.textFormat: Text.StyledText
|
||||
summary.text:
|
||||
targetIsInvited ?
|
||||
qsTr("Withdraw %1's invitation?").arg(coloredTarget) :
|
||||
qsTr("Kick %1 out of the room?").arg(coloredTarget)
|
||||
|
||||
okText: qsTr("Kick")
|
||||
|
||||
onOpened: reasonField.field.forceActiveFocus()
|
||||
onOk: py.callClientCoro(
|
||||
userId,
|
||||
"room_kick",
|
||||
[roomId, targetUserId, reasonField.field.text || null],
|
||||
)
|
||||
|
||||
|
||||
property string userId
|
||||
property string roomId
|
||||
property string targetUserId
|
||||
property string targetDisplayName
|
||||
property bool targetIsInvited: false
|
||||
|
||||
readonly property string coloredTarget:
|
||||
utils.coloredNameHtml(targetDisplayName, targetUserId)
|
||||
|
||||
|
||||
HLabeledTextField {
|
||||
id: reasonField
|
||||
label.text: qsTr("Optional reason:")
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
@@ -160,9 +160,7 @@ QtObject {
|
||||
}
|
||||
|
||||
|
||||
function coloredNameHtml(
|
||||
name, userId, displayText=null, disambiguate=false, dim=false,
|
||||
) {
|
||||
function coloredNameHtml(name, userId, displayText=null, dim=false) {
|
||||
// substring: remove leading @
|
||||
return `<font color="${nameColor(name || userId.substring(1), dim)}">`+
|
||||
escapeHtml(displayText || name || userId) +
|
||||
@@ -210,7 +208,7 @@ QtObject {
|
||||
|
||||
if (ev.content.includes("%2"))
|
||||
content = content.arg(coloredNameHtml(
|
||||
ev.redacter_name, ev.redacter_id, "", false, true,
|
||||
ev.redacter_name, ev.redacter_id, "", true,
|
||||
))
|
||||
|
||||
return qsTr(
|
||||
|
Reference in New Issue
Block a user