2022-06-28 15:03:10 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.controls.chat 1.0
|
|
|
|
|
|
|
|
import "../../layouts"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property string placeholderText
|
|
|
|
property var model
|
2023-04-06 14:23:19 +00:00
|
|
|
property var communityMemberContextMenu
|
2022-06-28 15:03:10 +00:00
|
|
|
|
|
|
|
signal userProfileClicked(string id)
|
|
|
|
signal kickUserClicked(string id, string name)
|
|
|
|
signal banUserClicked(string id, string name)
|
|
|
|
signal unbanUserClicked(string id)
|
|
|
|
|
2022-08-04 07:49:41 +00:00
|
|
|
signal acceptRequestToJoin(string id)
|
|
|
|
signal declineRequestToJoin(string id)
|
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
enum TabType {
|
|
|
|
AllMembers,
|
2022-08-04 07:49:41 +00:00
|
|
|
BannedMembers,
|
|
|
|
PendingRequests,
|
|
|
|
DeclinedRequests
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
property int panelType: CommunityMembersTabPanel.TabType.AllMembers
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
2022-08-08 15:56:57 +00:00
|
|
|
spacing: 30
|
2022-06-28 15:03:10 +00:00
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: memberSearch
|
2022-09-22 22:18:15 +00:00
|
|
|
Layout.preferredWidth: 400
|
2022-08-08 15:56:57 +00:00
|
|
|
Layout.leftMargin: 12
|
2022-06-28 15:03:10 +00:00
|
|
|
maximumHeight: 36
|
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
|
|
|
rightPadding: 0
|
|
|
|
placeholderText: root.placeholderText
|
2022-08-11 11:55:08 +00:00
|
|
|
input.asset.name: "search"
|
2023-04-19 16:48:57 +00:00
|
|
|
enabled: !!model && model.count > 0
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: membersList
|
2022-10-25 19:08:15 +00:00
|
|
|
objectName: "CommunityMembersTabPanel_MembersListViews"
|
2022-06-28 15:03:10 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
model: root.model
|
|
|
|
clip: true
|
2022-08-08 15:56:57 +00:00
|
|
|
spacing: 15
|
2022-06-28 15:03:10 +00:00
|
|
|
|
|
|
|
delegate: StatusMemberListItem {
|
|
|
|
id: memberItem
|
|
|
|
|
|
|
|
readonly property bool itsMe: model.pubKey.toLowerCase() === userProfile.pubKey.toLowerCase()
|
2022-08-04 07:49:41 +00:00
|
|
|
readonly property bool isHovered: memberItem.sensor.containsMouse
|
|
|
|
readonly property bool canBeBanned: !memberItem.itsMe && !model.isAdmin
|
2022-06-28 15:03:10 +00:00
|
|
|
|
|
|
|
statusListItemComponentsSlot.spacing: 16
|
2022-08-04 07:49:41 +00:00
|
|
|
statusListItemTitleArea.anchors.rightMargin: 0
|
|
|
|
statusListItemSubTitle.elide: Text.ElideRight
|
|
|
|
rightPadding: 75
|
2022-08-08 15:56:57 +00:00
|
|
|
leftPadding: 12
|
2022-06-28 15:03:10 +00:00
|
|
|
|
|
|
|
components: [
|
|
|
|
StatusButton {
|
2022-10-25 19:08:15 +00:00
|
|
|
objectName: "MemberListIten_KickButton"
|
2022-08-04 07:49:41 +00:00
|
|
|
visible: (root.panelType === CommunityMembersTabPanel.TabType.AllMembers) && isHovered && canBeBanned
|
2022-06-28 15:03:10 +00:00
|
|
|
text: qsTr("Kick")
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
onClicked: root.kickUserClicked(model.pubKey, model.displayName)
|
|
|
|
},
|
|
|
|
|
|
|
|
StatusButton {
|
2022-08-04 07:49:41 +00:00
|
|
|
visible: (root.panelType === CommunityMembersTabPanel.TabType.AllMembers) && isHovered && canBeBanned
|
2022-06-28 15:03:10 +00:00
|
|
|
text: qsTr("Ban")
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
onClicked: root.banUserClicked(model.pubKey, model.displayName)
|
|
|
|
},
|
|
|
|
|
|
|
|
StatusButton {
|
2022-08-04 07:49:41 +00:00
|
|
|
visible: (root.panelType === CommunityMembersTabPanel.TabType.BannedMembers) && isHovered && canBeBanned
|
2022-06-28 15:03:10 +00:00
|
|
|
text: qsTr("Unban")
|
|
|
|
onClicked: root.unbanUserClicked(model.pubKey)
|
2022-08-04 07:49:41 +00:00
|
|
|
},
|
|
|
|
|
2023-03-21 11:21:23 +00:00
|
|
|
StatusButton {
|
|
|
|
visible: (root.panelType === CommunityMembersTabPanel.TabType.PendingRequests) && isHovered
|
|
|
|
text: qsTr("Reject")
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
icon.name: "close-circle"
|
|
|
|
icon.color: Style.current.danger
|
|
|
|
onClicked: root.declineRequestToJoin(model.requestToJoinId)
|
|
|
|
},
|
|
|
|
|
2022-08-04 07:49:41 +00:00
|
|
|
StatusButton {
|
|
|
|
visible: (root.panelType === CommunityMembersTabPanel.TabType.PendingRequests ||
|
|
|
|
root.panelType === CommunityMembersTabPanel.TabType.DeclinedRequests) && isHovered
|
|
|
|
text: qsTr("Accept")
|
|
|
|
icon.name: "checkmark-circle"
|
|
|
|
icon.color: Theme.palette.successColor1
|
|
|
|
normalColor: Theme.palette.successColor2
|
|
|
|
hoverColor: Theme.palette.successColor3
|
|
|
|
textColor: Theme.palette.successColor1
|
2023-03-21 11:21:23 +00:00
|
|
|
loading: model.requestToJoinLoading
|
2022-08-04 07:49:41 +00:00
|
|
|
onClicked: root.acceptRequestToJoin(model.requestToJoinId)
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
2023-03-21 11:21:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
width: membersList.width
|
|
|
|
visible: memberSearch.text === "" || title.toLowerCase().includes(memberSearch.text.toLowerCase())
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
color: "transparent"
|
|
|
|
|
2023-04-19 16:48:57 +00:00
|
|
|
pubKey: model.isEnsVerified ? "" : Utils.getElidedCompressedPk(model.pubKey)
|
2022-06-28 15:03:10 +00:00
|
|
|
nickName: model.localNickname
|
2022-12-05 09:56:44 +00:00
|
|
|
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
|
2022-06-28 15:03:10 +00:00
|
|
|
status: model.onlineStatus
|
2022-09-06 15:06:33 +00:00
|
|
|
asset.color: Utils.colorForColorId(model.colorId)
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: model.icon
|
2022-09-09 12:51:10 +00:00
|
|
|
asset.isImage: !!model.icon
|
|
|
|
asset.isLetterIdenticon: !model.icon
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.width: 40
|
|
|
|
asset.height: 40
|
2023-01-10 11:29:24 +00:00
|
|
|
ringSettings.ringSpecModel: model.colorHash
|
2022-06-28 15:03:10 +00:00
|
|
|
statusListItemIcon.badge.visible: (root.panelType === CommunityMembersTabPanel.TabType.AllMembers)
|
|
|
|
|
2023-04-06 14:23:19 +00:00
|
|
|
onClicked: {
|
|
|
|
if(mouse.button === Qt.RightButton) {
|
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
root.communityMemberContextMenu.parent = this
|
|
|
|
root.communityMemberContextMenu.isProfile = true
|
|
|
|
root.communityMemberContextMenu.selectedUserPublicKey = model.pubKey
|
|
|
|
root.communityMemberContextMenu.selectedUserDisplayName = userName
|
|
|
|
root.communityMemberContextMenu.selectedUserIcon = asset.name
|
|
|
|
root.communityMemberContextMenu.popup()
|
|
|
|
} else {
|
|
|
|
root.userProfileClicked(model.pubKey)
|
|
|
|
}
|
|
|
|
}
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|