mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 23:42:51 -05:00
Add battery charge limit (#1151)
This commit is contained in:
@@ -261,6 +261,7 @@ Singleton {
|
|||||||
property int batterySuspendTimeout: 0
|
property int batterySuspendTimeout: 0
|
||||||
property int batterySuspendBehavior: SettingsData.SuspendBehavior.Suspend
|
property int batterySuspendBehavior: SettingsData.SuspendBehavior.Suspend
|
||||||
property string batteryProfileName: ""
|
property string batteryProfileName: ""
|
||||||
|
property int batteryChargeLimit: 100
|
||||||
property bool lockBeforeSuspend: false
|
property bool lockBeforeSuspend: false
|
||||||
property bool loginctlLockIntegration: true
|
property bool loginctlLockIntegration: true
|
||||||
property bool fadeToLockEnabled: false
|
property bool fadeToLockEnabled: false
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ var SPEC = {
|
|||||||
batterySuspendTimeout: { def: 0 },
|
batterySuspendTimeout: { def: 0 },
|
||||||
batterySuspendBehavior: { def: 0 },
|
batterySuspendBehavior: { def: 0 },
|
||||||
batteryProfileName: { def: "" },
|
batteryProfileName: { def: "" },
|
||||||
|
batteryChargeLimit: { def: 100 },
|
||||||
lockBeforeSuspend: { def: false },
|
lockBeforeSuspend: { def: false },
|
||||||
loginctlLockIntegration: { def: true },
|
loginctlLockIntegration: { def: true },
|
||||||
fadeToLockEnabled: { def: false },
|
fadeToLockEnabled: { def: false },
|
||||||
|
|||||||
@@ -503,6 +503,24 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsCard {
|
||||||
|
width: parent.width
|
||||||
|
iconName: "tune"
|
||||||
|
title: I18n.tr("Advanced")
|
||||||
|
collapsible: true
|
||||||
|
expanded: false
|
||||||
|
|
||||||
|
SettingsSliderRow {
|
||||||
|
text: I18n.tr("Battery Charge Limit")
|
||||||
|
description: I18n.tr("Note: this only changes the percentage, it does not actually limit charging.")
|
||||||
|
value: SettingsData.batteryChargeLimit
|
||||||
|
minimum: 50
|
||||||
|
maximum: 100
|
||||||
|
defaultValue: 100
|
||||||
|
onSliderValueChanged: newValue => SettingsData.set("batteryChargeLimit", newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ Singleton {
|
|||||||
property bool suppressSound: true
|
property bool suppressSound: true
|
||||||
property bool previousPluggedState: false
|
property bool previousPluggedState: false
|
||||||
|
|
||||||
|
readonly property var scale: 100 / SettingsData.batteryChargeLimit
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: startupTimer
|
id: startupTimer
|
||||||
interval: 500
|
interval: 500
|
||||||
@@ -43,14 +45,14 @@ Singleton {
|
|||||||
return 0;
|
return 0;
|
||||||
if (batteryCapacity === 0) {
|
if (batteryCapacity === 0) {
|
||||||
if (usePreferred && device && device.ready)
|
if (usePreferred && device && device.ready)
|
||||||
return Math.round(device.percentage * 100);
|
return Math.round(device.percentage * 100 * scale);
|
||||||
const validBatteries = batteries.filter(b => b.ready && b.percentage >= 0);
|
const validBatteries = batteries.filter(b => b.ready && b.percentage >= 0);
|
||||||
if (validBatteries.length === 0)
|
if (validBatteries.length === 0)
|
||||||
return 0;
|
return 0;
|
||||||
const avgPercentage = validBatteries.reduce((sum, b) => sum + b.percentage, 0) / validBatteries.length;
|
const avgPercentage = validBatteries.reduce((sum, b) => sum + b.percentage, 0) / validBatteries.length;
|
||||||
return Math.round(avgPercentage * 100);
|
return Math.round(avgPercentage * 100 * scale);
|
||||||
}
|
}
|
||||||
return Math.round((batteryEnergy * 100) / batteryCapacity);
|
return Math.round((batteryEnergy * 100) / batteryCapacity * scale);
|
||||||
}
|
}
|
||||||
readonly property bool isCharging: batteryAvailable && batteries.some(b => b.state === UPowerDeviceState.Charging)
|
readonly property bool isCharging: batteryAvailable && batteries.some(b => b.state === UPowerDeviceState.Charging)
|
||||||
|
|
||||||
|
|||||||
@@ -869,6 +869,12 @@
|
|||||||
"reference": "Modules/Settings/WidgetsTabSection.qml:838, Modules/Settings/WidgetsTab.qml:168, Modules/ControlCenter/Models/WidgetModel.qml:161, Modules/ControlCenter/Widgets/BatteryPill.qml:17",
|
"reference": "Modules/Settings/WidgetsTabSection.qml:838, Modules/Settings/WidgetsTab.qml:168, Modules/ControlCenter/Models/WidgetModel.qml:161, Modules/ControlCenter/Widgets/BatteryPill.qml:17",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"term": "Battery Charge Limit",
|
||||||
|
"context": "Battery Charge Limit",
|
||||||
|
"reference": "Modules/Settings/PowerSleepTab.qml:515",
|
||||||
|
"comment": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"term": "Battery and power management",
|
"term": "Battery and power management",
|
||||||
"context": "Battery and power management",
|
"context": "Battery and power management",
|
||||||
@@ -4799,6 +4805,12 @@
|
|||||||
"reference": "Modules/Settings/NetworkTab.qml:744",
|
"reference": "Modules/Settings/NetworkTab.qml:744",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"term": "Note: this only changes the displayed percentage, it does not actually limit charging.",
|
||||||
|
"context": "Note: this only changes the displayed percentage, it does not actually limit charging.",
|
||||||
|
"reference": "Modules/Settings/PowerSleepTab.qml:516",
|
||||||
|
"comment": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"term": "Notepad",
|
"term": "Notepad",
|
||||||
"context": "Notepad",
|
"context": "Notepad",
|
||||||
|
|||||||
@@ -1014,6 +1014,13 @@
|
|||||||
"reference": "",
|
"reference": "",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"term": "Battery Charge Limit",
|
||||||
|
"translation": "",
|
||||||
|
"context": "",
|
||||||
|
"reference": "",
|
||||||
|
"comment": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"term": "Battery and power management",
|
"term": "Battery and power management",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
@@ -5599,6 +5606,13 @@
|
|||||||
"reference": "",
|
"reference": "",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"term": "Note: this only changes the displayed percentage, it does not actually limit charging.",
|
||||||
|
"translation": "",
|
||||||
|
"context": "",
|
||||||
|
"reference": "",
|
||||||
|
"comment": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"term": "Notepad",
|
"term": "Notepad",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user