Add option for enable/disable apply AC/Bat policy on change

This commit is contained in:
Luke D. Jones
2024-05-12 11:55:34 +12:00
parent 92ca7bc70d
commit 6c7e1a6467
9 changed files with 150 additions and 81 deletions

View File

@@ -43,8 +43,12 @@ export global SystemPageData {
callback set_throttle_policy_linked_epp(bool);
in-out property <int> throttle_policy_on_ac: 0;
callback set_throttle_policy_on_ac(int);
in-out property <bool> change_throttle_policy_on_ac: true;
callback set_change_throttle_policy_on_ac(bool);
in-out property <int> throttle_policy_on_battery: 0;
callback set_throttle_policy_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true;
callback set_change_throttle_policy_on_battery(bool);
in-out property <bool> panel_od;
callback set_panel_od(bool);
in-out property <bool> boot_sound;
@@ -340,23 +344,45 @@ export component PageSystem inherits Rectangle {
text: @tr("Throttle Policy for power state");
}
SystemDropdown {
text: @tr("Throttle Policy on Battery");
current_index <=> SystemPageData.throttle_policy_on_battery;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery];
model <=> SystemPageData.throttle_policy_choices;
selected => {
SystemPageData.set_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery)
HorizontalLayout {
spacing: 10px;
SystemDropdown {
text: @tr("Throttle Policy on Battery");
current_index <=> SystemPageData.throttle_policy_on_battery;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery];
model <=> SystemPageData.throttle_policy_choices;
selected => {
SystemPageData.set_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery)
}
}
SystemToggle {
text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_battery;
toggled => {
SystemPageData.set_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery);
}
}
}
SystemDropdown {
text: @tr("Throttle Policy on AC");
current_index <=> SystemPageData.throttle_policy_on_ac;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac];
model <=> SystemPageData.throttle_policy_choices;
selected => {
SystemPageData.set_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac)
HorizontalLayout {
spacing: 10px;
SystemDropdown {
text: @tr("Throttle Policy on AC");
current_index <=> SystemPageData.throttle_policy_on_ac;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac];
model <=> SystemPageData.throttle_policy_choices;
selected => {
SystemPageData.set_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac)
}
}
SystemToggle {
text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_ac;
toggled => {
SystemPageData.set_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac);
}
}
}
}

View File

@@ -5,7 +5,8 @@ export component RogItem inherits Rectangle {
border-color: Palette.border;
border-width: 3px;
border-radius: 10px;
min-height: 46px;
min-height: 48px;
max-height: 56px;
}
export component SystemSlider inherits RogItem {
@@ -54,6 +55,7 @@ export component SystemToggle inherits RogItem {
in-out property <bool> checked;
callback toggled(bool);
HorizontalLayout {
spacing: 6px;
HorizontalLayout {
alignment: LayoutAlignment.start;
padding-left: 10px;
@@ -195,7 +197,7 @@ export component PopupNotification {
}
}
public function show() {
public function show(){
_p.show();
}
}