Warning, /network/neochat/src/qml/RoomSecurity.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2019-2020 Black Hat <bhat@encom.eu.org> 0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: GPL-3.0-only 0004 0005 import QtQuick 0006 import QtQuick.Controls as QQC2 0007 import QtQuick.Layouts 0008 0009 import org.kde.kirigami as Kirigami 0010 import org.kde.kirigamiaddons.formcard as FormCard 0011 0012 import org.kde.neochat 0013 0014 FormCard.FormCardPage { 0015 id: root 0016 0017 property NeoChatRoom room 0018 property string needUpgradeRoom: i18n("You need to upgrade this room to a newer version to enable this setting.") 0019 0020 title: i18n("Security") 0021 0022 FormCard.FormHeader { 0023 title: i18nc("@option:check", "Encryption") 0024 } 0025 FormCard.FormCard { 0026 FormCard.FormSwitchDelegate { 0027 id: enableEncryptionSwitch 0028 text: i18n("Enable encryption") 0029 description: i18nc("option:check", "Once enabled, encryption cannot be disabled.") 0030 enabled: room.canEncryptRoom 0031 checked: room.usesEncryption 0032 onToggled: if (checked) { 0033 let dialog = confirmEncryptionDialog.createObject(applicationWindow().overlay, { 0034 room: room 0035 }); 0036 dialog.open(); 0037 } 0038 } 0039 } 0040 0041 FormCard.FormHeader { 0042 title: i18nc("@option:check", "Access") 0043 } 0044 FormCard.FormCard { 0045 FormCard.FormRadioDelegate { 0046 text: i18nc("@option:check", "Private (invite only)") 0047 description: i18n("Only invited people can join.") 0048 checked: room.joinRule === "invite" 0049 enabled: room.canSendState("m.room.join_rules") 0050 onCheckedChanged: if (checked && room.joinRule != "invite") { 0051 root.room.joinRule = "invite"; 0052 } 0053 } 0054 FormCard.FormRadioDelegate { 0055 text: i18nc("@option:check", "Space members") 0056 description: i18n("Anyone in the selected spaces can find and join.") + (!["8", "9", "10"].includes(room.version) ? `\n${needUpgradeRoom}` : "") 0057 checked: room.joinRule === "restricted" 0058 enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version) 0059 onCheckedChanged: if (checked && room.joinRule != "restricted") { 0060 selectSpacesDialog.createObject(applicationWindow().overlay).open(); 0061 } 0062 0063 contentItem.children: QQC2.Button { 0064 visible: root.room.joinRule === "restricted" 0065 text: i18n("Select spaces") 0066 icon.name: "list-add" 0067 0068 onClicked: selectSpacesDialog.createObject(applicationWindow().overlay).open() 0069 0070 QQC2.ToolTip.text: text 0071 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0072 QQC2.ToolTip.visible: hovered 0073 } 0074 0075 Component { 0076 id: selectSpacesDialog 0077 SelectSpacesDialog { 0078 room: root.room 0079 } 0080 } 0081 } 0082 FormCard.FormRadioDelegate { 0083 text: i18nc("@option:check", "Knock") 0084 description: i18n("People not in the room need to request an invite to join the room.") + (!["7", "8", "9", "10"].includes(room.version) ? `\n${needUpgradeRoom}` : "") 0085 checked: room.joinRule === "knock" 0086 // https://spec.matrix.org/v1.4/rooms/#feature-matrix 0087 enabled: room.canSendState("m.room.join_rules") && ["7", "8", "9", "10"].includes(room.version) 0088 onCheckedChanged: if (checked && room.joinRule != "knock") { 0089 root.room.joinRule = "knock"; 0090 } 0091 } 0092 FormCard.FormRadioDelegate { 0093 text: i18nc("@option:check", "Public") 0094 description: i18nc("@option:check", "Anyone can find and join.") 0095 checked: room.joinRule === "public" 0096 enabled: room.canSendState("m.room.join_rules") 0097 onCheckedChanged: if (checked && root.room.joinRule != "public") { 0098 root.room.joinRule = "public"; 0099 } 0100 } 0101 } 0102 0103 FormCard.FormHeader { 0104 title: i18nc("@option:check", "Message history visibility") 0105 } 0106 FormCard.FormCard { 0107 FormCard.FormRadioDelegate { 0108 text: i18nc("@option:check", "Anyone") 0109 description: i18nc("@option:check", "Anyone, regardless of whether they have joined, can view history.") 0110 checked: room.historyVisibility === "world_readable" 0111 enabled: room.canSendState("m.room.history_visibility") 0112 onCheckedChanged: if (checked) { 0113 room.historyVisibility = "world_readable"; 0114 } 0115 } 0116 FormCard.FormRadioDelegate { 0117 text: i18nc("@option:check", "Members only") 0118 description: i18nc("@option:check", "All members can view the entire message history, even before they joined.") 0119 checked: room.historyVisibility === "shared" 0120 enabled: room.canSendState("m.room.history_visibility") 0121 onCheckedChanged: if (checked) { 0122 room.historyVisibility = "shared"; 0123 } 0124 } 0125 FormCard.FormRadioDelegate { 0126 text: i18nc("@option:check", "Members only (since invite)") 0127 description: i18nc("@option:check", "New members can view the message history from the point they were invited to the room.") 0128 checked: room.historyVisibility === "invited" 0129 enabled: room.canSendState("m.room.history_visibility") 0130 onCheckedChanged: if (checked) { 0131 room.historyVisibility = "invited"; 0132 } 0133 } 0134 FormCard.FormRadioDelegate { 0135 text: i18nc("@option:check", "Members only (since joining)") 0136 description: i18nc("@option:check", "New members can view the message history from the point they joined the room.") 0137 checked: room.historyVisibility === "joined" 0138 enabled: room.canSendState("m.room.history_visibility") 0139 onCheckedChanged: if (checked) { 0140 room.historyVisibility = "joined"; 0141 } 0142 } 0143 } 0144 0145 property Component confirmEncryptionDialog: Component { 0146 id: confirmEncryptionDialog 0147 0148 ConfirmEncryptionDialog { 0149 onClosed: { 0150 // At the point this is executed, the state in the room is not yet changed. 0151 // The value will be updated when room.onEncryption() emitted. 0152 // This is in case if user simply closed the dialog. 0153 enableEncryptionSwitch.checked = false; 0154 } 0155 } 0156 } 0157 0158 property Connections connections: Connections { 0159 target: room 0160 onEncryption: { 0161 enableEncryptionSwitch.checked = room.usesEncryption; 0162 } 0163 } 0164 }