mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
feature: add UI controls fro screenpad
This commit is contained in:
@@ -3,6 +3,7 @@ use std::sync::{Arc, Mutex};
|
||||
use concat_idents::concat_idents;
|
||||
use log::{debug, error};
|
||||
use rog_dbus::asus_armoury::AsusArmouryProxy;
|
||||
use rog_dbus::zbus_backlight::BacklightProxy;
|
||||
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
|
||||
use rog_platform::asus_armoury::FirmwareAttribute;
|
||||
use rog_platform::platform::Properties;
|
||||
@@ -40,6 +41,7 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
ui.global::<SystemPageData>().set_panel_overdrive(-1);
|
||||
ui.global::<SystemPageData>().set_boot_sound(-1);
|
||||
ui.global::<SystemPageData>().set_mini_led_mode(-1);
|
||||
ui.global::<SystemPageData>().set_screenpad_brightness(-1);
|
||||
ui.global::<SystemPageData>().set_ppt_pl1_spl(MINMAX);
|
||||
ui.global::<SystemPageData>().set_ppt_pl2_sppt(MINMAX);
|
||||
ui.global::<SystemPageData>().set_ppt_pl3_fppt(MINMAX);
|
||||
@@ -288,6 +290,13 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
|
||||
log::error!("Failed to create platform proxy: {}", e);
|
||||
})
|
||||
.unwrap();
|
||||
let backlight = BacklightProxy::builder(&conn)
|
||||
.build()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to create backlight proxy: {}", e);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
debug!("Setting up system page profile callbacks");
|
||||
set_ui_props_async!(
|
||||
@@ -381,6 +390,24 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
|
||||
|
||||
set_ui_props_async!(handle, platform, SystemPageData, enable_ppt_group);
|
||||
|
||||
set_ui_props_async!(handle, backlight, SystemPageData, screenpad_brightness);
|
||||
if let Ok(value) = backlight.screenpad_gamma().await {
|
||||
handle
|
||||
.upgrade_in_event_loop(move |handle| {
|
||||
handle
|
||||
.global::<SystemPageData>()
|
||||
.set_screenpad_gamma(value.parse().unwrap_or(1.0));
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
set_ui_props_async!(
|
||||
handle,
|
||||
backlight,
|
||||
SystemPageData,
|
||||
screenpad_sync_with_primary
|
||||
);
|
||||
|
||||
let platform_copy = platform.clone();
|
||||
handle
|
||||
.upgrade_in_event_loop(move |handle| {
|
||||
@@ -501,6 +528,27 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
|
||||
"Throttle policy on battery enabled: {}",
|
||||
"Setting Throttle policy on AC failed"
|
||||
);
|
||||
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as i32),
|
||||
backlight.screenpad_brightness(as i32),
|
||||
"Screenpad successfully set to {}",
|
||||
"Setting screenpad brightness failed"
|
||||
);
|
||||
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as bool),
|
||||
backlight.screenpad_sync_with_primary(as bool),
|
||||
"Screenpad successfully set to {}",
|
||||
"Setting screenpad brightness failed"
|
||||
);
|
||||
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(.parse().unwrap_or(1.0)),
|
||||
backlight.screenpad_gamma(.to_string().as_str()),
|
||||
"Screenpad successfully set to {}",
|
||||
"Setting screenpad brightness failed"
|
||||
);
|
||||
})
|
||||
.ok();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
|
||||
import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt, RogItem } from "../widgets/common.slint";
|
||||
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox, StandardButton} from "std-widgets.slint";
|
||||
|
||||
export struct AttrMinMax {
|
||||
@@ -53,6 +53,15 @@ export global SystemPageData {
|
||||
callback cb_boot_sound(int);
|
||||
in-out property <int> mini_led_mode;
|
||||
callback cb_mini_led_mode(int);
|
||||
|
||||
in-out property <float> screenpad_gamma;
|
||||
callback cb_screenpad_gamma(float);
|
||||
// percentage
|
||||
in-out property <int> screenpad_brightness: 50;
|
||||
callback cb_screenpad_brightness(int);
|
||||
in-out property <bool> screenpad_sync_with_primary: false;
|
||||
callback cb_screenpad_sync_with_primary(bool);
|
||||
|
||||
in-out property <bool> asus_armoury_loaded: false;
|
||||
|
||||
in-out property <AttrMinMax> ppt_pl1_spl: {
|
||||
@@ -185,6 +194,52 @@ export component PageSystem inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
if SystemPageData.screenpad_brightness != -1: RogItem {
|
||||
HorizontalLayout {
|
||||
padding-left: 10px;
|
||||
padding-right: 20px;
|
||||
HorizontalLayout {
|
||||
width: 38%;
|
||||
alignment: LayoutAlignment.space-between;
|
||||
padding-right: 15px;
|
||||
Text {
|
||||
font-size: 16px;
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
color: Palette.control-foreground;
|
||||
text: @tr("Screenpad brightness");
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
width: 38%;
|
||||
alignment: LayoutAlignment.stretch;
|
||||
screen_bright := Slider {
|
||||
enabled: true;
|
||||
minimum: 0;
|
||||
maximum: 100;
|
||||
value: SystemPageData.screenpad_brightness;
|
||||
released(value) => {
|
||||
// SystemPageData.screenpad_brightness = self.value;
|
||||
SystemPageData.cb_screenpad_brightness(Math.floor(self.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
width: 20%;
|
||||
padding-left: 10px;
|
||||
alignment: LayoutAlignment.stretch;
|
||||
Switch {
|
||||
text: @tr("Sync with primary");
|
||||
checked <=> SystemPageData.screenpad_sync_with_primary;
|
||||
toggled => {
|
||||
SystemPageData.cb_screenpad_sync_with_primary(self.checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Palette.alternate-background;
|
||||
border-color: Palette.accent-background;
|
||||
|
||||
Reference in New Issue
Block a user