Battery: add visual indicator for low battery (same as SysMon)

This commit is contained in:
Ly-sec
2025-11-21 13:27:03 +01:00
parent 5ed4c97ee5
commit e46c9cdf0e
4 changed files with 20 additions and 7 deletions
+4 -1
View File
@@ -34,10 +34,11 @@ Item {
readonly property bool isBarVertical: Settings.data.bar.position === "left" || Settings.data.bar.position === "right"
readonly property string displayMode: widgetSettings.displayMode !== undefined ? widgetSettings.displayMode : widgetMetadata.displayMode
readonly property real warningThreshold: widgetSettings.warningThreshold !== undefined ? widgetSettings.warningThreshold : widgetMetadata.warningThreshold
readonly property bool isLowBattery: !charging && percent <= warningThreshold
// Test mode
readonly property bool testMode: false
readonly property int testPercent: 100
readonly property int testPercent: 15
readonly property bool testCharging: false
// Main properties
@@ -120,6 +121,8 @@ Item {
autoHide: false
forceOpen: isReady && (testMode || battery.isLaptopBattery) && displayMode === "alwaysShow"
forceClose: displayMode === "alwaysHide" || !isReady || (!testMode && !battery.isLaptopBattery)
customBackgroundColor: isLowBattery ? Color.mError : Qt.rgba(0, 0, 0, 0)
customTextIconColor: isLowBattery ? Color.mOnError : Qt.rgba(0, 0, 0, 0)
tooltipText: {
let lines = [];
if (testMode) {