2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick 2.12
|
2019-12-27 09:06:42 -04:00
|
|
|
import Clipboard 0.1
|
2019-12-18 04:53:08 -04:00
|
|
|
import "../../../Base"
|
2020-03-30 15:03:35 -04:00
|
|
|
import "../../../Base/HTile"
|
2020-04-19 17:30:16 -04:00
|
|
|
import "../../../Popups"
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2020-05-14 19:30:34 -04:00
|
|
|
HTile {
|
2020-03-30 15:03:35 -04:00
|
|
|
id: member
|
2020-03-13 01:09:04 -04:00
|
|
|
backgroundColor: theme.chat.roomPane.listView.member.background
|
2019-12-17 09:46:18 -04:00
|
|
|
contentOpacity:
|
2020-03-13 01:09:04 -04:00
|
|
|
model.invited ? theme.chat.roomPane.listView.member.invitedOpacity : 1
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2020-03-30 15:03:35 -04:00
|
|
|
contentItem: ContentRow {
|
|
|
|
tile: member
|
|
|
|
|
|
|
|
HUserAvatar {
|
|
|
|
id: avatar
|
|
|
|
userId: model.id
|
|
|
|
displayName: model.display_name
|
|
|
|
mxc: model.avatar_url
|
|
|
|
powerLevel: model.power_level
|
|
|
|
shiftMembershipIconPosition: ! roomPane.collapsed
|
|
|
|
invited: model.invited
|
|
|
|
compact: member.compact
|
|
|
|
}
|
2019-08-21 04:39:07 -04:00
|
|
|
|
2020-03-30 15:03:35 -04:00
|
|
|
HColumnLayout {
|
|
|
|
TitleLabel {
|
|
|
|
text: model.display_name || model.id
|
|
|
|
color:
|
|
|
|
member.hovered ?
|
|
|
|
utils.nameColor(
|
|
|
|
model.display_name || model.id.substring(1)
|
|
|
|
) :
|
|
|
|
theme.chat.roomPane.listView.member.name
|
2019-08-22 05:42:48 -04:00
|
|
|
|
2020-03-30 15:03:35 -04:00
|
|
|
Behavior on color { HColorAnimation {} }
|
|
|
|
}
|
|
|
|
|
|
|
|
SubtitleLabel {
|
|
|
|
tile: member
|
|
|
|
text: model.display_name ? model.id : ""
|
|
|
|
color: theme.chat.roomPane.listView.member.subtitle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-30 05:12:00 -04:00
|
|
|
|
2019-12-12 08:32:50 -04:00
|
|
|
contextMenu: HMenu {
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "copy-user-id"
|
|
|
|
text: qsTr("Copy user ID")
|
2019-12-02 16:29:29 -04:00
|
|
|
onTriggered: Clipboard.text = model.id
|
2019-12-12 08:32:50 -04:00
|
|
|
}
|
2020-04-19 11:12:35 -04:00
|
|
|
|
|
|
|
HMenuItemPopupSpawner {
|
|
|
|
icon.name: "room-kick"
|
|
|
|
icon.color: theme.colors.negativeBackground
|
|
|
|
text: model.invited ? qsTr("Disinvite") : qsTr("Kick")
|
2020-04-19 16:50:19 -04:00
|
|
|
enabled: false
|
2020-04-19 11:12:35 -04:00
|
|
|
|
2020-04-19 17:30:16 -04:00
|
|
|
popup: "Popups/RemoveMemberPopup.qml"
|
2020-04-19 11:12:35 -04:00
|
|
|
popupParent: chat
|
|
|
|
properties: ({
|
|
|
|
userId: chat.userId,
|
|
|
|
roomId: chat.roomId,
|
|
|
|
targetUserId: model.id,
|
|
|
|
targetDisplayName: model.display_name,
|
2020-04-19 17:30:16 -04:00
|
|
|
operation:
|
|
|
|
model.invited ?
|
|
|
|
RemoveMemberPopup.Operation.Disinvite :
|
|
|
|
RemoveMemberPopup.Operation.Kick,
|
2020-04-19 11:12:35 -04:00
|
|
|
})
|
2020-04-19 16:50:19 -04:00
|
|
|
|
|
|
|
Component.onCompleted: py.callClientCoro(
|
|
|
|
chat.userId,
|
|
|
|
"can_kick",
|
|
|
|
[chat.roomId, model.id],
|
|
|
|
can => { enabled = can },
|
|
|
|
)
|
2020-04-19 11:12:35 -04:00
|
|
|
}
|
2020-04-19 17:30:16 -04:00
|
|
|
|
|
|
|
HMenuItemPopupSpawner {
|
|
|
|
icon.name: "room-ban"
|
|
|
|
icon.color: theme.colors.negativeBackground
|
|
|
|
text: qsTr("Ban")
|
|
|
|
enabled: false
|
|
|
|
|
|
|
|
popup: "Popups/RemoveMemberPopup.qml"
|
|
|
|
popupParent: chat
|
|
|
|
properties: ({
|
|
|
|
userId: chat.userId,
|
|
|
|
roomId: chat.roomId,
|
|
|
|
targetUserId: model.id,
|
|
|
|
targetDisplayName: model.display_name,
|
|
|
|
operation: RemoveMemberPopup.Operation.Ban,
|
|
|
|
})
|
|
|
|
|
|
|
|
Component.onCompleted: py.callClientCoro(
|
|
|
|
chat.userId,
|
|
|
|
"can_ban",
|
|
|
|
[chat.roomId, model.id],
|
|
|
|
can => { enabled = can },
|
|
|
|
)
|
|
|
|
}
|
2019-12-12 08:32:50 -04:00
|
|
|
}
|
|
|
|
|
2019-11-30 05:12:00 -04:00
|
|
|
|
2019-12-17 09:46:18 -04:00
|
|
|
Behavior on contentOpacity { HNumberAnimation {} }
|
2019-12-21 12:46:47 -04:00
|
|
|
Behavior on spacing { HNumberAnimation {} }
|
|
|
|
|
|
|
|
Binding on spacing {
|
2020-03-30 15:03:35 -04:00
|
|
|
value: (roomPane.minimumSize - avatar.width) / 2
|
|
|
|
when: avatar && roomPane.width < avatar.width + theme.spacing * 2
|
2019-12-21 12:46:47 -04:00
|
|
|
}
|
2019-05-12 13:17:42 -04:00
|
|
|
}
|