Skip to content

Commit

Permalink
fix(CommunityColumnView): re-add right click menu on community column
Browse files Browse the repository at this point in the history
Fixes #6609

The menu was lost because it used to be set as part of the ScrollView background, but it got changed to  a Flickable as part of the fix to the scrolls being not smooth.
Anyway, background doesn't exist on Flickables, so I removed it and moved the MouseArea to the CommunityColumnView instead.
  • Loading branch information
jrainville committed Jul 27, 2022
1 parent e351653 commit e20929b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 67 deletions.
125 changes: 59 additions & 66 deletions ui/app/AppLayouts/Chat/views/CommunityColumnView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ Item {
signal infoButtonClicked
signal manageButtonClicked

MouseArea {
enabled: communityData.amISectionAdmin
anchors.fill: parent
z: 0
acceptedButtons: Qt.RightButton
onClicked: {
adminPopupMenu.showInviteButton = true
adminPopupMenu.x = mouse.x + 4
adminPopupMenu.y = mouse.y + 4
adminPopupMenu.open()
}
}

StatusChatInfoButton {
id: communityHeader
objectName: "communityHeaderButton"
Expand Down Expand Up @@ -76,7 +89,7 @@ Item {
text: qsTr("Start chat")
visible: parent.hovered
}
} // StatusChatInfoToolBar
}

Loader {
id: membershipRequests
Expand All @@ -100,6 +113,45 @@ Item {
}
}

StatusPopupMenu {
property bool showInviteButton: false

id: adminPopupMenu
enabled: communityData.amISectionAdmin

onClosed: adminPopupMenu.showInviteButton = false

StatusMenuItem {
objectName: "createCommunityChannelBtn"
text: qsTr("Create channel")
icon.name: "channel"
onTriggered: Global.openPopup(createChannelPopup)
}

StatusMenuItem {
objectName: "createCommunityCategoryBtn"
text: qsTr("Create category")
icon.name: "channel-category"
onTriggered: Global.openPopup(createCategoryPopup)
}

StatusMenuSeparator {
visible: invitePeopleBtn.enabled
}

StatusMenuItem {
id: invitePeopleBtn
text: qsTr("Invite people")
icon.name: "share-ios"
enabled: communityData.canManageUsers && adminPopupMenu.showInviteButton
onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
community: communityData,
hasAddedContacts: root.hasAddedContacts,
communitySectionModule: root.communitySectionModule
})
}
}

StatusScrollView {
id: scrollView
anchors.top: membershipRequests.bottom
Expand All @@ -116,46 +168,6 @@ Item {
+ bannerColumn.height
+ Style.current.bigPadding

background: MouseArea {
acceptedButtons: Qt.RightButton
onClicked: {
if (communityData.amISectionAdmin) {
popup.x = mouse.x + 4
popup.y = mouse.y + 4
popup.open()
}
}

property var popup: StatusPopupMenu {
StatusMenuItem {
text: qsTr("Create channel")
icon.name: "channel"
enabled: communityData.amISectionAdmin
onTriggered: Global.openPopup(createChannelPopup)
}

StatusMenuItem {
text: qsTr("Create category")
icon.name: "channel-category"
enabled: communityData.amISectionAdmin
onTriggered: Global.openPopup(createCategoryPopup)
}

StatusMenuSeparator {}

StatusMenuItem {
text: qsTr("Invite people")
icon.name: "share-ios"
enabled: communityData.canManageUsers
onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
community: communityData,
hasAddedContacts: root.hasAddedContacts,
communitySectionModule: root.communitySectionModule
})
}
}
} // MouseArea

StatusChatListAndCategories {
id: communityChatListAndCategories
anchors.horizontalCenter: parent.horizontalCenter
Expand Down Expand Up @@ -192,7 +204,6 @@ Item {
StatusMenuItem {
text: qsTr("Create channel")
icon.name: "channel"
// Not Refactored Yet
enabled: communityData.amISectionAdmin
onTriggered: Global.openPopup(createChannelPopup)
}
Expand Down Expand Up @@ -484,6 +495,7 @@ Item {
active: communityData.amISectionAdmin
sourceComponent: Component {
StatusBaseText {
id: createChannelOrCategoryBtn
objectName: "createChannelOrCategoryBtn"
color: Theme.palette.baseColor1
height: visible ? implicitHeight : 0
Expand All @@ -496,30 +508,11 @@ Item {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
if (createChatOrCatMenu.opened) {
createChatOrCatMenu.close()
return
}
createChatOrCatMenu.open()
createChatOrCatMenu.y = - createChatOrCatMenu.height - 5
}
}

StatusPopupMenu {
id: createChatOrCatMenu
closePolicy: Popup.CloseOnPressOutsideParent
StatusMenuItem {
objectName: "createCommunityChannelBtn"
text: qsTr("Create channel")
icon.name: "channel"
onTriggered: Global.openPopup(createChannelPopup)
}

StatusMenuItem {
objectName: "createCommunityCategoryBtn"
text: qsTr("Create category")
icon.name: "channel-category"
onTriggered: Global.openPopup(createCategoryPopup)
adminPopupMenu.showInviteButton = false
adminPopupMenu.popup()
adminPopupMenu.y = Qt.binding(function () {
return root.height - adminPopupMenu.height - createChannelOrCategoryBtn.height - 20
})
}
}
}
Expand Down

0 comments on commit e20929b

Please sign in to comment.