feat: support TUF lighting power

This commit is contained in:
Denis Benato
2026-01-26 22:38:07 +01:00
parent 7d55a2675b
commit 024d41727f
5 changed files with 72 additions and 2 deletions

View File

@@ -148,6 +148,12 @@ async fn main() -> Result<()> {
} }
}; };
let is_tuf = {
let b = board_name.to_lowercase();
let p = prod_family.to_lowercase();
b.contains("tuf") || p.contains("tuf")
};
#[cfg(feature = "rog_ally")] #[cfg(feature = "rog_ally")]
if is_rog_ally { if is_rog_ally {
config.notifications.enabled = false; config.notifications.enabled = false;
@@ -198,7 +204,7 @@ async fn main() -> Result<()> {
loop { loop {
if is_rog_ally { if is_rog_ally {
let config_copy_2 = config.clone(); let config_copy_2 = config.clone();
let newui = setup_window(config.clone(), prefetched_supported.clone()); let newui = setup_window(config.clone(), prefetched_supported.clone(), is_tuf);
newui.window().on_close_requested(move || { newui.window().on_close_requested(move || {
exit(0); exit(0);
}); });
@@ -256,7 +262,7 @@ async fn main() -> Result<()> {
}); });
} else { } else {
let config_copy_2 = config_copy.clone(); let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy, pref_for_invoke.clone()); let newui = setup_window(config_copy, pref_for_invoke.clone(), is_tuf);
newui.window().on_close_requested(move || { newui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() { if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed; *app_state = AppState::MainWindowClosed;

View File

@@ -120,6 +120,7 @@ pub fn show_toast(
pub fn setup_window( pub fn setup_window(
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>,
prefetched_supported: std::sync::Arc<Option<Vec<i32>>>, prefetched_supported: std::sync::Arc<Option<Vec<i32>>>,
is_tuf: bool,
) -> MainWindow { ) -> MainWindow {
slint::set_xdg_app_id("rog-control-center") slint::set_xdg_app_id("rog-control-center")
.map_err(|e| warn!("Couldn't set application ID: {e:?}")) .map_err(|e| warn!("Couldn't set application ID: {e:?}"))
@@ -127,6 +128,8 @@ pub fn setup_window(
let ui = MainWindow::new() let ui = MainWindow::new()
.map_err(|e| warn!("Couldn't create main window: {e:?}")) .map_err(|e| warn!("Couldn't create main window: {e:?}"))
.unwrap(); .unwrap();
// propagate TUF flag to the UI so the sidebar can swap logo branding
ui.set_is_tuf(is_tuf);
ui.window() ui.window()
.show() .show()
.map_err(|e| warn!("Couldn't show main window: {e:?}")) .map_err(|e| warn!("Couldn't show main window: {e:?}"))

View File

@@ -35,6 +35,8 @@ export component MainWindow inherits Window {
true, // About true, // About
]; ];
private property <bool> show_notif; private property <bool> show_notif;
// TODO: change if TUF on the logo in the menu on the main page
in property <bool> is_tuf: false;
private property <bool> fade_cover; private property <bool> fade_cover;
private property <bool> toast: false; private property <bool> toast: false;
private property <string> toast_text: "I show when something is waiting"; private property <string> toast_text: "I show when something is waiting";
@@ -80,6 +82,7 @@ export component MainWindow inherits Window {
@tr("Menu7" => "About"), @tr("Menu7" => "About"),
]; ];
available: root.sidebar_items_avilable; available: root.sidebar_items_avilable;
is_tuf: root.is_tuf;
} }
Button { Button {

View File

@@ -252,6 +252,60 @@ export component PageAura inherits Rectangle {
} }
} }
// TUF devices: show the same configurable power groups as `New`, since
// `setup_aura` fills `AuraPageData.supported_power_zones` and `led_power`
// appropriately for TUF devices. This ensures the Power Settings panel
// reflects what the firmware reports for TUF models.
if root.show_aura_power && AuraPageData.device_type == AuraDevType.Tuf: Rectangle {
background: Palette.background;
width: 100%;
height: 100%;
opacity: 1;
ScrollView {
VerticalLayout {
padding: 30px;
padding-top: 10px;
spacing: 10px;
alignment: LayoutAlignment.start;
for state[idx] in AuraPageData.led_power.states: tuf_zone := AuraPowerGroup {
group-title: AuraPageData.power_zone_names[state.zone_name_idx];
boot_checked: state.boot;
boot_toggled => {
AuraPageData.led_power.states[idx].boot = tuf_zone.boot_checked;
AuraPageData.cb_led_power(AuraPageData.led_power);
}
awake_checked: state.awake;
awake_toggled => {
AuraPageData.led_power.states[idx].awake = tuf_zone.awake_checked;
AuraPageData.cb_led_power(AuraPageData.led_power);
}
sleep_checked: state.sleep;
sleep_toggled => {
AuraPageData.led_power.states[idx].sleep = tuf_zone.sleep_checked;
AuraPageData.cb_led_power(AuraPageData.led_power);
}
shutdown_checked: state.shutdown;
shutdown_toggled => {
AuraPageData.led_power.states[idx].shutdown = tuf_zone.shutdown_checked;
AuraPageData.cb_led_power(AuraPageData.led_power);
}
}
}
Button {
x: root.width - self.width - 6px;
y: 6px;
text: "✕";
height: 36px;
clicked => {
root.show_aura_power = false;
root.show_fade_cover = false;
}
}
}
}
if root.show_aura_power && AuraPageData.device_type == AuraDevType.Old: Rectangle { if root.show_aura_power && AuraPageData.device_type == AuraDevType.Old: Rectangle {
background: Palette.background; background: Palette.background;
width: 100%; width: 100%;

View File

@@ -52,6 +52,7 @@ component SideBarItem inherits Rectangle {
export component SideBar inherits Rectangle { export component SideBar inherits Rectangle {
in property <[string]> model: []; in property <[string]> model: [];
in property <[bool]> available: []; in property <[bool]> available: [];
in property <bool> is_tuf: false;
out property <int> current-item: 0; out property <int> current-item: 0;
out property <int> current-focused: fs.has-focus ? fs.focused-tab : -1; out property <int> current-focused: fs.has-focus ? fs.focused-tab : -1;
@@ -99,6 +100,9 @@ export component SideBar inherits Rectangle {
Image { Image {
height: 100px; height: 100px;
// TODO: change if TUF on the logo in the menu on the main page
// If running on a TUF model, replace the ROG red with TUF orange
// (add data/tuf-control-center.png and switch here when available)
source: @image-url("../../data/rog-control-center.png"); source: @image-url("../../data/rog-control-center.png");
horizontal-alignment: center; horizontal-alignment: center;
image-fit: contain; image-fit: contain;