Split avatar presence orb into its own component
This commit is contained in:
parent
8d5d0ff7fb
commit
62ea61380a
1
TODO.md
1
TODO.md
|
@ -1,5 +1,6 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
- block power level change when offline
|
||||||
- fix power level control button layout when apply button is loading
|
- fix power level control button layout when apply button is loading
|
||||||
|
|
||||||
- joining new DM, not loading past events the first time?
|
- joining new DM, not loading past events the first time?
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
|
||||||
HAvatar {
|
HAvatar {
|
||||||
|
id: avatar
|
||||||
|
|
||||||
property string userId
|
property string userId
|
||||||
property string displayName
|
property string displayName
|
||||||
property string presence: ""
|
property string presence: ""
|
||||||
|
@ -52,48 +54,13 @@ HAvatar {
|
||||||
}
|
}
|
||||||
|
|
||||||
HLoader {
|
HLoader {
|
||||||
property int diameter:
|
|
||||||
window.settings.compactMode ?
|
|
||||||
theme.controls.presence.radius * 2 :
|
|
||||||
theme.controls.presence.radius * 2.5
|
|
||||||
|
|
||||||
active: presence && presence !== "offline"
|
active: presence && presence !== "offline"
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottomMargin: -diameter / 2
|
anchors.bottomMargin: item ? -item.width / 2 : 0
|
||||||
anchors.rightMargin: -diameter / 2
|
anchors.rightMargin: item ? -item.height / 2 : 0
|
||||||
opacity: theme.controls.presence.opacity
|
|
||||||
z: 300
|
z: 300
|
||||||
|
|
||||||
sourceComponent: Rectangle {
|
sourceComponent: PresenceOrb { presence: avatar.presence }
|
||||||
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()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
src/gui/Base/PresenceOrb.qml
Normal file
44
src/gui/Base/PresenceOrb.qml
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user