2020-04-20 01:12:35 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
2020-07-12 12:52:14 +10:00
|
|
|
import "../Base/Buttons"
|
2020-04-20 01:12:35 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
HFlickableColumnPopup {
|
|
|
|
id: popup
|
2020-04-20 01:12:35 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
property string userId
|
|
|
|
property string roomId
|
|
|
|
property string targetUserId
|
|
|
|
property string targetDisplayName
|
|
|
|
property string operation // "disinvite", "kick" or "ban"
|
2020-04-20 07:30:16 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
readonly property string coloredTarget:
|
|
|
|
utils.coloredNameHtml(targetDisplayName, targetUserId)
|
2020-04-20 07:30:16 +10:00
|
|
|
|
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
function remove() {
|
|
|
|
py.callClientCoro(
|
|
|
|
userId,
|
|
|
|
operation === "ban" ? "room_ban" : "room_kick",
|
|
|
|
[roomId, targetUserId, reasonField.item.text || null],
|
|
|
|
)
|
2020-04-20 01:12:35 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
popup.close()
|
|
|
|
}
|
2020-04-20 01:12:35 +10:00
|
|
|
|
|
|
|
|
2020-07-12 12:52:14 +10:00
|
|
|
page.footer: AutoDirectionLayout {
|
2020-06-25 22:32:08 +10:00
|
|
|
ApplyButton {
|
|
|
|
text:
|
|
|
|
operation === "disinvite" ? qsTr("Disinvite") :
|
|
|
|
operation === "kick" ? qsTr("Kick") :
|
|
|
|
qsTr("Ban")
|
2020-04-20 07:30:16 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
icon.name: operation === "ban" ? "room-ban" : "room-kick"
|
2020-04-20 01:12:35 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
onClicked: remove()
|
|
|
|
}
|
|
|
|
|
|
|
|
CancelButton {
|
|
|
|
onClicked: popup.close()
|
|
|
|
}
|
|
|
|
}
|
2020-04-20 01:12:35 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
onOpened: reasonField.item.forceActiveFocus()
|
2020-06-26 00:27:24 +10:00
|
|
|
onKeyboardAccept: popup.remove()
|
2020-06-25 22:32:08 +10:00
|
|
|
|
|
|
|
SummaryLabel {
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
text:
|
|
|
|
operation === "disinvite" ?
|
|
|
|
qsTr("Disinvite %1 from the room?").arg(coloredTarget) :
|
|
|
|
|
|
|
|
operation === "kick" ?
|
|
|
|
qsTr("Kick %1 out of the room?").arg(coloredTarget) :
|
|
|
|
|
|
|
|
qsTr("Ban %1 from the room?").arg(coloredTarget)
|
|
|
|
}
|
2020-04-20 01:12:35 +10:00
|
|
|
|
2020-06-03 10:14:55 +10:00
|
|
|
HLabeledItem {
|
2020-04-20 01:12:35 +10:00
|
|
|
id: reasonField
|
|
|
|
label.text: qsTr("Optional reason:")
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-06-03 10:14:55 +10:00
|
|
|
|
|
|
|
HTextField {
|
|
|
|
width: parent.width
|
|
|
|
}
|
2020-04-20 01:12:35 +10:00
|
|
|
}
|
|
|
|
}
|