mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
power: support automatic profile switching on battery change (#897)
This commit is contained in:
@@ -99,6 +99,43 @@ Item {
|
||||
SettingsData.set("fadeToLockGracePeriod", periodValues[index]);
|
||||
}
|
||||
}
|
||||
SettingsDropdownRow {
|
||||
id: powerProfileDropdown
|
||||
property var profileOptions: [I18n.tr("Don't Change"), Theme.getPowerProfileLabel(0), Theme.getPowerProfileLabel(1), Theme.getPowerProfileLabel(2)]
|
||||
property var profileValues: ["", "0", "1", "2"]
|
||||
|
||||
width: parent.width
|
||||
addHorizontalPadding: true
|
||||
text: I18n.tr("Switch to power profile")
|
||||
options: profileOptions
|
||||
|
||||
Connections {
|
||||
target: powerCategory
|
||||
function onCurrentIndexChanged() {
|
||||
const currentProfile = powerCategory.currentIndex === 0 ? SettingsData.acProfileName : SettingsData.batteryProfileName;
|
||||
const index = powerProfileDropdown.profileValues.indexOf(currentProfile);
|
||||
powerProfileDropdown.currentValue = powerProfileDropdown.profileOptions[index]
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
const currentProfile = powerCategory.currentIndex === 0 ? SettingsData.acProfileName : SettingsData.batteryProfileName;
|
||||
const index = profileValues.indexOf(currentProfile);
|
||||
currentValue = profileOptions[index]
|
||||
}
|
||||
|
||||
onValueChanged: value => {
|
||||
const index = profileOptions.indexOf(value);
|
||||
if (index >= 0) {
|
||||
const profileValue = profileValues[index];
|
||||
if (powerCategory.currentIndex === 0) {
|
||||
SettingsData.set("acProfileName", profileValue);
|
||||
} else {
|
||||
SettingsData.set("batteryProfileName", profileValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
|
||||
Reference in New Issue
Block a user