forked from Shinonome/dots-hyprland
put battery charge icon into loader
This commit is contained in:
@@ -7,6 +7,7 @@ import Quickshell.Io
|
|||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: root
|
||||||
readonly property var chargeState: UPower.displayDevice.state
|
readonly property var chargeState: UPower.displayDevice.state
|
||||||
readonly property bool isCharging: chargeState == UPowerDeviceState.Charging
|
readonly property bool isCharging: chargeState == UPowerDeviceState.Charging
|
||||||
readonly property bool isPluggedIn: isCharging || chargeState == UPowerDeviceState.PendingCharge
|
readonly property bool isPluggedIn: isCharging || chargeState == UPowerDeviceState.PendingCharge
|
||||||
@@ -27,7 +28,7 @@ Rectangle {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
implicitWidth: (isCharging ? boltIcon.width : 0)
|
implicitWidth: (isCharging ? (boltIconLoader?.item?.width ?? 0) : 0)
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
Behavior on implicitWidth {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
@@ -64,26 +65,41 @@ Rectangle {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialSymbol {
|
Loader {
|
||||||
id: boltIcon
|
id: boltIconLoader
|
||||||
|
active: true
|
||||||
anchors.left: rowLayout.left
|
anchors.left: rowLayout.left
|
||||||
anchors.verticalCenter: rowLayout.verticalCenter
|
anchors.verticalCenter: rowLayout.verticalCenter
|
||||||
text: "bolt"
|
|
||||||
iconSize: Appearance.font.pixelSize.large
|
|
||||||
color: Appearance.m3colors.m3onSecondaryContainer
|
|
||||||
visible: opacity > 0 // Only show when charging
|
|
||||||
opacity: isCharging ? 1 : 0 // Keep opacity for visibility
|
|
||||||
|
|
||||||
Behavior on opacity {
|
Connections {
|
||||||
NumberAnimation {
|
target: root
|
||||||
duration: Appearance.animation.elementMove.duration
|
function onIsChargingChanged() {
|
||||||
easing.type: Appearance.animation.elementMove.type
|
if (isCharging) boltIconLoader.active = true
|
||||||
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceComponent: MaterialSymbol {
|
||||||
|
id: boltIcon
|
||||||
|
|
||||||
|
text: "bolt"
|
||||||
|
iconSize: Appearance.font.pixelSize.large
|
||||||
|
color: Appearance.m3colors.m3onSecondaryContainer
|
||||||
|
visible: opacity > 0 // Only show when charging
|
||||||
|
opacity: isCharging ? 1 : 0 // Keep opacity for visibility
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (!visible) boltIconLoader.active = false
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.animation.elementMove.duration
|
||||||
|
easing.type: Appearance.animation.elementMove.type
|
||||||
|
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user