Files
asusctl/rog-control-center/ui/pages/fans.slint
mihai2mn a0dd0b36dd feat(ui): Major UI update to Slint components
- Add real-time system status components

- Add theme support

- Improve layouts
2026-01-24 17:03:21 +01:00

351 lines
14 KiB
Plaintext

import { Palette, TabWidget, Button, CheckBox, Slider } from "std-widgets.slint";
import { Graph, Node } from "../widgets/graph.slint";
import { SystemToggle } from "../widgets/common.slint";
import { Profile, FanType, FanPageData } from "../types/fan_types.slint";
import { RogPalette } from "../themes/rog_theme.slint";
component FanTab inherits Rectangle {
in-out property <bool> enabled: false;
in-out property <bool> tab_enabled: true;
in property <Profile> profile;
in property <FanType> fan_type;
callback apply();
callback cancel();
callback default();
callback toggled();
in property <string> title;
in-out property <[Node]> nodes;
VerticalLayout {
private property <bool> local_busy:
(root.fan_type == FanType.CPU && FanPageData.is_busy_cpu) ||
(root.fan_type == FanType.GPU && FanPageData.is_busy_gpu) ||
(root.fan_type == FanType.Middle && FanPageData.is_busy_mid);
if FanPageData.show_custom_warning: Rectangle {
background: RogPalette.control-background;
border-radius: 4px;
height: 48px;
HorizontalLayout {
padding: 10px;
Text {
color: #ffd700; // Gold/Yellow
text: @tr("Zero RPM Mode Enabled: Fans will take ~25s to spin down entirely.");
vertical-alignment: TextVerticalAlignment.center;
horizontal-alignment: TextHorizontalAlignment.center;
wrap: word-wrap;
}
}
}
HorizontalLayout {
spacing: 10px;
if root.tab_enabled: Graph {
nodes <=> root.nodes;
}
if root.tab_enabled: VerticalLayout {
width: 40px;
alignment: center;
spacing: 10px;
Button {
text: "+";
height: 40px;
width: 40px;
clicked => {
root.nodes = [
{ x: root.nodes[0].x, y: min(255px, root.nodes[0].y + 13px) },
{ x: root.nodes[1].x, y: min(255px, root.nodes[1].y + 13px) },
{ x: root.nodes[2].x, y: min(255px, root.nodes[2].y + 13px) },
{ x: root.nodes[3].x, y: min(255px, root.nodes[3].y + 13px) },
{ x: root.nodes[4].x, y: min(255px, root.nodes[4].y + 13px) },
{ x: root.nodes[5].x, y: min(255px, root.nodes[5].y + 13px) },
{ x: root.nodes[6].x, y: min(255px, root.nodes[6].y + 13px) },
{ x: root.nodes[7].x, y: min(255px, root.nodes[7].y + 13px) }
];
}
}
Text {
text: "All";
font-size: 10px;
horizontal-alignment: center;
color: white;
}
Button {
text: "-";
height: 40px;
width: 40px;
clicked => {
root.nodes = [
{ x: root.nodes[0].x, y: max(0px, root.nodes[0].y - 13px) },
{ x: root.nodes[1].x, y: max(0px, root.nodes[1].y - 13px) },
{ x: root.nodes[2].x, y: max(0px, root.nodes[2].y - 13px) },
{ x: root.nodes[3].x, y: max(0px, root.nodes[3].y - 13px) },
{ x: root.nodes[4].x, y: max(0px, root.nodes[4].y - 13px) },
{ x: root.nodes[5].x, y: max(0px, root.nodes[5].y - 13px) },
{ x: root.nodes[6].x, y: max(0px, root.nodes[6].y - 13px) },
{ x: root.nodes[7].x, y: max(0px, root.nodes[7].y - 13px) }
];
}
}
}
if !root.tab_enabled: Rectangle {
Text {
font-size: 24px;
text: @tr("This fan is not avilable on this machine");
}
}
}
HorizontalLayout {
spacing: 20px;
alignment: LayoutAlignment.end;
CheckBox {
text: @tr("Enable Manual Control");
checked <=> root.enabled;
enabled: root.tab_enabled && !local_busy;
toggled => {
root.toggled();
}
}
Button {
text: local_busy ? @tr("Applying...") : @tr("Apply Curve");
enabled: root.tab_enabled && root.enabled && !local_busy;
clicked => {
root.apply();
}
}
Button {
text: @tr("Cancel");
enabled: root.tab_enabled && !local_busy;
clicked => {
root.cancel()
}
}
Button {
text: @tr("Factory Default (all fans)");
enabled: root.tab_enabled && !local_busy;
clicked => {
root.default();
}
}
}
}
}
export component PageFans inherits VerticalLayout {
TabWidget {
Tab {
title: @tr("Balanced");
TabWidget {
Tab {
title: @tr("CPU");
FanTab {
tab_enabled <=> FanPageData.cpu_fan_available;
enabled <=> FanPageData.balanced_cpu_enabled;
nodes <=> FanPageData.balanced_cpu;
apply => {
FanPageData.set_fan_data(FanType.CPU, Profile.Balanced, self.enabled, FanPageData.balanced_cpu);
}
toggled => {
FanPageData.set_fan_data(FanType.CPU, Profile.Balanced, self.enabled, FanPageData.balanced_cpu);
}
default => {
FanPageData.set_profile_default(Profile.Balanced);
}
cancel => {
FanPageData.cancel(FanType.CPU, Profile.Balanced);
}
}
}
Tab {
title: @tr("Mid");
FanTab {
tab_enabled <=> FanPageData.mid_fan_available;
enabled <=> FanPageData.balanced_mid_enabled;
nodes <=> FanPageData.balanced_mid;
apply => {
FanPageData.set_fan_data(FanType.Middle, Profile.Balanced, self.enabled, FanPageData.balanced_mid);
}
toggled => {
FanPageData.set_fan_data(FanType.Middle, Profile.Balanced, self.enabled, FanPageData.balanced_mid);
}
default => {
FanPageData.set_profile_default(Profile.Balanced);
}
cancel => {
FanPageData.cancel(FanType.Middle, Profile.Balanced);
}
}
}
Tab {
title: @tr("GPU");
FanTab {
tab_enabled <=> FanPageData.gpu_fan_available;
enabled <=> FanPageData.balanced_gpu_enabled;
nodes <=> FanPageData.balanced_gpu;
apply => {
FanPageData.set_fan_data(FanType.GPU, Profile.Balanced, self.enabled, FanPageData.balanced_gpu);
}
toggled => {
FanPageData.set_fan_data(FanType.GPU, Profile.Balanced, self.enabled, FanPageData.balanced_gpu);
}
default => {
FanPageData.set_profile_default(Profile.Balanced);
}
cancel => {
FanPageData.cancel(FanType.GPU, Profile.Balanced);
}
}
}
}
}
Tab {
title: @tr("Performance");
TabWidget {
Tab {
title: @tr("CPU");
FanTab {
tab_enabled <=> FanPageData.cpu_fan_available;
enabled <=> FanPageData.performance_cpu_enabled;
nodes <=> FanPageData.performance_cpu;
apply => {
FanPageData.set_fan_data(FanType.CPU, Profile.Performance, self.enabled, FanPageData.performance_cpu);
}
toggled => {
FanPageData.set_fan_data(FanType.CPU, Profile.Performance, self.enabled, FanPageData.performance_cpu);
}
default => {
FanPageData.set_profile_default(Profile.Performance);
}
cancel => {
FanPageData.cancel(FanType.CPU, Profile.Performance);
}
}
}
Tab {
title: @tr("Mid");
FanTab {
tab_enabled <=> FanPageData.mid_fan_available;
enabled <=> FanPageData.performance_mid_enabled;
nodes <=> FanPageData.performance_mid;
apply => {
FanPageData.set_fan_data(FanType.Middle, Profile.Performance, self.enabled, FanPageData.performance_mid);
}
toggled => {
FanPageData.set_fan_data(FanType.Middle, Profile.Performance, self.enabled, FanPageData.performance_mid);
}
default => {
FanPageData.set_profile_default(Profile.Performance);
}
cancel => {
FanPageData.cancel(FanType.Middle, Profile.Performance);
}
}
}
Tab {
title: @tr("GPU");
FanTab {
tab_enabled <=> FanPageData.gpu_fan_available;
enabled <=> FanPageData.performance_gpu_enabled;
nodes <=> FanPageData.performance_gpu;
apply => {
FanPageData.set_fan_data(FanType.GPU, Profile.Performance, self.enabled, FanPageData.performance_gpu);
}
toggled => {
FanPageData.set_fan_data(FanType.GPU, Profile.Performance, self.enabled, FanPageData.performance_gpu);
}
default => {
FanPageData.set_profile_default(Profile.Performance);
}
cancel => {
FanPageData.cancel(FanType.GPU, Profile.Performance);
}
}
}
}
}
Tab {
title: @tr("Quiet");
TabWidget {
Tab {
title: @tr("CPU");
FanTab {
tab_enabled <=> FanPageData.cpu_fan_available;
enabled <=> FanPageData.quiet_cpu_enabled;
nodes <=> FanPageData.quiet_cpu;
apply => {
FanPageData.set_fan_data(FanType.CPU, Profile.Quiet, self.enabled, FanPageData.quiet_cpu);
}
toggled => {
FanPageData.set_fan_data(FanType.CPU, Profile.Quiet, self.enabled, FanPageData.quiet_cpu);
}
default => {
FanPageData.set_profile_default(Profile.Quiet);
}
cancel => {
FanPageData.cancel(FanType.CPU, Profile.Quiet);
}
}
}
Tab {
title: @tr("Mid");
FanTab {
tab_enabled <=> FanPageData.mid_fan_available;
enabled <=> FanPageData.quiet_mid_enabled;
nodes <=> FanPageData.quiet_mid;
apply => {
FanPageData.set_fan_data(FanType.Middle, Profile.Quiet, self.enabled, FanPageData.quiet_mid);
}
toggled => {
FanPageData.set_fan_data(FanType.Middle, Profile.Quiet, self.enabled, FanPageData.quiet_mid);
}
default => {
FanPageData.set_profile_default(Profile.Quiet);
}
cancel => {
FanPageData.cancel(FanType.Middle, Profile.Quiet);
}
}
}
Tab {
title: @tr("GPU");
FanTab {
tab_enabled <=> FanPageData.gpu_fan_available;
enabled <=> FanPageData.quiet_gpu_enabled;
nodes <=> FanPageData.quiet_gpu;
apply => {
FanPageData.set_fan_data(FanType.GPU, Profile.Quiet, self.enabled, FanPageData.quiet_gpu);
}
toggled => {
FanPageData.set_fan_data(FanType.GPU, Profile.Quiet, self.enabled, FanPageData.quiet_gpu);
}
default => {
FanPageData.set_profile_default(Profile.Quiet);
}
cancel => {
FanPageData.cancel(FanType.GPU, Profile.Quiet);
}
}
}
}
}
}
}