diff --git a/ui/StatusQ/src/StatusQ/Components/StatusItemSelector.qml b/ui/StatusQ/src/StatusQ/Components/StatusItemSelector.qml index 638ddc1c28..bf68282143 100644 --- a/ui/StatusQ/src/StatusQ/Components/StatusItemSelector.qml +++ b/ui/StatusQ/src/StatusQ/Components/StatusItemSelector.qml @@ -117,6 +117,13 @@ Rectangle { */ property bool useLetterIdenticons: false + /*! + \qmlproperty bool StatusItemSelector::itemsClickable + This property determines if items in the selector are clickable (cursor + is changed on hover and itemClicked emitted when clicked) + */ + property bool itemsClickable: true + /*! \qmlsignal StatusItemSelector::itemClicked This signal is emitted when the item is clicked. @@ -217,7 +224,8 @@ Rectangle { MouseArea { anchors.fill: parent - cursorShape: Qt.PointingHandCursor + enabled: root.itemsClickable + cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: root.itemClicked(parent, model.index, mouse) } diff --git a/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml b/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml index ba4bcd9e95..8cf52f7bfa 100644 --- a/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml +++ b/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml @@ -76,6 +76,23 @@ StatusScrollView { readonly property int dropdownVerticalOffset: 1 property int permissionType: PermissionTypes.Type.None + + readonly property bool isCommunityPermission: + permissionType === PermissionTypes.Type.Admin || + permissionType === PermissionTypes.Type.Member + + onIsCommunityPermissionChanged: { + if (isCommunityPermission) { + inModelChannels.clear() + inSelector.wholeCommunitySelected = true + inSelector.itemsModel = inModelCommunity + } else { + inSelector.itemsModel = 0 + inSelector.wholeCommunitySelected = false + inSelector.itemsModel = inModelChannels + } + } + property bool triggerDirtyTool: false // Trick: Used to force the reevaluation of dirty when an item of the list is updated property QtObject dirtyValues: QtObject { @@ -417,6 +434,11 @@ StatusScrollView { disableAdminPermission: !root.store.isOwner onDone: { + if (d.permissionType === permissionType) { + permissionsDropdown.close() + return + } + d.permissionType = permissionType d.dirtyValues.permissionObject.key = permissionType d.dirtyValues.permissionObject.text = title @@ -454,8 +476,13 @@ StatusScrollView { StatusItemSelector { id: inSelector + readonly property bool editable: !d.isCommunityPermission + + addButton.visible: editable + itemsClickable: editable + Layout.fillWidth: true - icon: Style.svg("create-category") + icon: d.isCommunityPermission ? Style.svg("communities") : Style.svg("create-category") iconSize: 24 title: qsTr("In") defaultItemText: qsTr("Example: `#general` channel") @@ -464,6 +491,21 @@ StatusScrollView { property bool wholeCommunitySelected: false + function openInDropdown(parent, x, y) { + inDropdown.parent = parent + inDropdown.x = x + inDropdown.y = y + + const selectedChannels = [] + + if (!inSelector.wholeCommunitySelected) + for (let i = 0; i < inModelChannels.count; i++) + selectedChannels.push(inModelChannels.get(i).itemId) + + inDropdown.setSelectedChannels(selectedChannels) + inDropdown.open() + } + ListModel { id: inModelCommunity @@ -522,21 +564,6 @@ StatusScrollView { } } - function openInDropdown(parent, x, y) { - inDropdown.parent = parent - inDropdown.x = x - inDropdown.y = y - - const selectedChannels = [] - - if (!inSelector.wholeCommunitySelected) - for (let i = 0; i < inModelChannels.count; i++) - selectedChannels.push(inModelChannels.get(i).itemId) - - inDropdown.setSelectedChannels(selectedChannels) - inDropdown.open() - } - addButton.onClicked: { inDropdown.acceptMode = InDropdown.AcceptMode.Add openInDropdown(inSelector.addButton,