2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
2019-07-07 14:24:23 +10:00
|
|
|
|
|
|
|
HAvatar {
|
2019-11-04 04:48:12 +11:00
|
|
|
name: displayName || userId.substring(1) // no leading @
|
2020-03-10 02:46:08 +11:00
|
|
|
title: "user_" + userId + ".avatar"
|
2019-07-10 12:48:59 +10:00
|
|
|
|
2019-07-07 14:24:23 +10:00
|
|
|
|
2019-11-04 04:48:12 +11:00
|
|
|
property string userId
|
|
|
|
property string displayName
|
2020-06-30 02:26:28 +10:00
|
|
|
property string presence: ""
|
2019-11-30 19:59:02 +11:00
|
|
|
property int powerLevel: 0
|
2019-12-18 00:46:18 +11:00
|
|
|
property bool shiftMembershipIconPosition: true
|
|
|
|
property bool invited: false
|
2019-11-30 19:59:02 +11:00
|
|
|
|
|
|
|
readonly property bool admin: powerLevel >= 100
|
|
|
|
readonly property bool moderator: powerLevel >= 50 && ! admin
|
|
|
|
|
|
|
|
|
|
|
|
HLoader {
|
2019-12-18 00:46:18 +11:00
|
|
|
active: admin || moderator || invited
|
2019-11-30 19:59:02 +11:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
2019-12-18 00:46:18 +11:00
|
|
|
anchors.topMargin: shiftMembershipIconPosition ? -16 / 2 : 0
|
2019-11-30 19:59:02 +11:00
|
|
|
anchors.leftMargin: anchors.topMargin
|
|
|
|
z: 100
|
|
|
|
|
2019-12-05 00:17:13 +11:00
|
|
|
Behavior on anchors.topMargin { HNumberAnimation {} }
|
|
|
|
|
2019-11-30 19:59:02 +11:00
|
|
|
sourceComponent: HIcon {
|
2019-12-05 00:08:38 +11:00
|
|
|
small: true
|
2019-12-18 00:46:18 +11:00
|
|
|
svgName:
|
|
|
|
invited ? "user-invited" :
|
|
|
|
admin ? "user-power-100" :
|
|
|
|
"user-power-50"
|
2019-11-30 19:59:02 +11:00
|
|
|
|
2019-12-18 00:46:18 +11:00
|
|
|
colorize:
|
2020-03-13 16:09:04 +11:00
|
|
|
invited ? theme.chat.roomPane.listView.member.invitedIcon :
|
|
|
|
admin ? theme.chat.roomPane.listView.member.adminIcon :
|
|
|
|
theme.chat.roomPane.listView.member.moderatorIcon
|
2019-12-18 00:46:18 +11:00
|
|
|
|
|
|
|
HoverHandler { id: membershipIcon }
|
2019-11-30 19:59:02 +11:00
|
|
|
|
|
|
|
HToolTip {
|
2019-12-18 00:46:18 +11:00
|
|
|
visible: membershipIcon.hovered
|
|
|
|
text:
|
|
|
|
invited ? qsTr("Invited") :
|
|
|
|
admin ? qsTr("Admin (%1 power)").arg(powerLevel) :
|
|
|
|
qsTr("Moderator (%1 power)").arg(powerLevel)
|
2019-11-30 19:59:02 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-30 02:26:28 +10:00
|
|
|
HLoader {
|
2020-07-02 06:55:03 +10:00
|
|
|
active: presence && presence !== "offline"
|
2020-06-30 02:26:28 +10:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottomMargin: -diameter / 2
|
|
|
|
anchors.rightMargin: -diameter / 2
|
2020-06-30 12:20:37 +10:00
|
|
|
opacity: theme.controls.presence.opacity
|
2020-07-11 03:42:08 +10:00
|
|
|
z: 300
|
2020-06-30 02:26:28 +10:00
|
|
|
|
2020-07-11 00:59:26 +10:00
|
|
|
property int diameter:
|
|
|
|
window.settings.compactMode ?
|
|
|
|
theme.controls.presence.radius * 2 :
|
|
|
|
theme.controls.presence.radius * 2.5
|
2020-06-30 02:26:28 +10:00
|
|
|
|
|
|
|
sourceComponent: Rectangle {
|
|
|
|
width: diameter
|
|
|
|
height: diameter
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
radius: diameter / 2
|
2020-07-10 09:53:25 +10:00
|
|
|
opacity: presence.includes("echo") ? 0.4 : 1
|
2020-06-30 02:26:28 +10:00
|
|
|
|
|
|
|
color:
|
2020-07-10 09:53:25 +10:00
|
|
|
presence.includes("online") ?
|
2020-06-30 12:20:37 +10:00
|
|
|
theme.controls.presence.online :
|
|
|
|
|
2020-07-10 09:53:25 +10:00
|
|
|
presence.includes("unavailable") ?
|
2020-06-30 12:20:37 +10:00
|
|
|
theme.controls.presence.unavailable :
|
|
|
|
|
|
|
|
theme.controls.presence.offline
|
|
|
|
|
|
|
|
border.color: theme.controls.presence.border
|
2020-07-11 03:38:18 +10:00
|
|
|
border.width: theme.controls.presence.borderWidth
|
2020-06-30 12:20:37 +10:00
|
|
|
|
2020-07-10 09:53:25 +10:00
|
|
|
Behavior on color { HColorAnimation {} }
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
2020-06-30 12:20:37 +10:00
|
|
|
HoverHandler { id: presenceHover }
|
|
|
|
|
|
|
|
HToolTip {
|
2020-07-11 00:59:26 +10:00
|
|
|
visible: presenceHover.hovered && ! presence.includes("echo")
|
|
|
|
text: qsTr(presence.replace(/^\w/, c => c.toUpperCase()))
|
2020-06-30 12:20:37 +10:00
|
|
|
}
|
2020-06-30 02:26:28 +10:00
|
|
|
}
|
|
|
|
}
|
2019-07-07 14:24:23 +10:00
|
|
|
}
|