mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -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
|
root.isLowBattery = root.batteryLevel <= 20
|
||||||
}
|
}
|
||||||
} else if (line.includes('state:') || line.includes('status:')) {
|
} 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.batteryStatus = "Charging"
|
||||||
root.isCharging = true
|
root.isCharging = true
|
||||||
} else if (line.includes('discharging')) {
|
console.log("Battery is charging")
|
||||||
|
} else if (statusPart === 'discharging') {
|
||||||
root.batteryStatus = "Discharging"
|
root.batteryStatus = "Discharging"
|
||||||
root.isCharging = false
|
root.isCharging = false
|
||||||
} else if (line.includes('full')) {
|
console.log("Battery is discharging")
|
||||||
|
} else if (statusPart === 'full') {
|
||||||
root.batteryStatus = "Full"
|
root.batteryStatus = "Full"
|
||||||
root.isCharging = false
|
root.isCharging = false
|
||||||
} else if (line.includes('not charging')) {
|
console.log("Battery is full")
|
||||||
|
} else if (statusPart === 'not charging') {
|
||||||
root.batteryStatus = "Not charging"
|
root.batteryStatus = "Not charging"
|
||||||
root.isCharging = false
|
root.isCharging = false
|
||||||
|
console.log("Battery is not charging")
|
||||||
} else {
|
} else {
|
||||||
root.batteryStatus = "Unknown"
|
root.batteryStatus = statusPart.charAt(0).toUpperCase() + statusPart.slice(1) || "Unknown"
|
||||||
root.isCharging = false
|
root.isCharging = false
|
||||||
|
console.log("Battery status unknown:", statusPart)
|
||||||
}
|
}
|
||||||
} else if (line.includes('time to')) {
|
} else if (line.includes('time to')) {
|
||||||
let match = line.match(/(\d+):(\d+)/)
|
let match = line.match(/(\d+):(\d+)/)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Rectangle {
|
|||||||
|
|
||||||
property bool batteryPopupVisible: false
|
property bool batteryPopupVisible: false
|
||||||
|
|
||||||
width: 48
|
width: 70 // Increased width to accommodate percentage text
|
||||||
height: 32
|
height: 32
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: batteryArea.containsMouse || batteryPopupVisible ?
|
color: batteryArea.containsMouse || batteryPopupVisible ?
|
||||||
@@ -16,25 +16,44 @@ Rectangle {
|
|||||||
Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.08)
|
Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.08)
|
||||||
visible: BatteryService.batteryAvailable
|
visible: BatteryService.batteryAvailable
|
||||||
|
|
||||||
// Battery icon - Material Design icons already show level visually
|
Row {
|
||||||
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
|
|
||||||
}
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
spacing: 4
|
||||||
|
|
||||||
// Subtle pulse animation for charging
|
// Battery icon - Material Design icons already show level visually
|
||||||
SequentialAnimation on opacity {
|
Text {
|
||||||
running: BatteryService.isCharging
|
text: BatteryService.getBatteryIcon()
|
||||||
loops: Animation.Infinite
|
font.family: Theme.iconFont
|
||||||
NumberAnimation { to: 0.6; duration: 1000; easing.type: Easing.InOutQuad }
|
font.pixelSize: Theme.iconSize - 6
|
||||||
NumberAnimation { to: 1.0; duration: 1000; easing.type: Easing.InOutQuad }
|
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 {
|
||||||
text: "power_settings_new"
|
text: "power_settings_new"
|
||||||
font.family: Theme.iconFont
|
font.family: Theme.iconFont
|
||||||
font.pixelSize: Theme.iconSize
|
font.pixelSize: Theme.iconSize - 6
|
||||||
color: powerArea.containsMouse || root.powerMenuVisible ? Theme.error : Theme.surfaceText
|
color: powerArea.containsMouse || root.powerMenuVisible ? Theme.error : Theme.surfaceText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user