From 9982c3df521fb02ea0f5a677ea44cd836c765bae Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Tue, 15 Jun 2021 12:17:51 +0200 Subject: [PATCH] feat(StatusChatListCategory): introduce flag to show/hide buttons This commit introduces a `showActionButtons` flag that defaults to `false` and can be used to render the action buttons provided in the chat list category. This is useful for cases where only admin users should have the right to create channels inside categories or mutate a category's state. Settings `showActionButtons: true` will then render the buttons. Closes #150 --- sandbox/DemoApp.qml | 3 ++- sandbox/ListItems.qml | 7 +++++++ src/StatusQ/Components/StatusChatListCategory.qml | 1 + src/StatusQ/Components/StatusChatListCategoryItem.qml | 9 +++++++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sandbox/DemoApp.qml b/sandbox/DemoApp.qml index f0488d21..ed67c219 100644 --- a/sandbox/DemoApp.qml +++ b/sandbox/DemoApp.qml @@ -279,7 +279,7 @@ Rectangle { StatusChatListCategory { name: "Public" - + showActionButtons: true chatList.chatListItems.model: demoCommunityChatListItems chatList.selectedChatId: "0" chatList.onChatItemSelected: chatList.selectedChatId = id @@ -289,6 +289,7 @@ Rectangle { StatusChatListCategory { name: "Development" + showActionButtons: true chatList.chatListItems.model: demoCommunityChatListItems chatList.onChatItemSelected: chatList.selectedChatId = id popupMenu: categoryPopupCmp diff --git a/sandbox/ListItems.qml b/sandbox/ListItems.qml index 6ba94946..fb35851e 100644 --- a/sandbox/ListItems.qml +++ b/sandbox/ListItems.qml @@ -40,11 +40,18 @@ GridLayout { StatusChatListCategoryItem { title: "Chat list category" opened: false + showActionButtons: true } StatusChatListCategoryItem { title: "Chat list category (opened)" opened: true + showActionButtons: true + } + + StatusChatListCategoryItem { + title: "Chat list category (no buttons)" + opened: true } StatusChatListItem { diff --git a/src/StatusQ/Components/StatusChatListCategory.qml b/src/StatusQ/Components/StatusChatListCategory.qml index d31d42fb..4450432a 100644 --- a/src/StatusQ/Components/StatusChatListCategory.qml +++ b/src/StatusQ/Components/StatusChatListCategory.qml @@ -12,6 +12,7 @@ Column { property string name: "" property bool opened: true + property alias showActionButtons: statusChatListCategoryItem.showActionButtons property alias addButton: statusChatListCategoryItem.addButton property alias menuButton: statusChatListCategoryItem.menuButton property alias toggleButton: statusChatListCategoryItem.toggleButton diff --git a/src/StatusQ/Components/StatusChatListCategoryItem.qml b/src/StatusQ/Components/StatusChatListCategoryItem.qml index e410e7dc..62d5b460 100644 --- a/src/StatusQ/Components/StatusChatListCategoryItem.qml +++ b/src/StatusQ/Components/StatusChatListCategoryItem.qml @@ -16,6 +16,7 @@ StatusListItem { property bool opened: true property bool highlighted: false + property bool showActionButtons: false property alias addButton: addButton property alias menuButton: menuButton property alias toggleButton: toggleButton @@ -39,7 +40,9 @@ StatusListItem { id: addButton icon.name: "add" icon.width: 20 - visible: statusChatListCategoryItem.sensor.containsMouse || statusChatListCategoryItem.highlighted + visible: statusChatListCategoryItem.showActionButtons && + (statusChatListCategoryItem.highlighted || + statusChatListCategoryItem.sensor.containsMouse) onClicked: statusChatListCategoryItem.addButtonClicked(mouse) tooltip.text: "Add channel inside category" }, @@ -47,7 +50,9 @@ StatusListItem { id: menuButton icon.name: "more" icon.width: 21 - visible: statusChatListCategoryItem.sensor.containsMouse || statusChatListCategoryItem.highlighted + visible: statusChatListCategoryItem.showActionButtons && + (statusChatListCategoryItem.highlighted || + statusChatListCategoryItem.sensor.containsMouse) onClicked: statusChatListCategoryItem.menuButtonClicked(mouse) tooltip.text: "More" },