From 562373fdfc46c72dfb3e34673f856621623c6214 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Fri, 25 Jun 2021 11:13:54 +0200 Subject: [PATCH] fix(communities): Right click inside the community pane does not open context menu Fixes: #2547 --- ui/app/AppLayouts/Chat/CommunityColumn.qml | 129 +++++++++++------- .../BackUpCommuntyBanner.qml | 10 ++ .../Chat/CommunityComponents/CategoryList.qml | 10 ++ .../CommunityWelcomeBanner.qml | 10 ++ 4 files changed, 107 insertions(+), 52 deletions(-) diff --git a/ui/app/AppLayouts/Chat/CommunityColumn.qml b/ui/app/AppLayouts/Chat/CommunityColumn.qml index b604845d5a..6464003f0c 100644 --- a/ui/app/AppLayouts/Chat/CommunityColumn.qml +++ b/ui/app/AppLayouts/Chat/CommunityColumn.qml @@ -41,6 +41,56 @@ Rectangle { TransferOwnershipPopup {} } + CommunityProfilePopup { + id: communityProfilePopup + communityId: chatsModel.communities.activeCommunity.id + name: chatsModel.communities.activeCommunity.name + description: chatsModel.communities.activeCommunity.description + access: chatsModel.communities.activeCommunity.access + nbMembers: chatsModel.communities.activeCommunity.nbMembers + isAdmin: chatsModel.communities.activeCommunity.admin + source: chatsModel.communities.activeCommunity.thumbnailImage + communityColor: chatsModel.communities.activeCommunity.communityColor + } + + PopupMenu { + id: optionsMenu + + Action { + enabled: chatsModel.communities.activeCommunity.admin + //% "Create channel" + text: qsTrId("create-channel") + icon.source: "../../img/hash.svg" + icon.width: 20 + icon.height: 20 + onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id}) + } + + Action { + enabled: chatsModel.communities.activeCommunity.admin + text: qsTr("Create category") + icon.source: "../../img/create-category.svg" + icon.width: 20 + icon.height: 20 + onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id}) + } + + Separator {} + + Action { + text: qsTr("Invite People") + enabled: chatsModel.communities.activeCommunity.canManageUsers + icon.source: "../../img/export.svg" + icon.width: 20 + icon.height: 20 + onTriggered: openPopup(inviteFriendsToCommunityPopup, {communityId: chatsModel.communities.activeCommunity.id}) + } + + onAboutToHide: { + optionsBtn.state = "default" + } + } + Item { id: communityHeader width: parent.width @@ -74,48 +124,13 @@ Rectangle { onClicked: { optionsBtn.state = "pressed" + let x = optionsBtn.iconX + optionsBtn.icon.width / 2 - optionsMenu.width / 2 - optionsMenu.popup(x, optionsBtn.icon.height + 14) - } + let y = optionsBtn.height + 4 - PopupMenu { - id: optionsMenu - x: optionsBtn.x + optionsBtn.width / 2 - optionsMenu.width / 2 - y: optionsBtn.height + let point = optionsBtn.mapToItem(root, x, y) - Action { - enabled: chatsModel.communities.activeCommunity.admin - //% "Create channel" - text: qsTrId("create-channel") - icon.source: "../../img/hash.svg" - icon.width: 20 - icon.height: 20 - onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id}) - } - - Action { - enabled: chatsModel.communities.activeCommunity.admin - text: qsTr("Create category") - icon.source: "../../img/create-category.svg" - icon.width: 20 - icon.height: 20 - onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id}) - } - - Separator {} - - Action { - text: qsTr("Invite People") - enabled: chatsModel.communities.activeCommunity.canManageUsers - icon.source: "../../img/export.svg" - icon.width: 20 - icon.height: 20 - onTriggered: openPopup(inviteFriendsToCommunityPopup, {communityId: chatsModel.communities.activeCommunity.id}) - } - - onAboutToHide: { - optionsBtn.state = "default" - } + optionsMenu.popup(point.x, point.y) } } } @@ -174,9 +189,31 @@ Rectangle { leftPadding: Style.current.halfPadding rightPadding: Style.current.halfPadding ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - contentHeight: categoryList.height + channelList.height + emptyViewAndSuggestionsLoader.height + backUpBannerLoader.height + 2 * Style.current.padding + contentHeight: categoryList.height + + channelList.height + + emptyViewAndSuggestionsLoader.height + + backUpBannerLoader.height + + 2 * Style.current.padding clip: true + background: Item { + anchors.fill: parent + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + + onClicked: { + let x = mouse.x + 4 + let y = mouse.y + 4 + + let point = chatGroupsContainer.mapToItem(root, x, y) + + optionsMenu.popup(point.x, point.y) + } + } + } + ChannelList { id: channelList searchStr: "" @@ -212,18 +249,6 @@ Rectangle { BackUpCommuntyBanner {} } } - - CommunityProfilePopup { - id: communityProfilePopup - communityId: chatsModel.communities.activeCommunity.id - name: chatsModel.communities.activeCommunity.name - description: chatsModel.communities.activeCommunity.description - access: chatsModel.communities.activeCommunity.access - nbMembers: chatsModel.communities.activeCommunity.nbMembers - isAdmin: chatsModel.communities.activeCommunity.admin - source: chatsModel.communities.activeCommunity.thumbnailImage - communityColor: chatsModel.communities.activeCommunity.communityColor - } } } diff --git a/ui/app/AppLayouts/Chat/CommunityComponents/BackUpCommuntyBanner.qml b/ui/app/AppLayouts/Chat/CommunityComponents/BackUpCommuntyBanner.qml index 6cec3edfb1..739590cc6e 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/BackUpCommuntyBanner.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/BackUpCommuntyBanner.qml @@ -15,6 +15,16 @@ Rectangle { radius: 16 color: Style.current.transparent + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + onClicked: { + /* Prevents sending events to the component beneath + if Right Mouse Button is clicked. */ + mouse.accepted = false; + } + } + Rectangle { width: 66 height: 4 diff --git a/ui/app/AppLayouts/Chat/CommunityComponents/CategoryList.qml b/ui/app/AppLayouts/Chat/CommunityComponents/CategoryList.qml index 6164e35ab8..2310264c01 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/CategoryList.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/CategoryList.qml @@ -37,6 +37,16 @@ Column { height: 40 width: categoryListContent.width + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + onClicked: { + /* Prevents sending events to the component beneath + if Right Mouse Button is clicked. */ + mouse.accepted = false; + } + } + StyledText { text: model.name elide: Text.ElideRight diff --git a/ui/app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml b/ui/app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml index cc4208795d..0232b208ba 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml @@ -17,6 +17,16 @@ Rectangle { radius: 16 color: Style.current.transparent + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + onClicked: { + /* Prevents sending events to the component beneath + if Right Mouse Button is clicked. */ + mouse.accepted = false; + } + } + SVGImage { anchors.top: parent.top anchors.topMargin: -6