From 180d63620b9de490098567874e0daf41ab2f8856 Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Wed, 8 Oct 2025 01:19:38 +0200 Subject: [PATCH] Fix multiple warnings --- asusctl/src/main.rs | 4 +- asusd/src/aura_laptop/mod.rs | 2 +- asusd/src/aura_scsi/mod.rs | 2 +- asusd/src/aura_slash/mod.rs | 2 +- rog-control-center/src/ui/setup_system.rs | 231 +++++++++--------- rog-control-center/ui/main_window.slint | 4 +- rog-control-center/ui/pages/anime.slint | 3 +- .../ui/pages/app_settings.slint | 4 +- rog-control-center/ui/pages/aura.slint | 9 +- rog-control-center/ui/pages/system.slint | 3 +- rog-control-center/ui/widgets/sidebar.slint | 3 +- 11 files changed, 140 insertions(+), 127 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 514a5d56..d2385e4b 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -1171,9 +1171,9 @@ fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box Result<(), Box> { { - if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help { + if cmd.free.is_empty() || !cmd.free.len().is_multiple_of(2) || cmd.help { const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5"; - if cmd.free.len() % 2 != 0 { + if !cmd.free.len().is_multiple_of(2) { println!( "Incorrect number of args, each attribute label must be paired with a setting:" ); diff --git a/asusd/src/aura_laptop/mod.rs b/asusd/src/aura_laptop/mod.rs index a3be5068..90e55547 100644 --- a/asusd/src/aura_laptop/mod.rs +++ b/asusd/src/aura_laptop/mod.rs @@ -28,7 +28,7 @@ impl Aura { Ok(()) } - pub async fn lock_config(&self) -> MutexGuard { + pub async fn lock_config(&self) -> MutexGuard<'_, AuraConfig> { self.config.lock().await } diff --git a/asusd/src/aura_scsi/mod.rs b/asusd/src/aura_scsi/mod.rs index 182869e7..2fc45b54 100644 --- a/asusd/src/aura_scsi/mod.rs +++ b/asusd/src/aura_scsi/mod.rs @@ -20,7 +20,7 @@ impl ScsiAura { Self { device, config } } - pub async fn lock_config(&self) -> MutexGuard { + pub async fn lock_config(&self) -> MutexGuard<'_, ScsiConfig> { self.config.lock().await } diff --git a/asusd/src/aura_slash/mod.rs b/asusd/src/aura_slash/mod.rs index ef9517f0..42434003 100644 --- a/asusd/src/aura_slash/mod.rs +++ b/asusd/src/aura_slash/mod.rs @@ -27,7 +27,7 @@ impl Slash { Self { hid, usb, config } } - pub async fn lock_config(&self) -> MutexGuard { + pub async fn lock_config(&self) -> MutexGuard<'_, SlashConfig> { self.config.lock().await } diff --git a/rog-control-center/src/ui/setup_system.rs b/rog-control-center/src/ui/setup_system.rs index 52015cd7..e7d9f7f9 100644 --- a/rog-control-center/src/ui/setup_system.rs +++ b/rog-control-center/src/ui/setup_system.rs @@ -12,7 +12,7 @@ use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel}; use super::show_toast; use crate::config::Config; use crate::zbus_proxies::find_iface_async; -use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, SystemPageData}; +use crate::{set_ui_callbacks, AttrMinMax, MainWindow, SystemPageData}; const MINMAX: AttrMinMax = AttrMinMax { min: 0, @@ -572,120 +572,123 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc>) for attr in armoury_attrs { if let Ok(value) = attr.current_value().await { - let name = attr.name().await.unwrap(); - debug!("Setting up {} = {value}", <&str>::from(name)); - let platform = platform.clone(); - handle - .upgrade_in_event_loop(move |handle| match name { - FirmwareAttribute::ApuMem => {} - FirmwareAttribute::CoresPerformance => {} - FirmwareAttribute::CoresEfficiency => {} - FirmwareAttribute::PptEnabled => { - init_property!(ppt_enabled, handle, value, bool); - setup_callback!(ppt_enabled, handle, attr, bool); - let handle_copy = handle.as_weak(); - let proxy_copy = attr.clone(); - tokio::spawn(async move { - let mut x = proxy_copy.receive_current_value_changed().await; - use futures_util::StreamExt; - while let Some(e) = x.next().await { - if let Ok(out) = e.get().await { - handle_copy - .upgrade_in_event_loop(move |handle| { - handle - .global::() - .set_enable_ppt_group(out == 1); - handle - .global::() - .set_ppt_enabled(out == 1); - }) - .ok(); + if let Ok(name) = attr.name().await { + debug!("Setting up {} = {value}", <&str>::from(name)); + let platform = platform.clone(); + handle + .upgrade_in_event_loop(move |handle| match name { + FirmwareAttribute::ApuMem => {} + FirmwareAttribute::CoresPerformance => {} + FirmwareAttribute::CoresEfficiency => {} + FirmwareAttribute::PptEnabled => { + init_property!(ppt_enabled, handle, value, bool); + setup_callback!(ppt_enabled, handle, attr, bool); + let handle_copy = handle.as_weak(); + let proxy_copy = attr.clone(); + tokio::spawn(async move { + let mut x = proxy_copy.receive_current_value_changed().await; + use futures_util::StreamExt; + while let Some(e) = x.next().await { + if let Ok(out) = e.get().await { + handle_copy + .upgrade_in_event_loop(move |handle| { + handle + .global::() + .set_enable_ppt_group(out == 1); + handle + .global::() + .set_ppt_enabled(out == 1); + }) + .ok(); + } } - } - }); - handle - .global::() - .set_ppt_enabled_available(true); - handle - .global::() - .set_enable_ppt_group(value == 1); - } - FirmwareAttribute::PptPl1Spl => { - init_minmax_property!(ppt_pl1_spl, handle, attr); - setup_callback!(ppt_pl1_spl, handle, attr, i32); - setup_callback_restore_default!(ppt_pl1_spl, handle, attr); - setup_minmax_external!(ppt_pl1_spl, handle, attr, platform); - } - FirmwareAttribute::PptPl2Sppt => { - init_minmax_property!(ppt_pl2_sppt, handle, attr); - setup_callback!(ppt_pl2_sppt, handle, attr, i32); - setup_callback_restore_default!(ppt_pl2_sppt, handle, attr); - setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform); - } - FirmwareAttribute::PptPl3Fppt => { - init_minmax_property!(ppt_pl3_fppt, handle, attr); - setup_callback!(ppt_pl3_fppt, handle, attr, i32); - setup_callback_restore_default!(ppt_pl3_fppt, handle, attr); - setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform); - } - FirmwareAttribute::PptFppt => { - init_minmax_property!(ppt_fppt, handle, attr); - setup_callback!(ppt_fppt, handle, attr, i32); - setup_callback_restore_default!(ppt_fppt, handle, attr); - setup_minmax_external!(ppt_fppt, handle, attr, platform); - } - FirmwareAttribute::PptApuSppt => { - init_minmax_property!(ppt_apu_sppt, handle, attr); - setup_callback!(ppt_apu_sppt, handle, attr, i32); - setup_callback_restore_default!(ppt_apu_sppt, handle, attr); - setup_minmax_external!(ppt_apu_sppt, handle, attr, platform); - } - FirmwareAttribute::PptPlatformSppt => { - init_minmax_property!(ppt_platform_sppt, handle, attr); - setup_callback!(ppt_platform_sppt, handle, attr, i32); - setup_callback_restore_default!(ppt_platform_sppt, handle, attr); - setup_minmax_external!(ppt_platform_sppt, handle, attr, platform); - } - FirmwareAttribute::NvDynamicBoost => { - init_minmax_property!(nv_dynamic_boost, handle, attr); - setup_callback!(nv_dynamic_boost, handle, attr, i32); - setup_callback_restore_default!(nv_dynamic_boost, handle, attr); - setup_minmax_external!(nv_dynamic_boost, handle, attr, platform); - } - FirmwareAttribute::NvTempTarget => { - init_minmax_property!(nv_temp_target, handle, attr); - setup_callback!(nv_temp_target, handle, attr, i32); - setup_callback_restore_default!(nv_temp_target, handle, attr); - setup_minmax_external!(nv_temp_target, handle, attr, platform); - } - FirmwareAttribute::DgpuBaseTgp => {} - FirmwareAttribute::DgpuTgp => {} - FirmwareAttribute::ChargeMode => {} - FirmwareAttribute::BootSound => { - init_property!(boot_sound, handle, value, i32); - setup_callback!(boot_sound, handle, attr, i32); - setup_external!(boot_sound, i32, handle, attr, value) - } - FirmwareAttribute::McuPowersave => {} - FirmwareAttribute::PanelOverdrive => { - init_property!(panel_overdrive, handle, value, i32); - setup_callback!(panel_overdrive, handle, attr, i32); - setup_external!(panel_overdrive, i32, handle, attr, value) - } - FirmwareAttribute::PanelHdMode => {} - FirmwareAttribute::EgpuConnected => {} - FirmwareAttribute::EgpuEnable => {} - FirmwareAttribute::DgpuDisable => {} - FirmwareAttribute::GpuMuxMode => {} - FirmwareAttribute::MiniLedMode => { - init_property!(mini_led_mode, handle, value, i32); - setup_callback!(mini_led_mode, handle, attr, i32); - setup_external!(mini_led_mode, i32, handle, attr, value); - } - FirmwareAttribute::PendingReboot => {} - FirmwareAttribute::None => {} - }) - .ok(); + }); + handle + .global::() + .set_ppt_enabled_available(true); + handle + .global::() + .set_enable_ppt_group(value == 1); + } + FirmwareAttribute::PptPl1Spl => { + init_minmax_property!(ppt_pl1_spl, handle, attr); + setup_callback!(ppt_pl1_spl, handle, attr, i32); + setup_callback_restore_default!(ppt_pl1_spl, handle, attr); + setup_minmax_external!(ppt_pl1_spl, handle, attr, platform); + } + FirmwareAttribute::PptPl2Sppt => { + init_minmax_property!(ppt_pl2_sppt, handle, attr); + setup_callback!(ppt_pl2_sppt, handle, attr, i32); + setup_callback_restore_default!(ppt_pl2_sppt, handle, attr); + setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform); + } + FirmwareAttribute::PptPl3Fppt => { + init_minmax_property!(ppt_pl3_fppt, handle, attr); + setup_callback!(ppt_pl3_fppt, handle, attr, i32); + setup_callback_restore_default!(ppt_pl3_fppt, handle, attr); + setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform); + } + FirmwareAttribute::PptFppt => { + init_minmax_property!(ppt_fppt, handle, attr); + setup_callback!(ppt_fppt, handle, attr, i32); + setup_callback_restore_default!(ppt_fppt, handle, attr); + setup_minmax_external!(ppt_fppt, handle, attr, platform); + } + FirmwareAttribute::PptApuSppt => { + init_minmax_property!(ppt_apu_sppt, handle, attr); + setup_callback!(ppt_apu_sppt, handle, attr, i32); + setup_callback_restore_default!(ppt_apu_sppt, handle, attr); + setup_minmax_external!(ppt_apu_sppt, handle, attr, platform); + } + FirmwareAttribute::PptPlatformSppt => { + init_minmax_property!(ppt_platform_sppt, handle, attr); + setup_callback!(ppt_platform_sppt, handle, attr, i32); + setup_callback_restore_default!(ppt_platform_sppt, handle, attr); + setup_minmax_external!(ppt_platform_sppt, handle, attr, platform); + } + FirmwareAttribute::NvDynamicBoost => { + init_minmax_property!(nv_dynamic_boost, handle, attr); + setup_callback!(nv_dynamic_boost, handle, attr, i32); + setup_callback_restore_default!(nv_dynamic_boost, handle, attr); + setup_minmax_external!(nv_dynamic_boost, handle, attr, platform); + } + FirmwareAttribute::NvTempTarget => { + init_minmax_property!(nv_temp_target, handle, attr); + setup_callback!(nv_temp_target, handle, attr, i32); + setup_callback_restore_default!(nv_temp_target, handle, attr); + setup_minmax_external!(nv_temp_target, handle, attr, platform); + } + FirmwareAttribute::DgpuBaseTgp => {} + FirmwareAttribute::DgpuTgp => {} + FirmwareAttribute::ChargeMode => {} + FirmwareAttribute::BootSound => { + init_property!(boot_sound, handle, value, i32); + setup_callback!(boot_sound, handle, attr, i32); + setup_external!(boot_sound, i32, handle, attr, value) + } + FirmwareAttribute::McuPowersave => {} + FirmwareAttribute::PanelOverdrive => { + init_property!(panel_overdrive, handle, value, i32); + setup_callback!(panel_overdrive, handle, attr, i32); + setup_external!(panel_overdrive, i32, handle, attr, value) + } + FirmwareAttribute::PanelHdMode => {} + FirmwareAttribute::EgpuConnected => {} + FirmwareAttribute::EgpuEnable => {} + FirmwareAttribute::DgpuDisable => {} + FirmwareAttribute::GpuMuxMode => {} + FirmwareAttribute::MiniLedMode => { + init_property!(mini_led_mode, handle, value, i32); + setup_callback!(mini_led_mode, handle, attr, i32); + setup_external!(mini_led_mode, i32, handle, attr, value); + } + FirmwareAttribute::PendingReboot => {} + FirmwareAttribute::None => {} + }) + .ok(); + } else { + error!("Attribute with no name, skipping"); + } } } handle diff --git a/rog-control-center/ui/main_window.slint b/rog-control-center/ui/main_window.slint index acfdf437..0623c1dc 100644 --- a/rog-control-center/ui/main_window.slint +++ b/rog-control-center/ui/main_window.slint @@ -190,7 +190,9 @@ export component MainWindow inherits Window { y: 0px; width: root.width; height: root.height; - padding: 10px; + + //padding only has effect on layout elements + //padding: 10px; background: Palette.background; border-color: Palette.border; diff --git a/rog-control-center/ui/pages/anime.slint b/rog-control-center/ui/pages/anime.slint index 2ac383a9..aef04ea2 100644 --- a/rog-control-center/ui/pages/anime.slint +++ b/rog-control-center/ui/pages/anime.slint @@ -37,7 +37,8 @@ export component PageAnime inherits Rectangle { property show_builtin_advanced: false; clip: true; // TODO: slow with border-radius - padding: 8px; + //padding only has effect on layout elements + //padding: 8px; // height: parent.height - infobar.height - mainview.padding - self.padding * 2; // TODO: border-radius: 8px; VerticalLayout { diff --git a/rog-control-center/ui/pages/app_settings.slint b/rog-control-center/ui/pages/app_settings.slint index 993cbf90..d1a5e417 100644 --- a/rog-control-center/ui/pages/app_settings.slint +++ b/rog-control-center/ui/pages/app_settings.slint @@ -16,7 +16,9 @@ export component PageAppSettings inherits VerticalLayout { Rectangle { clip: true; // TODO: slow with border-radius - padding: 8px; + //padding only has effect on layout elements + //padding: 8px; + // height: parent.height - infobar.height - mainview.padding - self.padding * 2; // TODO: border-radius: 8px; mainview := VerticalLayout { diff --git a/rog-control-center/ui/pages/aura.slint b/rog-control-center/ui/pages/aura.slint index 866de1f0..71cb5281 100644 --- a/rog-control-center/ui/pages/aura.slint +++ b/rog-control-center/ui/pages/aura.slint @@ -113,7 +113,8 @@ export component PageAura inherits Rectangle { min-height: 80px; max-height: 90px; RogItem { - padding: 0px; + //padding only has effect on layout elements + //padding: 0px; VerticalBox { Text { text: @tr("Zone"); @@ -136,7 +137,8 @@ export component PageAura inherits Rectangle { } RogItem { - padding: 0px; + //padding only has effect on layout elements + //padding: 0px; VerticalBox { Text { text: @tr("Direction"); @@ -158,7 +160,8 @@ export component PageAura inherits Rectangle { } RogItem { - padding: 0px; + //padding only has effect on layout elements + //padding: 0px; VerticalBox { Text { text: @tr("Speed"); diff --git a/rog-control-center/ui/pages/system.slint b/rog-control-center/ui/pages/system.slint index e8a0b482..df913430 100644 --- a/rog-control-center/ui/pages/system.slint +++ b/rog-control-center/ui/pages/system.slint @@ -140,7 +140,8 @@ export component PageSystem inherits Rectangle { property show_fade_cover: false; property show_throttle_advanced: false; clip: true; - padding: 8px; + //padding only has effect on layout elements + //padding: 8px; ScrollView { VerticalLayout { padding: 10px; diff --git a/rog-control-center/ui/widgets/sidebar.slint b/rog-control-center/ui/widgets/sidebar.slint index b9d0323c..b3574a3f 100644 --- a/rog-control-center/ui/widgets/sidebar.slint +++ b/rog-control-center/ui/widgets/sidebar.slint @@ -4,7 +4,8 @@ import { Palette, HorizontalBox, VerticalBox } from "std-widgets.slint"; component SideBarItem inherits Rectangle { - padding: 10px; + // padding only has effect on layout elements + // padding: 10px; in property selected; in property has-focus; in-out property text <=> label.text;