From f15a31462f80a90e59b691952d09c46b83bf5bb5 Mon Sep 17 00:00:00 2001 From: Damian D'Souza Date: Fri, 10 Oct 2025 18:49:10 +0200 Subject: [PATCH] Battery: change panel labels --- Assets/Translations/en.json | 9 ++++----- Modules/Bar/Battery/BatteryPanel.qml | 14 +++++--------- Services/BatteryService.qml | 8 ++++---- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 0c6f052c..7d673f0d 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -1457,11 +1457,10 @@ "charging": "Charging.", "discharging": "Discharging.", "panel": { - "title": "Charging mode", - "full": "Full capacity", - "balanced": "Balanced", - "conservative": "Conservative", - "footer": "Charging threshold set to {limit}%" + "title": "Charge threshold", + "full": "Full capacity ({percentage}%)", + "balanced": "Balanced ({percentage}%)", + "lifespan": "Extended lifespan ({percentage}%)" } } } diff --git a/Modules/Bar/Battery/BatteryPanel.qml b/Modules/Bar/Battery/BatteryPanel.qml index 92ab067e..55e08e0c 100644 --- a/Modules/Bar/Battery/BatteryPanel.qml +++ b/Modules/Bar/Battery/BatteryPanel.qml @@ -11,7 +11,7 @@ NPanel { id: root preferredWidth: 300 - preferredHeight: 200 + preferredHeight: 210 panelKeyboardFocus: true property var optionsModel: [] @@ -27,7 +27,7 @@ NPanel { "icon": "battery-3" }, { "id": BatteryService.ChargingMode.Conservative, - "label": "battery.panel.conservative", + "label": "battery.panel.lifespan", "icon": "battery-2" }] root.optionsModel = newOptions @@ -50,12 +50,6 @@ NPanel { Layout.fillWidth: true spacing: Style.marginM * scaling - NIcon { - icon: optionsModel[BatteryService.chargingMode].icon - pointSize: Style.fontSizeXXL * scaling - color: Color.mPrimary - } - NText { text: I18n.tr("battery.panel.title") pointSize: Style.fontSizeL * scaling @@ -88,7 +82,9 @@ NPanel { NRadioButton { ButtonGroup.group: batteryGroup required property var modelData - text: I18n.tr(modelData.label) + text: I18n.tr(modelData.label, { + "percentage": BatteryService.getThresholdValue(modelData.id) + }) checked: BatteryService.chargingMode === modelData.id onClicked: { BatteryService.setChargingMode(modelData.id) diff --git a/Services/BatteryService.qml b/Services/BatteryService.qml index d8167b9f..739382f4 100644 --- a/Services/BatteryService.qml +++ b/Services/BatteryService.qml @@ -43,8 +43,8 @@ Singleton { } } - function getThresholdValue() { - switch (BatteryService.chargingMode) { + function getThresholdValue(chargingMode) { + switch (chargingMode) { case BatteryService.ChargingMode.Full: return "100" case BatteryService.ChargingMode.Balanced: @@ -69,7 +69,7 @@ Singleton { // uses toast messages so the flag is passed to supress notifs command.push("-q") - command.push(BatteryService.getThresholdValue()) + command.push(BatteryService.getThresholdValue(BatteryService.chargingMode)) BatteryService.hideSuccessToast = hideToast setterProcess.command = command @@ -94,7 +94,7 @@ Singleton { if (exitCode === 0) { Logger.log("BatteryService", "Battery threshold set successfully") if (!BatteryService.hideSuccessToast) { - ToastService.showNotice("Battery Manager", `Battery threshold set to ${BatteryService.getThresholdValue()}%`) + ToastService.showNotice("Battery Manager", `Battery threshold set to ${BatteryService.getThresholdValue(BatteryService.chargingMode)}%`) } } else if (exitCode === 2) { // Initial setup required - show toast and run installer