2022-03-23 10:56:25 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
2024-10-28 17:14:25 +00:00
|
|
|
import StatusQ 0.1
|
2022-03-23 10:56:25 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
2023-06-07 10:54:31 +00:00
|
|
|
import shared.controls.chat.menuItems 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.stores 1.0 as AppLayoutsStores
|
2024-10-28 17:14:25 +00:00
|
|
|
import AppLayouts.Chat.views 1.0
|
2023-06-07 10:54:31 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-03-23 10:56:25 +00:00
|
|
|
id: root
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property AppLayoutsStores.RootStore rootStore
|
2022-03-23 10:56:25 +00:00
|
|
|
|
|
|
|
signal inviteFriends(var communityData)
|
2023-06-07 10:54:31 +00:00
|
|
|
|
2023-06-14 08:42:52 +00:00
|
|
|
signal closeCommunityClicked(string communityId)
|
|
|
|
signal leaveCommunityClicked(string community, string communityId, string outroMessage)
|
2023-06-07 10:54:31 +00:00
|
|
|
signal setCommunityMutedClicked(string communityId, int mutedType)
|
2022-07-25 15:39:09 +00:00
|
|
|
signal setActiveCommunityClicked(string communityId)
|
2024-03-25 17:32:33 +00:00
|
|
|
signal showCommunityMembershipSetupDialog(string communityId, string name,
|
|
|
|
string introMessage, string imageSrc, int accessType)
|
2023-06-21 20:37:51 +00:00
|
|
|
signal cancelMembershipRequest(string communityId)
|
2022-03-23 10:56:25 +00:00
|
|
|
|
|
|
|
interactive: false
|
|
|
|
implicitHeight: contentItem.childrenRect.height
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
delegate: StatusListItem {
|
2023-06-21 20:37:51 +00:00
|
|
|
id: listItem
|
2024-10-28 17:14:25 +00:00
|
|
|
|
|
|
|
MembersModelAdaptor {
|
|
|
|
id: membersModelAdaptor
|
|
|
|
allMembers: model.allMembers
|
|
|
|
}
|
|
|
|
|
2023-06-21 20:37:51 +00:00
|
|
|
width: ListView.view.width
|
2022-03-23 10:56:25 +00:00
|
|
|
title: model.name
|
2022-09-15 15:49:13 +00:00
|
|
|
statusListItemTitle.font.pixelSize: 17
|
|
|
|
statusListItemTitle.font.bold: true
|
2023-06-21 20:37:51 +00:00
|
|
|
statusListItemIcon.anchors.verticalCenter: undefined
|
|
|
|
statusListItemIcon.anchors.top: statusListItemTitleArea.top
|
2022-03-23 10:56:25 +00:00
|
|
|
subTitle: model.description
|
2024-10-28 17:14:25 +00:00
|
|
|
tertiaryTitle: qsTr("%n member(s)", "", membersModelAdaptor.joinedMembers.ModelCount.count)
|
2023-06-21 20:37:51 +00:00
|
|
|
statusListItemTertiaryTitle.font.weight: Font.Medium
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: model.image
|
|
|
|
asset.isLetterIdenticon: !model.image
|
|
|
|
asset.bgColor: model.color || Theme.palette.primaryColor1
|
2022-09-21 11:19:50 +00:00
|
|
|
asset.width: 40
|
|
|
|
asset.height: 40
|
2022-03-23 10:56:25 +00:00
|
|
|
|
2022-09-15 15:49:13 +00:00
|
|
|
onClicked: setActiveCommunityClicked(model.id)
|
2022-07-25 15:39:09 +00:00
|
|
|
|
2023-06-29 08:47:37 +00:00
|
|
|
readonly property bool isSpectator: model.spectated && !model.joined
|
2023-06-21 20:37:51 +00:00
|
|
|
readonly property bool isOwner: model.memberRole === Constants.memberRole.owner
|
|
|
|
readonly property bool isAdmin: model.memberRole === Constants.memberRole.admin
|
2023-07-19 20:07:14 +00:00
|
|
|
readonly property bool isTokenMaster: model.memberRole === Constants.memberRole.tokenMaster
|
2024-03-27 12:48:17 +00:00
|
|
|
property bool isInvitationPending: root.rootStore.isMyCommunityRequestPending(model.id)
|
2023-06-07 10:54:31 +00:00
|
|
|
|
2023-06-21 20:37:51 +00:00
|
|
|
components: [
|
2022-09-15 15:49:13 +00:00
|
|
|
StatusFlatButton {
|
2023-04-12 19:08:42 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
size: StatusBaseButton.Size.Small
|
2023-06-21 20:37:51 +00:00
|
|
|
icon.name: "notification-muted"
|
|
|
|
icon.color: Theme.palette.baseColor1
|
|
|
|
visible: model.muted
|
|
|
|
onClicked: root.setCommunityMutedClicked(model.id, Constants.MutingVariations.Unmuted)
|
|
|
|
},
|
|
|
|
StatusFlatButton {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
text: listItem.isInvitationPending ? qsTr("Membership Request Sent") : qsTr("View & Join Community")
|
2023-06-29 08:47:37 +00:00
|
|
|
visible: listItem.isSpectator
|
2024-03-25 17:32:33 +00:00
|
|
|
onClicked: root.showCommunityMembershipSetupDialog(
|
|
|
|
model.id, model.name, model.introMessage, model.image, model.access)
|
2023-06-21 20:37:51 +00:00
|
|
|
},
|
|
|
|
StatusFlatButton {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
icon.name: "more"
|
|
|
|
icon.color: Theme.palette.directColor1
|
|
|
|
highlighted: moreMenu.opened
|
|
|
|
onClicked: moreMenu.popup(-moreMenu.width + width, height + 4)
|
2023-06-07 10:54:31 +00:00
|
|
|
|
2023-06-21 20:37:51 +00:00
|
|
|
StatusMenu {
|
|
|
|
id: moreMenu
|
2023-06-07 10:54:31 +00:00
|
|
|
|
|
|
|
StatusAction {
|
2023-06-21 20:37:51 +00:00
|
|
|
text: qsTr("Community Admin")
|
|
|
|
icon.name: "settings"
|
2023-07-19 20:07:14 +00:00
|
|
|
enabled: listItem.isOwner || listItem.isAdmin || listItem.isTokenMaster
|
2023-06-21 20:37:51 +00:00
|
|
|
onTriggered: {
|
|
|
|
moreMenu.close()
|
|
|
|
Global.switchToCommunity(model.id)
|
|
|
|
Global.switchToCommunitySettings(model.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Unmute Community")
|
|
|
|
enabled: model.muted
|
|
|
|
icon.name: "notification"
|
|
|
|
onTriggered: {
|
|
|
|
moreMenu.close()
|
|
|
|
root.setCommunityMutedClicked(model.id, Constants.MutingVariations.Unmuted)
|
|
|
|
}
|
2023-06-07 10:54:31 +00:00
|
|
|
}
|
|
|
|
MuteChatMenuItem {
|
2023-06-29 08:47:37 +00:00
|
|
|
enabled: (model.joined || (listItem.isSpectator && !listItem.isInvitationPending)) && !model.muted
|
2023-06-07 10:54:31 +00:00
|
|
|
title: qsTr("Mute Community")
|
|
|
|
onMuteTriggered: {
|
2023-06-21 20:37:51 +00:00
|
|
|
moreMenu.close()
|
2023-06-07 10:54:31 +00:00
|
|
|
root.setCommunityMutedClicked(model.id, interval)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusAction {
|
2023-06-21 20:37:51 +00:00
|
|
|
text: qsTr("Invite People")
|
|
|
|
icon.name: "invite-users"
|
|
|
|
onTriggered: {
|
|
|
|
moreMenu.close()
|
|
|
|
root.inviteFriends(model)
|
|
|
|
}
|
2023-09-12 08:55:40 +00:00
|
|
|
objectName: "invitePeople"
|
2023-06-07 10:54:31 +00:00
|
|
|
}
|
|
|
|
StatusAction {
|
2023-06-21 20:37:51 +00:00
|
|
|
text: qsTr("Edit Shared Addresses")
|
|
|
|
icon.name: "wallet"
|
|
|
|
enabled: {
|
2024-04-08 11:35:12 +00:00
|
|
|
if (listItem.isOwner || listItem.isSpectator)
|
2023-06-21 20:37:51 +00:00
|
|
|
return false
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
onTriggered: {
|
|
|
|
moreMenu.close()
|
|
|
|
Global.openEditSharedAddressesFlow(model.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusMenuSeparator {
|
2023-07-19 20:07:14 +00:00
|
|
|
visible: leaveMenuItem.enabled
|
2023-06-21 20:37:51 +00:00
|
|
|
}
|
|
|
|
StatusAction {
|
|
|
|
id: leaveMenuItem
|
|
|
|
objectName: "CommunitiesListPanel_leaveCommunityPopupButton"
|
|
|
|
text: {
|
|
|
|
if (listItem.isInvitationPending)
|
|
|
|
return qsTr("Cancel Membership Request")
|
2023-06-29 08:47:37 +00:00
|
|
|
return listItem.isSpectator ? qsTr("Close Community") : qsTr("Leave Community")
|
2023-06-21 20:37:51 +00:00
|
|
|
}
|
|
|
|
icon.name: {
|
|
|
|
if (listItem.isInvitationPending)
|
|
|
|
return "arrow-left"
|
2023-06-29 08:47:37 +00:00
|
|
|
return listItem.isSpectator ? "close-circle" : "arrow-left"
|
2023-06-21 20:37:51 +00:00
|
|
|
}
|
2023-06-07 10:54:31 +00:00
|
|
|
type: StatusAction.Type.Danger
|
2023-06-21 20:37:51 +00:00
|
|
|
enabled: !listItem.isOwner
|
|
|
|
onTriggered: {
|
|
|
|
moreMenu.close()
|
2024-03-27 12:48:17 +00:00
|
|
|
if (listItem.isInvitationPending) {
|
2023-06-21 20:37:51 +00:00
|
|
|
root.cancelMembershipRequest(model.id)
|
2024-03-27 12:48:17 +00:00
|
|
|
listItem.isInvitationPending = root.rootStore.isMyCommunityRequestPending(model.id)
|
|
|
|
} else if (listItem.isSpectator)
|
2023-06-21 20:37:51 +00:00
|
|
|
root.closeCommunityClicked(model.id)
|
|
|
|
else
|
|
|
|
root.leaveCommunityClicked(model.name, model.id, model.outroMessage)
|
|
|
|
}
|
2023-06-07 10:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-23 10:56:25 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2023-06-14 08:42:52 +00:00
|
|
|
}
|