diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-08-10 00:20:44 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-08-10 00:20:44 +0200 |
commit | 376612e4eb39b1a5260745b901a3366d393511ee (patch) | |
tree | e86bed96026080c0cd7298a2a69f8daedb68e2db /resources/qml/components | |
parent | Change preview title for spaces (diff) | |
download | nheko-376612e4eb39b1a5260745b901a3366d393511ee.tar.xz |
Support editing space children
Diffstat (limited to 'resources/qml/components')
-rw-r--r-- | resources/qml/components/SpaceMenuLevel.qml | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/resources/qml/components/SpaceMenuLevel.qml b/resources/qml/components/SpaceMenuLevel.qml new file mode 100644 index 00000000..419b0f6e --- /dev/null +++ b/resources/qml/components/SpaceMenuLevel.qml @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2022 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick 2.15 +import Qt.labs.platform 1.1 as Platform +import im.nheko 1.0 + +Platform.Menu { + id: spacesMenu + + property string roomid + property Component childMenu + + property int position: modelData == undefined ? -2 : modelData.treeIndex + title: modelData != undefined ? modelData.name : qsTr("Add or remove from space") + property bool loadChildren: false + + onAboutToShow: loadChildren = true + //onAboutToHide: loadChildren = false + + Platform.MenuItemGroup { + id: modificationGroup + visible: position != -1 + } + + Platform.MenuItem { + text: qsTr("Official community for this room") + group: modificationGroup + checkable: true + checked: spacesMenu.position >= 0 && (modelData.childValid && modelData.parentValid && modelData.canonical) + enabled: spacesMenu.position >= 0 && (modelData.canEditChild && modelData.canEditParent) + onTriggered: if (checked) Communities.updateSpaceStatus(modelData.roomid, spacesMenu.roomid, true, true, true) + } + Platform.MenuItem { + text: qsTr("Affiliated community for this room") + group: modificationGroup + checkable: true + checked: spacesMenu.position >= 0 && (modelData.childValid && modelData.parentValid && !modelData.canonical) + enabled: spacesMenu.position >= 0 && (modelData.canEditChild && modelData.canEditParent) + onTriggered: if (checked) Communities.updateSpaceStatus(modelData.roomid, spacesMenu.roomid, true, true, false) + } + Platform.MenuItem { + text: qsTr("Listed only for community members") + group: modificationGroup + checkable: true + checked: spacesMenu.position >= 0 && (modelData.childValid && !modelData.parentValid) + enabled: spacesMenu.position >= 0 && ((modelData.canEditChild || modelData.childValid) && (!modelData.parentValid || modelData.canEditParent)) + onTriggered: if (checked) Communities.updateSpaceStatus(modelData.roomid, spacesMenu.roomid, false, true, false) + } + Platform.MenuItem { + text: qsTr("Listed only for room members") + group: modificationGroup + checkable: true + checked: spacesMenu.position >= 0 && (!modelData.childValid && modelData.parentValid) + enabled: spacesMenu.position >= 0 && ((modelData.canEditChild) && (modelData.parentValid || modelData.canEditParent)) + onTriggered: if (checked) Communities.updateSpaceStatus(modelData.roomid, spacesMenu.roomid, true, false, false) + } + Platform.MenuItem { + text: qsTr("Not related") + group: modificationGroup + checkable: true + checked: spacesMenu.position >= 0 && (!modelData.childValid && !modelData.parentValid) + enabled: spacesMenu.position >= 0 && ((modelData.canEditChild || !modelData.childValid) && (!modelData.parentValid || modelData.canEditParent)) + onTriggered: if (checked) Communities.updateSpaceStatus(modelData.roomid, spacesMenu.roomid, false, false, false) + } + + Platform.MenuSeparator { + text: qsTr("Subcommunities") + group: modificationGroup + visible: modificationGroup.visible && inst.model != undefined + } + + Instantiator { + id: inst + model: spacesMenu.loadChildren ? Communities.spaceChildrenListFromIndex(spacesMenu.roomid, spacesMenu.position) : undefined + onObjectAdded: (idx, o) => { + spacesMenu.insertMenu(idx + (spacesMenu.position != -1 ? 6 : 0), o) + } + //onObjectRemoved: spacesMenu.removeMenu(object) + + delegate: childMenu + } +} |