2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2022-08-10 01:20:44 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2024-10-09 00:04:41 +03:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import im.nheko
|
2022-08-10 01:20:44 +03:00
|
|
|
|
2024-10-09 00:04:41 +03:00
|
|
|
Menu {
|
2022-08-10 01:20:44 +03:00
|
|
|
id: spacesMenu
|
|
|
|
|
|
|
|
property string roomid
|
|
|
|
property Component childMenu
|
|
|
|
|
|
|
|
property int position: modelData == undefined ? -2 : modelData.treeIndex
|
2022-10-01 16:20:38 +03:00
|
|
|
title: modelData != undefined ? modelData.name : qsTr("Add or remove from community")
|
2022-08-10 01:20:44 +03:00
|
|
|
property bool loadChildren: false
|
|
|
|
|
|
|
|
onAboutToShow: loadChildren = true
|
|
|
|
//onAboutToHide: loadChildren = false
|
|
|
|
|
2024-10-09 00:04:41 +03:00
|
|
|
ButtonGroup {
|
2022-08-10 01:20:44 +03:00
|
|
|
id: modificationGroup
|
2024-10-09 00:04:41 +03:00
|
|
|
//visible: position != -1
|
2022-08-10 01:20:44 +03:00
|
|
|
}
|
|
|
|
|
2024-10-09 00:04:41 +03:00
|
|
|
MenuItem {
|
2022-08-10 01:20:44 +03:00
|
|
|
text: qsTr("Official community for this room")
|
2024-10-09 00:04:41 +03:00
|
|
|
ButtonGroup.group: modificationGroup
|
|
|
|
visible: position != -1
|
2022-08-10 01:20:44 +03:00
|
|
|
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)
|
|
|
|
}
|
2024-10-09 00:04:41 +03:00
|
|
|
MenuItem {
|
2022-08-10 01:20:44 +03:00
|
|
|
text: qsTr("Affiliated community for this room")
|
2024-10-09 00:04:41 +03:00
|
|
|
ButtonGroup.group: modificationGroup
|
|
|
|
visible: position != -1
|
2022-08-10 01:20:44 +03:00
|
|
|
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)
|
|
|
|
}
|
2024-10-09 00:04:41 +03:00
|
|
|
MenuItem {
|
2022-08-10 01:20:44 +03:00
|
|
|
text: qsTr("Listed only for community members")
|
2024-10-09 00:04:41 +03:00
|
|
|
ButtonGroup.group: modificationGroup
|
|
|
|
visible: position != -1
|
2022-08-10 01:20:44 +03:00
|
|
|
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)
|
|
|
|
}
|
2024-10-09 00:04:41 +03:00
|
|
|
MenuItem {
|
2022-08-10 01:20:44 +03:00
|
|
|
text: qsTr("Listed only for room members")
|
2024-10-09 00:04:41 +03:00
|
|
|
ButtonGroup.group: modificationGroup
|
|
|
|
visible: position != -1
|
2022-08-10 01:20:44 +03:00
|
|
|
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)
|
|
|
|
}
|
2024-10-09 00:04:41 +03:00
|
|
|
MenuItem {
|
2022-08-10 01:20:44 +03:00
|
|
|
text: qsTr("Not related")
|
2024-10-09 00:04:41 +03:00
|
|
|
ButtonGroup.group: modificationGroup
|
|
|
|
visible: position != -1
|
2022-08-10 01:20:44 +03:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2024-10-09 00:04:41 +03:00
|
|
|
MenuSeparator {
|
|
|
|
//text: qsTr("Subcommunities")
|
|
|
|
ButtonGroup.group: modificationGroup
|
2024-10-09 00:35:13 +03:00
|
|
|
visible: position != -1 && inst.model != undefined
|
2022-08-10 01:20:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2024-11-17 21:41:21 +03:00
|
|
|
onObjectRemoved: (index, object) => tagsMenu.removeItem(object)
|
2022-08-10 01:20:44 +03:00
|
|
|
|
|
|
|
delegate: childMenu
|
|
|
|
}
|
|
|
|
}
|