import QtQuick import Quickshell import "." as M import "../services" as S import "../applets" as C M.BarSection { id: root spacing: S.Theme.moduleSpacing opacity: S.Modules.battery.enable && S.BatteryService.available ? 1 : 0 visible: opacity > 0 tooltip: "" property real _blinkOpacity: 1 SequentialAnimation { running: S.BatteryService.critical loops: Animation.Infinite NumberAnimation { target: root property: "_blinkOpacity" to: 0.45 duration: 400 easing.type: Easing.InOutQuad } NumberAnimation { target: root property: "_blinkOpacity" to: 1 duration: 400 easing.type: Easing.InOutQuad } onRunningChanged: if (!running) root._blinkOpacity = 1 } // Panel state property bool _pinned: false readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered readonly property bool _showPanel: _anyHover || _pinned on_AnyHoverChanged: { if (_anyHover) _unpinTimer.stop(); else if (_pinned) _unpinTimer.start(); } Timer { id: _unpinTimer interval: 500 onTriggered: root._pinned = false } // Bar widgets M.BarIcon { icon: { if (S.BatteryService.charging) return "\uDB80\uDC84"; const icons = ["\uDB80\uDC8E", "\uDB80\uDC7A", "\uDB80\uDC7B", "\uDB80\uDC7C", "\uDB80\uDC7D", "\uDB80\uDC7E", "\uDB80\uDC7F", "\uDB80\uDC80", "\uDB80\uDC81", "\uDB80\uDC82", "\uDB85\uDFE2"]; return icons[Math.min(10, Math.floor(S.BatteryService.percent / 10))]; } color: S.BatteryService.stateColor opacity: root._blinkOpacity font.pixelSize: S.Theme.fontSize + 2 anchors.verticalCenter: parent.verticalCenter TapHandler { onTapped: root._pinned = !root._pinned } } M.BarLabel { label: Math.round(S.BatteryService.percent) + "%" minText: "100%" color: S.BatteryService.stateColor opacity: root._blinkOpacity anchors.verticalCenter: parent.verticalCenter TapHandler { onTapped: root._pinned = !root._pinned } } // Hover panel M.HoverPanel { id: hoverPanel showPanel: root._showPanel screen: QsWindow.window?.screen ?? null anchorItem: root accentColor: root.accentColor panelNamespace: "nova-battery" panelTitle: "Battery" contentWidth: 240 C.BatteryApplet { width: hoverPanel.contentWidth active: root._showPanel accentColor: root.accentColor } } }