fix(communities): Right click inside the community pane does not open context menu

Fixes: #2547
This commit is contained in:
Sale Djenic 2021-06-25 11:13:54 +02:00 committed by Iuri Matias
parent 4c0371144b
commit 562373fdfc
4 changed files with 107 additions and 52 deletions

View File

@ -41,6 +41,56 @@ Rectangle {
TransferOwnershipPopup {} 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 { Item {
id: communityHeader id: communityHeader
width: parent.width width: parent.width
@ -74,48 +124,13 @@ Rectangle {
onClicked: { onClicked: {
optionsBtn.state = "pressed" optionsBtn.state = "pressed"
let x = optionsBtn.iconX + optionsBtn.icon.width / 2 - optionsMenu.width / 2 let x = optionsBtn.iconX + optionsBtn.icon.width / 2 - optionsMenu.width / 2
optionsMenu.popup(x, optionsBtn.icon.height + 14) let y = optionsBtn.height + 4
}
PopupMenu { let point = optionsBtn.mapToItem(root, x, y)
id: optionsMenu
x: optionsBtn.x + optionsBtn.width / 2 - optionsMenu.width / 2
y: optionsBtn.height
Action { optionsMenu.popup(point.x, point.y)
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"
}
} }
} }
} }
@ -174,9 +189,31 @@ Rectangle {
leftPadding: Style.current.halfPadding leftPadding: Style.current.halfPadding
rightPadding: Style.current.halfPadding rightPadding: Style.current.halfPadding
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff 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 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 { ChannelList {
id: channelList id: channelList
searchStr: "" searchStr: ""
@ -212,18 +249,6 @@ Rectangle {
BackUpCommuntyBanner {} 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
}
} }
} }

View File

@ -15,6 +15,16 @@ Rectangle {
radius: 16 radius: 16
color: Style.current.transparent 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 { Rectangle {
width: 66 width: 66
height: 4 height: 4

View File

@ -37,6 +37,16 @@ Column {
height: 40 height: 40
width: categoryListContent.width 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 { StyledText {
text: model.name text: model.name
elide: Text.ElideRight elide: Text.ElideRight

View File

@ -17,6 +17,16 @@ Rectangle {
radius: 16 radius: 16
color: Style.current.transparent 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 { SVGImage {
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: -6 anchors.topMargin: -6