mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
Fixed battery status and adjusted battery & power icon sizes
This commit is contained in:
@@ -115,21 +115,29 @@ Singleton {
|
||||
root.isLowBattery = root.batteryLevel <= 20
|
||||
}
|
||||
} else if (line.includes('state:') || line.includes('status:')) {
|
||||
if (line.includes('charging')) {
|
||||
let statusPart = line.split(':')[1]?.trim().toLowerCase() || line
|
||||
console.log("Raw battery status line:", line, "extracted status:", statusPart)
|
||||
|
||||
if (statusPart === 'charging') {
|
||||
root.batteryStatus = "Charging"
|
||||
root.isCharging = true
|
||||
} else if (line.includes('discharging')) {
|
||||
console.log("Battery is charging")
|
||||
} else if (statusPart === 'discharging') {
|
||||
root.batteryStatus = "Discharging"
|
||||
root.isCharging = false
|
||||
} else if (line.includes('full')) {
|
||||
console.log("Battery is discharging")
|
||||
} else if (statusPart === 'full') {
|
||||
root.batteryStatus = "Full"
|
||||
root.isCharging = false
|
||||
} else if (line.includes('not charging')) {
|
||||
console.log("Battery is full")
|
||||
} else if (statusPart === 'not charging') {
|
||||
root.batteryStatus = "Not charging"
|
||||
root.isCharging = false
|
||||
console.log("Battery is not charging")
|
||||
} else {
|
||||
root.batteryStatus = "Unknown"
|
||||
root.batteryStatus = statusPart.charAt(0).toUpperCase() + statusPart.slice(1) || "Unknown"
|
||||
root.isCharging = false
|
||||
console.log("Battery status unknown:", statusPart)
|
||||
}
|
||||
} else if (line.includes('time to')) {
|
||||
let match = line.match(/(\d+):(\d+)/)
|
||||
|
||||
@@ -8,7 +8,7 @@ Rectangle {
|
||||
|
||||
property bool batteryPopupVisible: false
|
||||
|
||||
width: 48
|
||||
width: 70 // Increased width to accommodate percentage text
|
||||
height: 32
|
||||
radius: Theme.cornerRadius
|
||||
color: batteryArea.containsMouse || batteryPopupVisible ?
|
||||
@@ -16,25 +16,44 @@ Rectangle {
|
||||
Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.08)
|
||||
visible: BatteryService.batteryAvailable
|
||||
|
||||
// Battery icon - Material Design icons already show level visually
|
||||
Text {
|
||||
text: BatteryService.getBatteryIcon()
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize
|
||||
color: {
|
||||
if (!BatteryService.batteryAvailable) return Theme.surfaceText
|
||||
if (BatteryService.isLowBattery && !BatteryService.isCharging) return Theme.error
|
||||
if (BatteryService.isCharging) return Theme.primary
|
||||
return Theme.surfaceText
|
||||
}
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
// Subtle pulse animation for charging
|
||||
SequentialAnimation on opacity {
|
||||
running: BatteryService.isCharging
|
||||
loops: Animation.Infinite
|
||||
NumberAnimation { to: 0.6; duration: 1000; easing.type: Easing.InOutQuad }
|
||||
NumberAnimation { to: 1.0; duration: 1000; easing.type: Easing.InOutQuad }
|
||||
// Battery icon - Material Design icons already show level visually
|
||||
Text {
|
||||
text: BatteryService.getBatteryIcon()
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize - 6
|
||||
color: {
|
||||
if (!BatteryService.batteryAvailable) return Theme.surfaceText
|
||||
if (BatteryService.isLowBattery && !BatteryService.isCharging) return Theme.error
|
||||
if (BatteryService.isCharging) return Theme.primary
|
||||
return Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
// Subtle pulse animation for charging
|
||||
SequentialAnimation on opacity {
|
||||
running: BatteryService.isCharging
|
||||
loops: Animation.Infinite
|
||||
NumberAnimation { to: 0.6; duration: 1000; easing.type: Easing.InOutQuad }
|
||||
NumberAnimation { to: 1.0; duration: 1000; easing.type: Easing.InOutQuad }
|
||||
}
|
||||
}
|
||||
|
||||
// Battery percentage text
|
||||
Text {
|
||||
text: BatteryService.batteryLevel + "%"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: {
|
||||
if (!BatteryService.batteryAvailable) return Theme.surfaceText
|
||||
if (BatteryService.isLowBattery && !BatteryService.isCharging) return Theme.error
|
||||
if (BatteryService.isCharging) return Theme.primary
|
||||
return Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Rectangle {
|
||||
Text {
|
||||
text: "power_settings_new"
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize
|
||||
font.pixelSize: Theme.iconSize - 6
|
||||
color: powerArea.containsMouse || root.powerMenuVisible ? Theme.error : Theme.surfaceText
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user