summaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-09-28 02:09:04 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-09-28 02:09:04 +0200
commit051c25d5b87c2351df46173f19b907cea436fa3b (patch)
tree7e68ff95c1a678cc614f908e67cef5fe0c6a624c /resources
parent0752f9477e1beb6cfbcec608b60c6418cd3dccf4 (diff)
Allow editing permissions in spaces recursively
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/Root.qml16
-rw-r--r--resources/qml/dialogs/PowerLevelEditor.qml11
-rw-r--r--resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml148
-rw-r--r--resources/res.qrc1
4 files changed, 174 insertions, 2 deletions
diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml
index 063284c1..dd1dfe1e 100644
--- a/resources/qml/Root.qml
+++ b/resources/qml/Root.qml
@@ -79,6 +79,22 @@ Pane {
}
Component {
+ id: plApplyPrompt
+
+ PowerLevelSpacesApplyDialog {
+ }
+ }
+
+ function showSpacePLApplyPrompt(settings, editingModel) {
+ var dialog = plApplyPrompt.createObject(timelineRoot, {
+ "roomSettings": settings,
+ "editingModel": editingModel
+ });
+ dialog.show();
+ destroyOnClose(dialog);
+ }
+
+ Component {
id: plEditor
PowerLevelEditor {
diff --git a/resources/qml/dialogs/PowerLevelEditor.qml b/resources/qml/dialogs/PowerLevelEditor.qml
index bfb337ff..4c23d9af 100644
--- a/resources/qml/dialogs/PowerLevelEditor.qml
+++ b/resources/qml/dialogs/PowerLevelEditor.qml
@@ -397,8 +397,15 @@ ApplicationWindow {
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
onAccepted: {
- editingModel.commit();
- plEditorW.close();
+ if (editingModel.isSpace) {
+ // TODO(Nico): Replace with showing a list of spaces to apply to
+ editingModel.updateSpacesModel();
+ plEditorW.close();
+ timelineRoot.showSpacePLApplyPrompt(roomSettings, editingModel)
+ } else {
+ editingModel.commit();
+ plEditorW.close();
+ }
}
onRejected: plEditorW.close();
}
diff --git a/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml b/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml
new file mode 100644
index 00000000..83af00f7
--- /dev/null
+++ b/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml
@@ -0,0 +1,148 @@
+// SPDX-FileCopyrightText: 2022 Nheko Contributors
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+import ".."
+import "../ui"
+import Qt.labs.platform 1.1 as Platform
+import QtQuick 2.15
+import QtQuick.Controls 2.3
+import QtQuick.Layouts 1.2
+import QtQuick.Window 2.13
+import im.nheko 1.0
+
+ApplicationWindow {
+ id: applyDialog
+
+ property RoomSettings roomSettings
+ property PowerlevelEditingModels editingModel
+
+ minimumWidth: 340
+ minimumHeight: 450
+ width: 450
+ height: 680
+ palette: Nheko.colors
+ color: Nheko.colors.window
+ modality: Qt.NonModal
+ flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
+ title: qsTr("Apply permission changes")
+
+ Shortcut {
+ sequence: StandardKey.Cancel
+ onActivated: roomSettingsDialog.close()
+ }
+
+ ColumnLayout {
+ anchors.margins: Nheko.paddingMedium
+ anchors.fill: parent
+ spacing: Nheko.paddingLarge
+
+
+ MatrixText {
+ text: qsTr("Which of the subcommunities and rooms should these permissions be applied to?")
+ font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 1.1)
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ color: Nheko.colors.text
+ Layout.bottomMargin: Nheko.paddingMedium
+ }
+
+ GridLayout {
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ columns: 2
+
+ Label {
+ text: qsTr("Apply permissions recursively")
+ Layout.fillWidth: true
+ color: Nheko.colors.text
+ }
+
+ ToggleButton {
+ checked: editingModel.spaces.applyToChildren
+ Layout.alignment: Qt.AlignRight
+ onCheckedChanged: editingModel.spaces.applyToChildren = checked
+ }
+
+ Label {
+ text: qsTr("Overwrite exisiting modifications in rooms")
+ Layout.fillWidth: true
+ color: Nheko.colors.text
+ }
+
+ ToggleButton {
+ checked: editingModel.spaces.overwriteDiverged
+ Layout.alignment: Qt.AlignRight
+ onCheckedChanged: editingModel.spaces.overwriteDiverged = checked
+ }
+ }
+
+ ListView {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ id: view
+
+ clip: true
+
+ ScrollHelper {
+ flickable: parent
+ anchors.fill: parent
+ }
+
+ model: editingModel.spaces
+ spacing: 4
+ cacheBuffer: 50
+
+ delegate: RowLayout {
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ ColumnLayout {
+ Layout.fillWidth: true
+ Text {
+ Layout.fillWidth: true
+ text: model.displayName
+ color: Nheko.colors.text
+ textFormat: Text.PlainText
+ elide: Text.ElideRight
+ }
+
+ Text {
+ Layout.fillWidth: true
+ text: {
+ if (!model.isEditable) return qsTr("No permissions to apply the new permissions here");
+ if (model.isAlreadyUpToDate) return qsTr("No changes needed");
+ if (model.isDifferentFromBase) return qsTr("Existing modifications to the permissions in this room will be overwritten");
+ return qsTr("Permissions synchronized with community")
+ }
+ elide: Text.ElideRight
+ color: Nheko.colors.buttonText
+ textFormat: Text.PlainText
+ }
+ }
+
+ ToggleButton {
+ checked: model.applyPermissions
+ Layout.alignment: Qt.AlignRight
+ onCheckedChanged: model.applyPermissions = checked
+ enabled: model.isEditable
+ }
+ }
+ }
+
+
+ }
+
+ footer: DialogButtonBox {
+ id: dbb
+
+ standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
+ onAccepted: {
+ editingModel.spaces.commit();
+ applyDialog.close();
+ }
+ onRejected: applyDialog.close()
+ }
+
+}
diff --git a/resources/res.qrc b/resources/res.qrc
index 27d9c081..7affe702 100644
--- a/resources/res.qrc
+++ b/resources/res.qrc
@@ -162,6 +162,7 @@
<file>qml/dialogs/LogoutDialog.qml</file>
<file>qml/dialogs/PhoneNumberInputDialog.qml</file>
<file>qml/dialogs/PowerLevelEditor.qml</file>
+ <file>qml/dialogs/PowerLevelSpacesApplyDialog.qml</file>
<file>qml/dialogs/RawMessageDialog.qml</file>
<file>qml/dialogs/ReadReceipts.qml</file>
<file>qml/dialogs/RoomDirectory.qml</file>