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
+6
View File
@@ -20,6 +20,8 @@ Item {
property bool oppositeDirection: false
property bool hovered: false
property bool rotateText: false
property color customBackgroundColor: Qt.rgba(0, 0, 0, 0)
property color customTextIconColor: Qt.rgba(0, 0, 0, 0)
readonly property string barPosition: Settings.data.bar.position
readonly property bool isVerticalBar: barPosition === "left" || barPosition === "right"
@@ -57,6 +59,8 @@ Item {
hovered: root.hovered
density: root.density
rotateText: root.rotateText
customBackgroundColor: root.customBackgroundColor
customTextIconColor: root.customTextIconColor
onShown: root.shown()
onHidden: root.hidden()
onEntered: root.entered()
@@ -82,6 +86,8 @@ Item {
oppositeDirection: root.oppositeDirection
hovered: root.hovered
density: root.density
customBackgroundColor: root.customBackgroundColor
customTextIconColor: root.customTextIconColor
onShown: root.shown()
onHidden: root.hidden()
onEntered: root.entered()
+5 -3
View File
@@ -20,6 +20,8 @@ Item {
property bool forceClose: false
property bool oppositeDirection: false
property bool hovered: false
property color customBackgroundColor: Qt.rgba(0, 0, 0, 0)
property color customTextIconColor: Qt.rgba(0, 0, 0, 0)
// Effective shown state (true if hovered/animated open or forced)
readonly property bool revealed: !forceClose && (forceOpen || showPill)
@@ -78,7 +80,7 @@ Item {
width: root.width
height: pillHeight
radius: halfPillHeight
color: hovered ? Color.mHover : Style.capsuleColor
color: hovered ? (customBackgroundColor.a > 0 ? Qt.lighter(customBackgroundColor, 1.1) : Color.mHover) : (customBackgroundColor.a > 0 ? customBackgroundColor : Style.capsuleColor)
anchors.verticalCenter: parent.verticalCenter
readonly property int halfPillHeight: Math.round(pillHeight * 0.5)
@@ -129,7 +131,7 @@ Item {
pointSize: textSize
applyUiScale: false
font.weight: Style.fontWeightBold
color: hovered ? Color.mOnHover : (forceOpen ? Color.mOnSurface : Color.mPrimary)
color: hovered ? (customTextIconColor.a > 0 ? customTextIconColor : Color.mOnHover) : (customTextIconColor.a > 0 ? customTextIconColor : (forceOpen ? Color.mOnSurface : Color.mPrimary))
visible: revealed
}
@@ -163,7 +165,7 @@ Item {
icon: root.icon
pointSize: iconSize
applyUiScale: false
color: hovered ? Color.mOnHover : Color.mOnSurface
color: hovered ? (customTextIconColor.a > 0 ? customTextIconColor : Color.mOnHover) : (customTextIconColor.a > 0 ? customTextIconColor : Color.mOnSurface)
// Center horizontally
x: (iconCircle.width - width) / 2
// Center vertically accounting for font metrics
+5 -3
View File
@@ -21,6 +21,8 @@ Item {
property bool oppositeDirection: false
property bool hovered: false
property bool rotateText: false
property color customBackgroundColor: Qt.rgba(0, 0, 0, 0)
property color customTextIconColor: Qt.rgba(0, 0, 0, 0)
// Bar position detection for pill direction
readonly property string barPosition: Settings.data.bar.position
@@ -91,7 +93,7 @@ Item {
width: buttonSize
height: revealed ? (buttonSize + maxPillHeight - pillOverlap) : buttonSize
radius: halfButtonSize
color: hovered ? Color.mHover : Style.capsuleColor
color: hovered ? (customBackgroundColor.a > 0 ? Qt.lighter(customBackgroundColor, 1.1) : Color.mHover) : (customBackgroundColor.a > 0 ? customBackgroundColor : Style.capsuleColor)
readonly property int halfButtonSize: Math.round(buttonSize * 0.5)
@@ -139,7 +141,7 @@ Item {
font.weight: Style.fontWeightMedium
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: hovered ? Color.mOnHover : (forceOpen ? Color.mOnSurface : Color.mPrimary)
color: hovered ? (customTextIconColor.a > 0 ? customTextIconColor : Color.mOnHover) : (customTextIconColor.a > 0 ? customTextIconColor : (forceOpen ? Color.mOnSurface : Color.mPrimary))
visible: revealed
function getVerticalCenterOffset() {
@@ -189,7 +191,7 @@ Item {
icon: root.icon
pointSize: iconSize
applyUiScale: false
color: hovered ? Color.mOnHover : Color.mOnSurface
color: hovered ? (customTextIconColor.a > 0 ? customTextIconColor : Color.mOnHover) : (customTextIconColor.a > 0 ? customTextIconColor : Color.mOnSurface)
// Center horizontally
x: (iconCircle.width - width) / 2
// Center vertically accounting for font metrics