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
|
2020-07-07 11:42:16 -03:00
|
|
|
import "../../../.."
|
2020-07-08 11:33:05 -04:00
|
|
|
import "../../../../Base"
|
|
|
|
import "../../../../Base/HTile"
|
|
|
|
import "../../../../Popups"
|
2020-07-17 00:46:46 -04:00
|
|
|
import "../../../../PythonBridge"
|
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-07-12 00:25:57 -04:00
|
|
|
|
2020-07-17 00:46:46 -04:00
|
|
|
property Future getPresenceFuture: null
|
|
|
|
|
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
|
|
|
|
invited: model.invited
|
|
|
|
compact: member.compact
|
2020-06-29 13:26:28 -03:00
|
|
|
presence: model.presence
|
2020-07-14 17:17:27 -04:00
|
|
|
shiftMembershipIconPositionBy:
|
|
|
|
roomPane.width >= width + 8 * 3 ? -8 : -4
|
2020-03-30 15:03:35 -04:00
|
|
|
}
|
2019-08-21 04:39:07 -04:00
|
|
|
|
2020-03-30 15:03:35 -04:00
|
|
|
HColumnLayout {
|
2020-06-29 21:49:01 -03:00
|
|
|
HRowLayout {
|
|
|
|
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
|
|
|
|
|
|
|
|
Behavior on color { HColorAnimation {} }
|
|
|
|
}
|
|
|
|
|
|
|
|
TitleRightInfoLabel {
|
2020-07-10 11:59:26 -03:00
|
|
|
id: lastActiveAt
|
2020-06-29 21:49:01 -03:00
|
|
|
tile: member
|
2020-07-09 20:53:25 -03:00
|
|
|
visible: presenceTimer.running
|
2020-07-14 17:32:47 -04:00
|
|
|
hideUnderWidth: 120
|
2020-06-29 21:49:01 -03:00
|
|
|
}
|
2020-03-30 15:03:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
SubtitleLabel {
|
|
|
|
tile: member
|
|
|
|
color: theme.chat.roomPane.listView.member.subtitle
|
2020-07-07 11:42:16 -03:00
|
|
|
text: utils.escapeHtml(model.status_msg.trim()) || model.id
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler { id: nameHover }
|
|
|
|
|
|
|
|
HToolTip {
|
|
|
|
visible: nameHover.hovered
|
|
|
|
text:
|
|
|
|
model.id +
|
|
|
|
(
|
|
|
|
model.status_msg.trim() ?
|
|
|
|
" - " + model.status_msg.trim() :
|
|
|
|
""
|
|
|
|
)
|
2020-03-30 15:03:35 -04:00
|
|
|
}
|
2020-07-10 11:59:26 -03:00
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: presenceTimer
|
|
|
|
running:
|
|
|
|
! model.currently_active &&
|
|
|
|
model.last_active_at > new Date(1)
|
|
|
|
repeat: true
|
|
|
|
interval:
|
|
|
|
new Date() - model.last_active_at < 60000 ? 10000 : 60000
|
|
|
|
triggeredOnStart: true
|
|
|
|
onTriggered: lastActiveAt.text = Qt.binding(() =>
|
|
|
|
utils.formatRelativeTime(new Date() - model.last_active_at)
|
|
|
|
)
|
|
|
|
}
|
2020-03-30 15:03:35 -04:00
|
|
|
}
|
|
|
|
}
|
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 {
|
2020-07-10 12:34:59 -04:00
|
|
|
property bool permissionToKick: false
|
|
|
|
|
2020-04-19 11:12:35 -04:00
|
|
|
icon.name: "room-kick"
|
|
|
|
icon.color: theme.colors.negativeBackground
|
|
|
|
text: model.invited ? qsTr("Disinvite") : qsTr("Kick")
|
2020-07-10 12:34:59 -04:00
|
|
|
enabled: chat.userInfo.presence !== "offline" && permissionToKick
|
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
|
|
|
properties: ({
|
|
|
|
userId: chat.userId,
|
|
|
|
roomId: chat.roomId,
|
|
|
|
targetUserId: model.id,
|
|
|
|
targetDisplayName: model.display_name,
|
2020-06-25 08:32:08 -04:00
|
|
|
operation: model.invited ? "disinvite" : "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],
|
2020-07-10 12:34:59 -04:00
|
|
|
can => { permissionToKick = can },
|
2020-04-19 16:50:19 -04:00
|
|
|
)
|
2020-04-19 11:12:35 -04:00
|
|
|
}
|
2020-04-19 17:30:16 -04:00
|
|
|
|
|
|
|
HMenuItemPopupSpawner {
|
2020-07-10 12:34:59 -04:00
|
|
|
property bool permissionToBan: false
|
|
|
|
|
2020-04-19 17:30:16 -04:00
|
|
|
icon.name: "room-ban"
|
|
|
|
icon.color: theme.colors.negativeBackground
|
|
|
|
text: qsTr("Ban")
|
2020-07-10 12:34:59 -04:00
|
|
|
enabled: chat.userInfo.presence !== "offline" && permissionToBan
|
2020-04-19 17:30:16 -04:00
|
|
|
|
|
|
|
popup: "Popups/RemoveMemberPopup.qml"
|
|
|
|
properties: ({
|
|
|
|
userId: chat.userId,
|
|
|
|
roomId: chat.roomId,
|
|
|
|
targetUserId: model.id,
|
|
|
|
targetDisplayName: model.display_name,
|
2020-06-25 08:32:08 -04:00
|
|
|
operation: "ban",
|
2020-04-19 17:30:16 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
Component.onCompleted: py.callClientCoro(
|
|
|
|
chat.userId,
|
|
|
|
"can_ban",
|
|
|
|
[chat.roomId, model.id],
|
2020-07-10 12:34:59 -04:00
|
|
|
can => { permissionToBan = can },
|
2020-04-19 17:30:16 -04:00
|
|
|
)
|
|
|
|
}
|
2019-12-12 08:32:50 -04:00
|
|
|
}
|
|
|
|
|
2020-07-17 00:46:46 -04:00
|
|
|
Component.onCompleted:
|
|
|
|
if (model.presence === "offline" && model.last_active_at < new Date(1))
|
|
|
|
getPresenceFuture = py.callClientCoro(
|
|
|
|
chat.userId, "get_offline_presence", [model.id],
|
|
|
|
)
|
|
|
|
|
|
|
|
Component.onDestruction: if (getPresenceFuture) getPresenceFuture.cancel()
|
|
|
|
|
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
|
|
|
}
|