Restricted Room Security
Create the required ux to allow the restricted room security setting to be re-enabled BUG: 471307
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
|
||||
import org.kde.neochat
|
||||
@@ -42,18 +45,37 @@ FormCard.FormCardPage {
|
||||
description: i18n("Only invited people can join.")
|
||||
checked: room.joinRule === "invite"
|
||||
enabled: room.canSendState("m.room.join_rules")
|
||||
onCheckedChanged: if (checked) {
|
||||
room.joinRule = "invite";
|
||||
onCheckedChanged: if (checked && room.joinRule != "invite") {
|
||||
root.room.joinRule = "invite";
|
||||
}
|
||||
}
|
||||
FormCard.FormRadioDelegate {
|
||||
text: i18nc("@option:check", "Space members")
|
||||
description: i18n("Anyone in a space can find and join.") +
|
||||
description: i18n("Anyone in the selected spaces can find and join.") +
|
||||
(!["8", "9", "10"].includes(room.version) ? `\n${needUpgradeRoom}` : "")
|
||||
checked: room.joinRule === "restricted"
|
||||
enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version) && false
|
||||
onCheckedChanged: if (checked) {
|
||||
room.joinRule = "restricted";
|
||||
enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version)
|
||||
onCheckedChanged: if (checked && room.joinRule != "restricted") {
|
||||
selectSpacesDialog.createObject(applicationWindow().overlay).open();
|
||||
}
|
||||
|
||||
contentItem.children: QQC2.Button {
|
||||
visible: root.room.joinRule === "restricted"
|
||||
text: i18n("Select spaces")
|
||||
icon.name: "list-add"
|
||||
|
||||
onClicked: selectSpacesDialog.createObject(applicationWindow().overlay).open();
|
||||
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
QQC2.ToolTip.visible: hovered
|
||||
}
|
||||
|
||||
Component {
|
||||
id: selectSpacesDialog
|
||||
SelectSpacesDialog {
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
}
|
||||
FormCard.FormRadioDelegate {
|
||||
@@ -63,8 +85,8 @@ FormCard.FormCardPage {
|
||||
checked: room.joinRule === "knock"
|
||||
// https://spec.matrix.org/v1.4/rooms/#feature-matrix
|
||||
enabled: room.canSendState("m.room.join_rules") && ["7", "8", "9", "10"].includes(room.version)
|
||||
onCheckedChanged: if (checked) {
|
||||
room.joinRule = "knock";
|
||||
onCheckedChanged: if (checked && room.joinRule != "knock") {
|
||||
root.room.joinRule = "knock";
|
||||
}
|
||||
}
|
||||
FormCard.FormRadioDelegate {
|
||||
@@ -72,8 +94,8 @@ FormCard.FormCardPage {
|
||||
description: i18nc("@option:check", "Anyone can find and join.")
|
||||
checked: room.joinRule === "public"
|
||||
enabled: room.canSendState("m.room.join_rules")
|
||||
onCheckedChanged: if (checked) {
|
||||
room.joinRule = "public";
|
||||
onCheckedChanged: if (checked && root.room.joinRule != "public") {
|
||||
root.room.joinRule = "public";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
77
src/qml/SelectSpacesDialog.qml
Normal file
77
src/qml/SelectSpacesDialog.qml
Normal file
@@ -0,0 +1,77 @@
|
||||
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kirigamiaddons.labs.components as Components
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
/**
|
||||
* @brief The current room this dialog is opened for.
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
/**
|
||||
* @brief The current list of space IDs that members of can join this room.
|
||||
*/
|
||||
property list<string> restrictedIds: room.restrictedIds
|
||||
|
||||
parent: applicationWindow().overlay
|
||||
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24)
|
||||
title: i18nc("@title", "Select Spaces")
|
||||
|
||||
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
|
||||
onAccepted: {
|
||||
let ids = [];
|
||||
for (var i in spaceGroup.buttons) {
|
||||
if (spaceGroup.buttons[i].checked) {
|
||||
ids.push(spaceGroup.buttons[i].modelData.id);
|
||||
}
|
||||
}
|
||||
root.room.setJoinRule("restricted", ids)
|
||||
console.warn(ids)
|
||||
}
|
||||
|
||||
QQC2.ButtonGroup {
|
||||
id: spaceGroup
|
||||
exclusive: false
|
||||
}
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 0
|
||||
Repeater {
|
||||
model: root.room.parentObjects(true)
|
||||
|
||||
delegate: FormCard.FormCheckDelegate {
|
||||
required property var modelData
|
||||
|
||||
text: modelData.displayName
|
||||
description: modelData.canonicalAlias
|
||||
checked: root.restrictedIds.includes(modelData.id)
|
||||
QQC2.ButtonGroup.group: spaceGroup
|
||||
|
||||
leading: Components.Avatar {
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||
|
||||
source: modelData.avatarUrl.toString().length > 0 ? connection.makeMediaUrl(modelData.avatarUrl) : ""
|
||||
name: modelData.displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user