Files
asusctl/rog-control-center/ui/pages/system.slint
2025-01-19 12:02:22 +13:00

473 lines
19 KiB
Plaintext

import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint";
export struct AttrMinMax {
min: int,
max: int,
val: float,
}
export struct AttrPossible {
range: [int],
val: int,
}
export global SystemPageData {
in-out property <float> charge_control_end_threshold: 30;
callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> throttle_thermal_policy: 0;
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
callback cb_throttle_thermal_policy(int);
in-out property <[string]> energy_performance_choices: [
@tr("Default"),
@tr("Performance"),
@tr("BalancePerformance"),
@tr("BalancePower"),
@tr("Power")
];
in-out property <int> throttle_balanced_epp: 0;
callback cb_throttle_balanced_epp(int);
in-out property <int> throttle_performance_epp: 0;
callback cb_throttle_performance_epp(int);
in-out property <int> throttle_quiet_epp: 0;
callback cb_throttle_quiet_epp(int);
// if the EPP should change with throttle
in-out property <bool> throttle_policy_linked_epp: true;
callback cb_throttle_policy_linked_epp(bool);
in-out property <int> throttle_policy_on_ac: 0;
callback cb_throttle_policy_on_ac(int);
in-out property <bool> change_throttle_policy_on_ac: true;
callback cb_change_throttle_policy_on_ac(bool);
in-out property <int> throttle_policy_on_battery: 0;
callback cb_throttle_policy_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true;
callback cb_change_throttle_policy_on_battery(bool);
//
in-out property <int> panel_overdrive;
callback cb_panel_overdrive(int);
in-out property <int> boot_sound;
callback cb_boot_sound(int);
in-out property <int> mini_led_mode;
callback cb_mini_led_mode(int);
in-out property <bool> asus_armoury_loaded: false;
in-out property <AttrMinMax> ppt_pl1_spl: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_pl1_spl(int);
callback cb_default_ppt_pl1_spl();
in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_pl2_sppt(int);
callback cb_default_ppt_pl2_sppt();
in-out property <AttrMinMax> ppt_pl3_fppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_pl3_fppt(int);
callback cb_default_ppt_pl3_fppt();
in-out property <AttrMinMax> ppt_fppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_fppt(int);
callback cb_default_ppt_fppt();
in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_apu_sppt(int);
callback cb_default_ppt_apu_sppt();
in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_platform_sppt(int);
callback cb_default_ppt_platform_sppt();
in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0,
max: 30,
val: 5,
};
callback cb_nv_dynamic_boost(int);
callback cb_default_nv_dynamic_boost();
in-out property <AttrMinMax> nv_temp_target: {
min: 0,
max: 80,
val: 75,
};
callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target();
}
export component PageSystem inherits Rectangle {
property <bool> show_fade_cover: false;
property <bool> show_throttle_advanced: false;
clip: true;
padding: 8px;
ScrollView {
VerticalLayout {
padding: 10px;
spacing: 10px;
Rectangle {
background: Palette.alternate-background;
border-color: Palette.accent-background;
border-width: 3px;
border-radius: 10px;
height: 40px;
Text {
font-size: 18px;
color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("Power settings");
}
}
if SystemPageData.charge_control_end_threshold != -1: SystemSlider {
text: @tr("Charge limit");
minimum: 20;
maximum: 100;
value <=> SystemPageData.charge_control_end_threshold;
released => {
SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
}
}
if SystemPageData.throttle_thermal_policy != -1: HorizontalLayout {
spacing: 10px;
SystemDropdown {
text: @tr("Throttle Policy");
current_index <=> SystemPageData.throttle_thermal_policy;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy];
model <=> SystemPageData.throttle_policy_choices;
selected => {
SystemPageData.cb_throttle_thermal_policy(SystemPageData.throttle_thermal_policy)
}
}
Button {
text: @tr("Advanced");
clicked => {
root.show_fade_cover = true;
root.show_throttle_advanced = true;
}
}
}
Rectangle {
background: Palette.alternate-background;
border-color: Palette.accent-background;
border-width: 3px;
border-radius: 10px;
height: 40px;
Text {
font-size: 18px;
color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("Armoury settings");
}
}
HorizontalBox {
padding: 0px;
spacing: 10px;
if SystemPageData.panel_overdrive != -1: SystemToggleInt {
text: @tr("Panel Overdrive");
checked_int <=> SystemPageData.panel_overdrive;
toggled => {
SystemPageData.cb_panel_overdrive(SystemPageData.panel_overdrive)
}
}
if SystemPageData.mini_led_mode != -1: SystemToggleInt {
text: @tr("MiniLED Mode");
checked_int <=> SystemPageData.mini_led_mode;
toggled => {
SystemPageData.cb_mini_led_mode(SystemPageData.mini_led_mode)
}
}
if SystemPageData.boot_sound != -1: SystemToggleInt {
text: @tr("POST boot sound");
checked_int <=> SystemPageData.boot_sound;
toggled => {
SystemPageData.cb_boot_sound(SystemPageData.boot_sound)
}
}
}
if !SystemPageData.asus_armoury_loaded: Rectangle {
VerticalBox {
Text {
text: @tr("The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
}
}
if SystemPageData.ppt_pl1_spl.val != -1: Rectangle {
height: 32px;
Text {
font-size: 16px;
text: @tr("ppt_warning" => "The following settings may not be safe, please take care.");
}
}
if SystemPageData.ppt_pl1_spl.val != -1: SystemSlider {
text: @tr("ppt_pl1_spl" => "PL1, sustained power limit");
minimum: SystemPageData.ppt_pl1_spl.min;
maximum: SystemPageData.ppt_pl1_spl.max;
value: SystemPageData.ppt_pl1_spl.val;
released => {
SystemPageData.ppt_pl1_spl.val = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value))
}
}
if SystemPageData.ppt_pl2_sppt.val != -1: SystemSlider {
text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit");
minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: SystemPageData.ppt_pl2_sppt.max;
value: SystemPageData.ppt_pl2_sppt.val;
released => {
SystemPageData.ppt_pl2_sppt.val = self.value;
SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value))
}
}
if SystemPageData.ppt_pl3_fppt.val != -1: SystemSlider {
text: @tr("ppt_pl3_fppt" => "PL3, Fast Power Limit");
minimum: SystemPageData.ppt_pl3_fppt.min;
maximum: SystemPageData.ppt_pl3_fppt.max;
value: SystemPageData.ppt_pl3_fppt.val;
released => {
SystemPageData.ppt_pl3_fppt.val = self.value;
SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value))
}
}
if SystemPageData.ppt_fppt.val != -1: SystemSlider {
text: @tr("ppt_fppt" => "FPPT, Fast Power Limit");
minimum: SystemPageData.ppt_fppt.min;
maximum: SystemPageData.ppt_fppt.max;
value: SystemPageData.ppt_fppt.val;
released => {
SystemPageData.ppt_fppt.val = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value))
}
}
if SystemPageData.ppt_apu_sppt.val != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit");
minimum: SystemPageData.ppt_apu_sppt.min;
maximum: SystemPageData.ppt_apu_sppt.max;
value: SystemPageData.ppt_apu_sppt.val;
released => {
SystemPageData.ppt_apu_sppt.val = self.value;
SystemPageData.cb_ppt_apu_sppt(Math.round(self.value))
}
}
if SystemPageData.ppt_platform_sppt.val != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Slow package power tracking limit");
minimum: SystemPageData.ppt_platform_sppt.min;
maximum: SystemPageData.ppt_platform_sppt.max;
value: SystemPageData.ppt_platform_sppt.val;
released => {
SystemPageData.ppt_platform_sppt.val = self.value;
SystemPageData.cb_ppt_platform_sppt(Math.round(self.value))
}
}
if SystemPageData.nv_dynamic_boost.val != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "dGPU boost overclock");
minimum: SystemPageData.nv_dynamic_boost.min;
maximum: SystemPageData.nv_dynamic_boost.max;
value: SystemPageData.nv_dynamic_boost.val;
released => {
SystemPageData.nv_dynamic_boost.val = self.value;
SystemPageData.cb_nv_dynamic_boost(Math.round(self.value))
}
}
if SystemPageData.nv_temp_target.val != -1: SystemSlider {
text: @tr("nv_temp_target" => "dGPU temperature max");
minimum: SystemPageData.nv_temp_target.min;
maximum: SystemPageData.nv_temp_target.max;
value: SystemPageData.nv_temp_target.val;
released => {
SystemPageData.nv_temp_target.val = self.value;
SystemPageData.cb_nv_temp_target(Math.round(self.value))
}
}
}
}
if root.show_fade_cover: Rectangle {
width: 100%;
height: 100%;
background: Palette.background;
opacity: 0.9;
TouchArea {
height: 100%;
width: 100%;
clicked => {
// toolbar-dropdown.close();
if (root.show_throttle_advanced) {
root.show_throttle_advanced = false;
}
root.show_fade_cover = false;
}
}
}
if root.show_throttle_advanced: Rectangle {
width: 100%;
height: 100%;
opacity: 1;
ScrollView {
VerticalLayout {
padding: 50px;
padding-top: 5px;
padding-bottom: 100px;
spacing: 10px;
GroupBox {
VerticalBox {
spacing: 10px;
Text {
font-size: 18px;
horizontal-alignment: TextHorizontalAlignment.center;
vertical-alignment: TextVerticalAlignment.center;
text: @tr("Energy Performance Preference linked to Throttle Policy");
}
SystemToggle {
text: @tr("Change EPP based on Throttle Policy");
checked <=> SystemPageData.throttle_policy_linked_epp;
toggled => {
SystemPageData.cb_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp)
}
}
SystemDropdown {
text: @tr("EPP for Balanced Policy");
current_index <=> SystemPageData.throttle_balanced_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp];
model <=> SystemPageData.energy_performance_choices;
selected => {
SystemPageData.cb_throttle_balanced_epp(SystemPageData.throttle_balanced_epp)
}
}
SystemDropdown {
text: @tr("EPP for Performance Policy");
current_index <=> SystemPageData.throttle_performance_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp];
model <=> SystemPageData.energy_performance_choices;
selected => {
SystemPageData.cb_throttle_performance_epp(SystemPageData.throttle_performance_epp)
}
}
SystemDropdown {
text: @tr("EPP for Quiet Policy");
current_index <=> SystemPageData.throttle_quiet_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp];
model <=> SystemPageData.energy_performance_choices;
selected => {
SystemPageData.cb_throttle_quiet_epp(SystemPageData.throttle_quiet_epp)
}
}
}
}
GroupBox {
VerticalBox {
spacing: 10px;
Text {
font-size: 18px;
horizontal-alignment: TextHorizontalAlignment.center;
vertical-alignment: TextVerticalAlignment.center;
text: @tr("Throttle Policy for power state");
}
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.cb_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery)
}
}
SystemToggle {
text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_battery;
toggled => {
SystemPageData.cb_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery);
}
}
}
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.cb_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac)
}
}
SystemToggle {
text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_ac;
toggled => {
SystemPageData.cb_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac);
}
}
}
}
}
}
}
Button {
x: root.width - self.width - 6px;
y: 6px;
text: "X";
height: 40px;
clicked => {
root.show_throttle_advanced = false;
root.show_fade_cover = false;
}
}
}
}