moment/src/gui/Base/HUserAvatar.qml

67 lines
1.9 KiB
QML
Raw Normal View History

2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
HAvatar {
id: avatar
property string userId
property string displayName
property string presence: ""
2019-11-30 19:59:02 +11:00
property int powerLevel: 0
property int shiftMembershipIconPositionBy: -8
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
name: displayName || userId.substring(1) // no leading @
title: "user_" + userId + ".avatar"
2019-11-30 19:59:02 +11:00
HLoader {
active: admin || moderator || invited
2019-11-30 19:59:02 +11:00
anchors.top: parent.top
anchors.left: parent.left
anchors.topMargin: shiftMembershipIconPositionBy
2019-11-30 19:59:02 +11:00
anchors.leftMargin: anchors.topMargin
z: 100
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
svgName:
invited ? "user-invited" :
admin ? "user-power-100" :
"user-power-50"
2019-11-30 19:59:02 +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
HoverHandler { id: membershipIcon }
2019-11-30 19:59:02 +11:00
HToolTip {
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
}
}
}
HLoader {
active: presence && presence !== "offline"
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.bottomMargin: item ? -item.width / 2 : 0
anchors.rightMargin: item ? -item.height / 2 : 0
z: 300
sourceComponent: PresenceOrb { presence: avatar.presence }
}
}