Files
asusctl/rog-control-center/ui/pages/system.slint
2025-03-03 18:22:26 +13:00

569 lines
25 KiB
Plaintext

import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox, StandardButton} from "std-widgets.slint";
export struct AttrMinMax {
min: int,
max: int,
current: float,
}
export struct AttrPossible {
range: [int],
current: int,
}
export global SystemPageData {
in-out property <bool> charge_control_enabled: true;
in-out property <float> charge_control_end_threshold: 30;
callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> platform_profile: 0;
in-out property <[string]> platform_profile_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet"), @tr("LowPower")];
// The dropdown list index is used to index in to this and find the correct
// value for platform profile
in-out property <[int]> platform_profile_indexes: [0, 1, 2, 3];
callback cb_platform_profile(int);
in-out property <[string]> energy_performance_choices: [
@tr("Default"),
@tr("Performance"),
@tr("BalancePerformance"),
@tr("BalancePower"),
@tr("Power")
];
in-out property <int> profile_balanced_epp: 0;
callback cb_profile_balanced_epp(int);
in-out property <int> profile_performance_epp: 0;
callback cb_profile_performance_epp(int);
in-out property <int> profile_quiet_epp: 0;
callback cb_profile_quiet_epp(int);
// if the EPP should change with throttle
in-out property <bool> platform_profile_linked_epp: true;
callback cb_platform_profile_linked_epp(bool);
in-out property <int> platform_profile_on_ac: 0;
callback cb_platform_profile_on_ac(int);
in-out property <bool> change_platform_profile_on_ac: true;
callback cb_change_platform_profile_on_ac(bool);
in-out property <int> platform_profile_on_battery: 0;
callback cb_platform_profile_on_battery(int);
in-out property <bool> change_platform_profile_on_battery: true;
callback cb_change_platform_profile_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,
current: 20,
};
callback cb_ppt_pl1_spl(int);
callback cb_default_ppt_pl1_spl();
in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_pl2_sppt(int);
callback cb_default_ppt_pl2_sppt();
in-out property <AttrMinMax> ppt_pl3_fppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_pl3_fppt(int);
callback cb_default_ppt_pl3_fppt();
in-out property <AttrMinMax> ppt_fppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_fppt(int);
callback cb_default_ppt_fppt();
in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_apu_sppt(int);
callback cb_default_ppt_apu_sppt();
in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_platform_sppt(int);
callback cb_default_ppt_platform_sppt();
in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0,
max: 30,
current: 5,
};
callback cb_nv_dynamic_boost(int);
callback cb_default_nv_dynamic_boost();
in-out property <AttrMinMax> nv_temp_target: {
min: 0,
max: 80,
current: 75,
};
callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target();
in-out property <bool> enable_ppt_group: false;
callback cb_enable_ppt_group(bool);
in-out property <bool> ppt_enabled_available;
in-out property <bool> ppt_enabled;
callback cb_ppt_enabled(bool);
}
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;
alignment: LayoutAlignment.start;
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;
has_reset: false;
enabled <=> SystemPageData.charge_control_enabled;
value: SystemPageData.charge_control_end_threshold;
released => {
SystemPageData.charge_control_end_threshold = self.value;
SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
}
}
if SystemPageData.platform_profile != -1: HorizontalLayout {
spacing: 10px;
SystemDropdown {
text: @tr("Platform Profile");
current_index <=> SystemPageData.platform_profile;
current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile];
model <=> SystemPageData.platform_profile_choices;
selected => {
SystemPageData.cb_platform_profile(SystemPageData.platform_profile_indexes[SystemPageData.platform_profile])
}
}
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");
}
}
if !SystemPageData.asus_armoury_loaded: Rectangle {
border-width: 3px;
border-color: red;
max-height: 30px;
VerticalBox {
Text {
text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
}
}
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.ppt_pl1_spl.current != -1 || SystemPageData.ppt_pl2_sppt.current != -1 || SystemPageData.ppt_pl3_fppt.current != -1 || SystemPageData.ppt_fppt.current != -1 || SystemPageData.ppt_apu_sppt.current != -1 || SystemPageData.nv_temp_target.current != -1 || SystemPageData.nv_dynamic_boost.current != -1: HorizontalLayout {
padding-right: 10px;
padding-left: 10px;
alignment: LayoutAlignment.space-between;
Rectangle {
height: 32px;
Text {
font-size: 16px;
text: @tr("ppt_warning" => "The following settings are not applied until the toggle is enabled.");
}
}
if !SystemPageData.ppt_enabled_available: Switch {
text: @tr("ppt_group_enabled" => "Enable Tuning");
checked <=> SystemPageData.enable_ppt_group;
toggled => {
SystemPageData.cb_enable_ppt_group(SystemPageData.enable_ppt_group)
}
}
if SystemPageData.ppt_enabled_available: Switch {
text: @tr("ppt_group_enabled" => "Enable Tuning");
checked <=> SystemPageData.ppt_enabled;
toggled => {
SystemPageData.enable_ppt_group = self.checked;
SystemPageData.cb_ppt_enabled(SystemPageData.ppt_enabled)
}
}
}
if SystemPageData.ppt_pl1_spl.current != -1: SystemSlider {
text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption.");
minimum: SystemPageData.ppt_pl1_spl.min;
maximum: SystemPageData.ppt_pl1_spl.max;
value: SystemPageData.ppt_pl1_spl.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl1_spl();
}
released(value) => {
SystemPageData.ppt_pl1_spl.current = Math.round(value);
SystemPageData.cb_ppt_pl1_spl(Math.round(value));
}
}
if SystemPageData.ppt_pl2_sppt.current != -1: SystemSlider {
text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts.");
minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: SystemPageData.ppt_pl2_sppt.max;
value: SystemPageData.ppt_pl2_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl2_sppt();
}
released(value) => {
SystemPageData.ppt_pl2_sppt.current = Math.round(value);
SystemPageData.cb_ppt_pl2_sppt(Math.round(value));
}
}
if SystemPageData.ppt_pl3_fppt.current != -1: SystemSlider {
text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes.");
minimum: SystemPageData.ppt_pl3_fppt.min;
maximum: SystemPageData.ppt_pl3_fppt.max;
value: SystemPageData.ppt_pl3_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl3_fppt();
}
released(value) => {
SystemPageData.ppt_pl3_fppt.current = Math.round(value);
SystemPageData.cb_ppt_pl3_fppt(Math.round(value));
}
}
if SystemPageData.ppt_fppt.current != -1: SystemSlider {
text: @tr("ppt_fppt" => "Fast Package Power Limit");
title: @tr("ppt_fppt" => "Fast Package Power Limit");
help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes.");
minimum: SystemPageData.ppt_fppt.min;
maximum: SystemPageData.ppt_fppt.max;
value: SystemPageData.ppt_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_fppt();
}
released(value) => {
SystemPageData.ppt_fppt.current = Math.round(value);
SystemPageData.cb_ppt_fppt(Math.round(value));
}
}
if SystemPageData.ppt_apu_sppt.current != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads.");
minimum: SystemPageData.ppt_apu_sppt.min;
maximum: SystemPageData.ppt_apu_sppt.max;
value: SystemPageData.ppt_apu_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_apu_sppt();
}
released(value) => {
SystemPageData.ppt_apu_sppt.current = Math.round(value);
SystemPageData.cb_ppt_apu_sppt(Math.round(value));
}
}
if SystemPageData.ppt_platform_sppt.current != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods.");
minimum: SystemPageData.ppt_platform_sppt.min;
maximum: SystemPageData.ppt_platform_sppt.max;
value: SystemPageData.ppt_platform_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_platform_sppt();
}
released(value) => {
SystemPageData.ppt_platform_sppt.current = Math.round(value);
SystemPageData.cb_ppt_platform_sppt(Math.round(value));
}
}
if SystemPageData.nv_dynamic_boost.current != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "GPU Power Boost");
title: @tr("nv_dynamic_boost" => "GPU Power Boost");
help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat.");
minimum: SystemPageData.nv_dynamic_boost.min;
maximum: SystemPageData.nv_dynamic_boost.max;
value: SystemPageData.nv_dynamic_boost.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_dynamic_boost();
}
released(value) => {
SystemPageData.nv_dynamic_boost.current = Math.round(value);
SystemPageData.cb_nv_dynamic_boost(Math.round(value));
}
}
if SystemPageData.nv_temp_target.current != -1: SystemSlider {
text: @tr("nv_temp_target" => "GPU Temperature Limit");
title: @tr("nv_temp_target" => "GPU Temperature Limit");
help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit.");
minimum: SystemPageData.nv_temp_target.min;
maximum: SystemPageData.nv_temp_target.max;
value: SystemPageData.nv_temp_target.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_temp_target();
}
released(value) => {
SystemPageData.nv_temp_target.current = Math.round(value);
SystemPageData.cb_nv_temp_target(Math.round(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.platform_profile_linked_epp;
toggled => {
SystemPageData.cb_platform_profile_linked_epp(SystemPageData.platform_profile_linked_epp)
}
}
SystemDropdown {
text: @tr("EPP for Balanced Policy");
current_index <=> SystemPageData.profile_balanced_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_balanced_epp];
model <=> SystemPageData.energy_performance_choices;
selected => {
SystemPageData.cb_profile_balanced_epp(SystemPageData.profile_balanced_epp)
}
}
SystemDropdown {
text: @tr("EPP for Performance Policy");
current_index <=> SystemPageData.profile_performance_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_performance_epp];
model <=> SystemPageData.energy_performance_choices;
selected => {
SystemPageData.cb_profile_performance_epp(SystemPageData.profile_performance_epp)
}
}
SystemDropdown {
text: @tr("EPP for Quiet Policy");
current_index <=> SystemPageData.profile_quiet_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_quiet_epp];
model <=> SystemPageData.energy_performance_choices;
selected => {
SystemPageData.cb_profile_quiet_epp(SystemPageData.profile_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.platform_profile_on_battery;
current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_battery];
model <=> SystemPageData.platform_profile_choices;
selected => {
SystemPageData.cb_platform_profile_on_battery(SystemPageData.platform_profile_on_battery)
}
}
SystemToggle {
text: @tr("Enabled");
checked <=> SystemPageData.change_platform_profile_on_battery;
toggled => {
SystemPageData.cb_change_platform_profile_on_battery(SystemPageData.change_platform_profile_on_battery);
}
}
}
HorizontalLayout {
spacing: 10px;
SystemDropdown {
text: @tr("Throttle Policy on AC");
current_index <=> SystemPageData.platform_profile_on_ac;
current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_ac];
model <=> SystemPageData.platform_profile_choices;
selected => {
SystemPageData.cb_platform_profile_on_ac(SystemPageData.platform_profile_on_ac)
}
}
SystemToggle {
text: @tr("Enabled");
checked <=> SystemPageData.change_platform_profile_on_ac;
toggled => {
SystemPageData.cb_change_platform_profile_on_ac(SystemPageData.change_platform_profile_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;
}
}
}
}