matrixion/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml

136 lines
4.2 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
2023-10-26 17:43:09 +03:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Window
import im.nheko
ApplicationWindow {
id: applyDialog
property PowerlevelEditingModels editingModel
2023-10-31 05:11:03 +03:00
property RoomSettings roomSettings
color: palette.window
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
2023-10-31 05:11:03 +03:00
height: 680
minimumHeight: 450
minimumWidth: 340
modality: Qt.NonModal
title: qsTr("Apply permission changes")
2023-10-31 05:11:03 +03:00
width: 450
footer: DialogButtonBox {
id: dbb
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
onAccepted: {
editingModel.spaces.commit();
applyDialog.close();
}
onRejected: applyDialog.close()
}
Shortcut {
sequence: StandardKey.Cancel
2023-10-31 05:11:03 +03:00
onActivated: roomSettingsDialog.close()
}
ColumnLayout {
anchors.fill: parent
2023-10-31 05:11:03 +03:00
anchors.margins: Nheko.paddingMedium
spacing: Nheko.paddingLarge
MatrixText {
2023-10-31 05:11:03 +03:00
Layout.bottomMargin: Nheko.paddingMedium
Layout.fillHeight: false
2023-10-31 05:11:03 +03:00
Layout.fillWidth: true
color: palette.text
2023-10-31 05:11:03 +03:00
font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 1.1)
text: qsTr("Which of the subcommunities and rooms should these permissions be applied to?")
}
GridLayout {
Layout.fillHeight: false
2023-10-31 05:11:03 +03:00
Layout.fillWidth: true
columns: 2
2023-10-31 05:11:03 +03:00
Label {
Layout.fillWidth: true
color: palette.text
text: qsTr("Apply permissions recursively")
}
ToggleButton {
Layout.alignment: Qt.AlignRight
checked: editingModel.spaces.applyToChildren
2023-10-31 05:11:03 +03:00
onCheckedChanged: editingModel.spaces.applyToChildren = checked
}
Label {
Layout.fillWidth: true
color: palette.text
text: qsTr("Overwrite exisiting modifications in rooms")
}
ToggleButton {
Layout.alignment: Qt.AlignRight
checked: editingModel.spaces.overwriteDiverged
2023-10-31 05:11:03 +03:00
onCheckedChanged: editingModel.spaces.overwriteDiverged = checked
}
}
ListView {
id: view
2023-10-31 05:11:03 +03:00
Layout.fillHeight: true
Layout.fillWidth: true
cacheBuffer: 50
clip: true
model: editingModel.spaces
spacing: 4
delegate: RowLayout {
anchors.left: parent.left
anchors.right: parent.right
ColumnLayout {
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
Text {
Layout.fillWidth: true
color: palette.text
elide: Text.ElideRight
2023-10-31 05:11:03 +03:00
text: model.displayName
textFormat: Text.PlainText
}
Text {
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette.buttonText
elide: Text.ElideRight
text: {
2023-10-31 05:11:03 +03:00
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");
}
textFormat: Text.PlainText
}
}
ToggleButton {
Layout.alignment: Qt.AlignRight
2023-10-31 05:11:03 +03:00
checked: model.applyPermissions
enabled: model.isEditable
2023-10-31 05:11:03 +03:00
onCheckedChanged: model.applyPermissions = checked
}
}
}
}
}