Files
asusctl/rog-control-center/ui/pages/system.slint
T
2024-02-25 23:21:11 +13:00

205 lines
7.0 KiB
Plaintext

import { ValueBar, SquareCharButton } from "../common_widgets.slint";
import { Theme } from "../globals.slint";
import { HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch} from "std-widgets.slint";
export struct AvailableSystemProperties {
charge_limit: bool,
panel_od: bool,
mini_led_mode: bool,
disable_nvidia_powerd_on_battery: bool,
ac_command: bool,
bat_command: bool,
throttle_policy: bool,
ppt_pl1_spl: bool,
ppt_pl2_sppt: bool,
ppt_fppt: bool,
ppt_apu_sppt: bool,
ppt_platform_sppt: bool,
nv_dynamic_boost: bool,
nv_temp_target: bool,
}
export struct SystemValues {
charge_limit: int,
last_charge_limit: int,
panel_od: bool,
mini_led_mode: bool,
disable_nvidia_powerd_on_battery: bool,
}
export global SystemPage {
in-out property <float> charge_limit;
in-out property <int> last_charge_limit;
callback set_charge_limit(/* charge limit */ int);
in-out property <bool> panel_od;
in-out property <bool> last_panel_od;
callback set_panel_od(/* panel_od */ bool);
callback applied();
callback cancelled();
in-out property <AvailableSystemProperties> available;
}
export component PageSystem inherits Rectangle {
background: Theme.background-color;
VerticalLayout {
ScrollView {
VerticalLayout {
// padding: 10px;
spacing: 10px;
min-height: root.height;
if SystemPage.available.charge-limit: Rectangle {
background: Theme.background-color;
VerticalBox {
HorizontalBox {
alignment: LayoutAlignment.start;
Text {
color: Theme.text-foreground-color;
text: @tr("ChargeLimit" => "Charge limit");
}
Text {
color: Theme.text-foreground-color;
text: "\{Math.floor(SystemPage.charge_limit)}";
}
}
HorizontalBox {
TouchArea { }
charge_slider := Slider {
maximum: 100;
minimum: 20;
value <=> SystemPage.charge_limit;
released => {
SystemPage.set_charge_limit(SystemPage.charge_limit)
}
}
}
}
}
if SystemPage.available.panel-od: Rectangle {
background: Theme.background-color;
VerticalBox {
HorizontalBox {
alignment: LayoutAlignment.start;
Text {
color: Theme.text-foreground-color;
text: @tr("PanelOverdrive" => "Panel Overdrive");
}
Switch {
checked <=> SystemPage.panel_od;
toggled => {
SystemPage.set_panel_od(SystemPage.panel_od)
}
}
}
Text {
color: Theme.text-foreground-color;
text: @tr("PerformanceProfile" => "Performance Profile");
}
}
}
Rectangle {
background: Theme.background-color;
VerticalBox {
Text {
color: Theme.text-foreground-color;
text: @tr("nv_dynamic_boost" => "nv_dynamic_boost");
}
Text {
color: Theme.text-foreground-color;
text: @tr("nv_temp_target" => "nv_temp_target");
}
Text {
color: Theme.text-foreground-color;
text: @tr("ppt_pl1_spl" => "ppt_pl1_spl");
}
Text {
color: Theme.text-foreground-color;
text: @tr("ppt_pl2_sppt" => "ppt_pl2_sppt");
}
}
}
Rectangle {
background: Theme.background-color;
VerticalBox {
Text {
color: Theme.text-foreground-color;
text: @tr("PanelOverdrive" => "Panel Overdrive");
}
Text {
color: Theme.text-foreground-color;
text: @tr("PerformanceProfile" => "Performance Profile");
}
}
}
Rectangle {
background: Theme.background-color;
VerticalBox {
Text {
color: Theme.text-foreground-color;
text: @tr("PanelOverdrive" => "Panel Overdrive");
}
Text {
color: Theme.text-foreground-color;
text: @tr("PerformanceProfile" => "Performance Profile");
}
}
}
Rectangle {
background: Theme.background-color;
VerticalBox {
Text {
color: Theme.text-foreground-color;
text: @tr("PanelOverdrive" => "Panel Overdrive");
}
Text {
color: Theme.text-foreground-color;
text: @tr("PerformanceProfile" => "Performance Profile");
}
}
}
}
}
HorizontalLayout {
Button {
text: "Apply";
clicked => {
if SystemPage.last_charge_limit != Math.floor(SystemPage.charge_limit) {
SystemPage.set_charge_limit(SystemPage.charge_limit);
SystemPage.last_charge_limit = Math.floor(SystemPage.charge_limit);
}
SystemPage.applied();
}
}
Button {
text: "Cancel";
clicked => {
SystemPage.charge_limit = SystemPage.last_charge_limit;
SystemPage.cancelled();
}
}
}
}
}