From f2462eb1b4a3f04b22e9f2b8c4992cefc0d49c62 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 9 Nov 2025 11:12:18 +0100 Subject: [PATCH] overlay: add battery level --- .../ii/modules/ii/bar/BarContent.qml | 2 +- .../ii/modules/ii/lock/LockSurface.qml | 2 +- .../ii/modules/ii/overlay/OverlayTaskbar.qml | 39 ++++++++++++++++++- .../ii/verticalBar/VerticalBarContent.qml | 4 +- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/dots/.config/quickshell/ii/modules/ii/bar/BarContent.qml b/dots/.config/quickshell/ii/modules/ii/bar/BarContent.qml index 186d76040..997e0209b 100644 --- a/dots/.config/quickshell/ii/modules/ii/bar/BarContent.qml +++ b/dots/.config/quickshell/ii/modules/ii/bar/BarContent.qml @@ -178,7 +178,7 @@ Item { // Bar content region } BatteryIndicator { - visible: (root.useShortenedForm < 2 && UPower.displayDevice.isLaptopBattery) + visible: (root.useShortenedForm < 2 && Battery.available) Layout.alignment: Qt.AlignVCenter } } diff --git a/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml b/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml index ff354ea70..da3e17627 100644 --- a/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml +++ b/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml @@ -288,7 +288,7 @@ MouseArea { opacity: root.toolbarOpacity IconAndTextPair { - visible: UPower.displayDevice.isLaptopBattery + visible: Battery.available icon: Battery.isCharging ? "bolt" : "battery_android_full" text: Math.round(Battery.percentage * 100) color: (Battery.isLow && !Battery.isCharging) ? Appearance.colors.colError : Appearance.colors.colOnSurfaceVariant diff --git a/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml b/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml index 65bb2a27e..232903474 100644 --- a/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml +++ b/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml @@ -49,8 +49,13 @@ Rectangle { } Separator {} - TimeWidget {} + Separator { + visible: Battery.available + } + BatteryWidget { + visible: Battery.available + } } component Separator: Rectangle { @@ -67,12 +72,44 @@ Rectangle { Layout.rightMargin: 6 text: DateTime.time + color: Appearance.colors.colOnSurface font { family: Appearance.font.family.numbers variableAxes: Appearance.font.variableAxes.numbers pixelSize: 22 } } + + component BatteryWidget: Row { + id: batteryWidget + Layout.alignment: Qt.AlignVCenter + Layout.leftMargin: 6 + Layout.rightMargin: 6 + spacing: 2 + property color colText: Battery.isLowAndNotCharging ? Appearance.colors.colError : Appearance.colors.colOnSurface + + MaterialSymbol { + id: boltIcon + anchors.verticalCenter: parent.verticalCenter + fill: 1 + text: Battery.isCharging ? "bolt" : "battery_android_full" + color: batteryWidget.colText + iconSize: 24 + animateChange: true + } + + StyledText { + id: batteryText + anchors.verticalCenter: parent.verticalCenter + text: Math.round(Battery.percentage * 100) + "%" + color: batteryWidget.colText + font { + family: Appearance.font.family.numbers + variableAxes: Appearance.font.variableAxes.numbers + pixelSize: 18 + } + } + } component WidgetButton: RippleButton { id: widgetButton diff --git a/dots/.config/quickshell/ii/modules/ii/verticalBar/VerticalBarContent.qml b/dots/.config/quickshell/ii/modules/ii/verticalBar/VerticalBarContent.qml index 554da8b74..d3326188e 100644 --- a/dots/.config/quickshell/ii/modules/ii/verticalBar/VerticalBarContent.qml +++ b/dots/.config/quickshell/ii/modules/ii/verticalBar/VerticalBarContent.qml @@ -148,11 +148,11 @@ Item { // Bar content region } HorizontalBarSeparator { - visible: UPower.displayDevice.isLaptopBattery + visible: Battery.available } BatteryIndicator { - visible: UPower.displayDevice.isLaptopBattery + visible: Battery.available Layout.fillWidth: true Layout.fillHeight: false }