summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-06-05 18:14:53 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-06-05 18:14:53 +1000
commitd37b3926c8b4f4ff3b32f2bdb0c1ea5d0dc6ff23 (patch)
tree066612a5a56d33a943cad10159886b7dfa233b2a /modules
parentinternal: fix memory issue (diff)
downloadcaelestia-shell-d37b3926c8b4f4ff3b32f2bdb0c1ea5d0dc6ff23.tar.gz
caelestia-shell-d37b3926c8b4f4ff3b32f2bdb0c1ea5d0dc6ff23.tar.bz2
caelestia-shell-d37b3926c8b4f4ff3b32f2bdb0c1ea5d0dc6ff23.zip
bar: show power profile if no battery
Diffstat (limited to 'modules')
-rw-r--r--modules/bar/components/StatusIcons.qml38
-rw-r--r--modules/bar/popouts/Battery.qml5
2 files changed, 23 insertions, 20 deletions
diff --git a/modules/bar/components/StatusIcons.qml b/modules/bar/components/StatusIcons.qml
index c1589a2..d2dbe2f 100644
--- a/modules/bar/components/StatusIcons.qml
+++ b/modules/bar/components/StatusIcons.qml
@@ -14,7 +14,7 @@ Item {
clip: true
implicitWidth: Math.max(network.implicitWidth, bluetooth.implicitWidth, devices.implicitWidth, battery.implicitWidth)
- implicitHeight: network.implicitHeight + bluetooth.implicitHeight + bluetooth.anchors.topMargin + (repeater.count > 0 ? devices.implicitHeight + devices.anchors.topMargin : 0) + (battery.active ? battery.implicitHeight + battery.anchors.topMargin : 0)
+ implicitHeight: network.implicitHeight + bluetooth.implicitHeight + bluetooth.anchors.topMargin + (repeater.count > 0 ? devices.implicitHeight + devices.anchors.topMargin : 0) + battery.implicitHeight + battery.anchors.topMargin
MaterialIcon {
id: network
@@ -62,30 +62,34 @@ Item {
}
}
- Loader {
+ MaterialIcon {
id: battery
anchors.horizontalCenter: devices.horizontalCenter
anchors.top: repeater.count > 0 ? devices.bottom : bluetooth.bottom
anchors.topMargin: Appearance.spacing.small
- active: UPower.displayDevice.isLaptopBattery
- asynchronous: true
-
- sourceComponent: MaterialIcon {
- text: {
- const perc = UPower.displayDevice.percentage;
- const charging = !UPower.onBattery;
- if (perc === 1)
- return charging ? "battery_charging_full" : "battery_full";
- let level = Math.floor(perc * 7);
- if (charging && (level === 4 || level === 1))
- level--;
- return charging ? `battery_charging_${(level + 3) * 10}` : `battery_${level}_bar`;
+ animate: true
+ text: {
+ if (!UPower.displayDevice.isLaptopBattery) {
+ if (PowerProfiles.profile === PowerProfile.PowerSaver)
+ return "energy_savings_leaf";
+ if (PowerProfiles.profile === PowerProfile.Performance)
+ return "rocket_launch";
+ return "balance";
}
- color: !UPower.onBattery || UPower.displayDevice.percentage > 0.2 ? root.colour : Colours.palette.m3error
- fill: 1
+
+ const perc = UPower.displayDevice.percentage;
+ const charging = !UPower.onBattery;
+ if (perc === 1)
+ return charging ? "battery_charging_full" : "battery_full";
+ let level = Math.floor(perc * 7);
+ if (charging && (level === 4 || level === 1))
+ level--;
+ return charging ? `battery_charging_${(level + 3) * 10}` : `battery_${level}_bar`;
}
+ color: !UPower.onBattery || UPower.displayDevice.percentage > 0.2 ? root.colour : Colours.palette.m3error
+ fill: 1
}
Behavior on implicitWidth {
diff --git a/modules/bar/popouts/Battery.qml b/modules/bar/popouts/Battery.qml
index 7e81cb9..90a6181 100644
--- a/modules/bar/popouts/Battery.qml
+++ b/modules/bar/popouts/Battery.qml
@@ -12,11 +12,10 @@ Column {
spacing: Appearance.spacing.normal
StyledText {
- text: qsTr("Remaining: %1%").arg(Math.round(UPower.displayDevice.percentage * 100))
+ text: UPower.displayDevice.isLaptopBattery ? qsTr("Remaining: %1%").arg(Math.round(UPower.displayDevice.percentage * 100)) : qsTr("No battery detected")
}
StyledText {
-
function formatSeconds(s: int, fallback: string): string {
const day = Math.floor(s / 86400);
const hr = Math.floor(s / 3600) % 60;
@@ -33,7 +32,7 @@ Column {
return comps.join(", ") || fallback;
}
- text: qsTr("Time %1: %2").arg(UPower.onBattery ? "remaining" : "until charged").arg(UPower.onBattery ? formatSeconds(UPower.displayDevice.timeToEmpty, "Calculating...") : formatSeconds(UPower.displayDevice.timeToFull, "Fully charged!"))
+ text: UPower.displayDevice.isLaptopBattery ? qsTr("Time %1: %2").arg(UPower.onBattery ? "remaining" : "until charged").arg(UPower.onBattery ? formatSeconds(UPower.displayDevice.timeToEmpty, "Calculating...") : formatSeconds(UPower.displayDevice.timeToFull, "Fully charged!")) : qsTr("Power profile: %1").arg(PowerProfile.toString(PowerProfiles.profile))
}
StyledRect {