Debian Codegraph @

resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import ".."
6 import QtQuick
7 import QtQuick.Controls
8 import QtQuick.Layouts
9 import QtQuick.Window
10 import im.nheko
11
12 ApplicationWindow {
13 id: applyDialog
14
15 property RoomSettings roomSettings
16 property PowerlevelEditingModels editingModel
17
18 minimumWidth: 340
19 minimumHeight: 450
20 width: 450
21 height: 680
22 color: palette.window
23 modality: Qt.NonModal
24 flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
25 title: qsTr("Apply permission changes")
26
27 Shortcut {
28 sequence: StandardKey.Cancel
29 onActivated: roomSettingsDialog.close()
30 }
31
32 ColumnLayout {
33 anchors.margins: Nheko.paddingMedium
34 anchors.fill: parent
35 spacing: Nheko.paddingLarge
36
37
38 MatrixText {
39 text: qsTr("Which of the subcommunities and rooms should these permissions be applied to?")
40 font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 1.1)
41 Layout.fillWidth: true
42 Layout.fillHeight: false
43 color: palette.text
44 Layout.bottomMargin: Nheko.paddingMedium
45 }
46
47 GridLayout {
48 Layout.fillWidth: true
49 Layout.fillHeight: false
50 columns: 2
51
52 Label {
53 text: qsTr("Apply permissions recursively")
54 Layout.fillWidth: true
55 color: palette.text
56 }
57
58 ToggleButton {
59 checked: editingModel.spaces.applyToChildren
60 Layout.alignment: Qt.AlignRight
61 onCheckedChanged: editingModel.spaces.applyToChildren = checked
62 }
63
64 Label {
65 text: qsTr("Overwrite exisiting modifications in rooms")
66 Layout.fillWidth: true
67 color: palette.text
68 }
69
70 ToggleButton {
71 checked: editingModel.spaces.overwriteDiverged
72 Layout.alignment: Qt.AlignRight
73 onCheckedChanged: editingModel.spaces.overwriteDiverged = checked
74 }
75 }
76
77 ListView {
78 Layout.fillWidth: true
79 Layout.fillHeight: true
80
81 id: view
82
83 clip: true
84
85 model: editingModel.spaces
86 spacing: 4
87 cacheBuffer: 50
88
89 delegate: RowLayout {
90 anchors.left: parent.left
91 anchors.right: parent.right
92
93 ColumnLayout {
94 Layout.fillWidth: true
95 Text {
96 Layout.fillWidth: true
97 text: model.displayName
98 color: palette.text
99 textFormat: Text.PlainText
100 elide: Text.ElideRight
101 }
102
103 Text {
104 Layout.fillWidth: true
105 text: {
106 if (!model.isEditable) return qsTr("No permissions to apply the new permissions here");
107 if (model.isAlreadyUpToDate) return qsTr("No changes needed");
108 if (model.isDifferentFromBase) return qsTr("Existing modifications to the permissions in this room will be overwritten");
109 return qsTr("Permissions synchronized with community")
110 }
111 elide: Text.ElideRight
112 color: palette.buttonText
113 textFormat: Text.PlainText
114 }
115 }
116
117 ToggleButton {
118 checked: model.applyPermissions
119 Layout.alignment: Qt.AlignRight
120 onCheckedChanged: model.applyPermissions = checked
121 enabled: model.isEditable
122 }
123 }
124 }
125
126
127 }
128
129 footer: DialogButtonBox {
130 id: dbb
131
132 standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
133 onAccepted: {
134 editingModel.spaces.commit();
135 applyDialog.close();
136 }
137 onRejected: applyDialog.close()
138 }
139
140 }