Split avatar presence orb into its own component

This commit is contained in:
miruka 2020-07-15 00:39:16 -04:00
parent 8d5d0ff7fb
commit 62ea61380a
3 changed files with 50 additions and 38 deletions

View File

@ -1,5 +1,6 @@
# TODO
- block power level change when offline
- fix power level control button layout when apply button is loading
- joining new DM, not loading past events the first time?

View File

@ -3,6 +3,8 @@
import QtQuick 2.12
HAvatar {
id: avatar
property string userId
property string displayName
property string presence: ""
@ -52,48 +54,13 @@ HAvatar {
}
HLoader {
property int diameter:
window.settings.compactMode ?
theme.controls.presence.radius * 2 :
theme.controls.presence.radius * 2.5
active: presence && presence !== "offline"
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.bottomMargin: -diameter / 2
anchors.rightMargin: -diameter / 2
opacity: theme.controls.presence.opacity
anchors.bottomMargin: item ? -item.width / 2 : 0
anchors.rightMargin: item ? -item.height / 2 : 0
z: 300
sourceComponent: Rectangle {
width: diameter
height: diameter
anchors.bottom: parent.bottom
anchors.right: parent.right
radius: diameter / 2
opacity: presence.includes("echo") ? 0.4 : 1
color:
presence.includes("online") ?
theme.controls.presence.online :
presence.includes("unavailable") ?
theme.controls.presence.unavailable :
theme.controls.presence.offline
border.color: theme.controls.presence.border
border.width: theme.controls.presence.borderWidth
Behavior on color { HColorAnimation {} }
Behavior on opacity { HNumberAnimation {} }
HoverHandler { id: presenceHover }
HToolTip {
visible: presenceHover.hovered && ! presence.includes("echo")
text: qsTr(presence.replace(/^\w/, c => c.toUpperCase()))
}
}
sourceComponent: PresenceOrb { presence: avatar.presence }
}
}

View File

@ -0,0 +1,44 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
Rectangle {
property string presence
implicitWidth:
window.settings.compactMode ?
theme.controls.presence.radius * 2 :
theme.controls.presence.radius * 2.5
implicitHeight: width
radius: width / 2
opacity:
theme.controls.presence.opacity * (presence.includes("echo") ? 0.5 : 1)
color:
presence.includes("online") ?
theme.controls.presence.online :
presence.includes("unavailable") ?
theme.controls.presence.unavailable :
theme.controls.presence.offline
border.color: theme.controls.presence.border
border.width: theme.controls.presence.borderWidth
Behavior on color { HColorAnimation {} }
Behavior on opacity { HNumberAnimation {} }
HoverHandler { id: presenceHover }
HToolTip {
visible: presenceHover.hovered
text:
presence.includes("online") ? qsTr("Online") :
presence.includes("unavailable") ? qsTr("Unavailable") :
presence.includes("invisible") ? qsTr("Invisible") :
qsTr("Offline")
}
}