diff --git a/TODO.md b/TODO.md index d34e79d7..62075017 100644 --- a/TODO.md +++ b/TODO.md @@ -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? diff --git a/src/gui/Base/HUserAvatar.qml b/src/gui/Base/HUserAvatar.qml index 1aac00b1..b61c2c23 100644 --- a/src/gui/Base/HUserAvatar.qml +++ b/src/gui/Base/HUserAvatar.qml @@ -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 } } } diff --git a/src/gui/Base/PresenceOrb.qml b/src/gui/Base/PresenceOrb.qml new file mode 100644 index 00000000..1ee3eeea --- /dev/null +++ b/src/gui/Base/PresenceOrb.qml @@ -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") + } +}