mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Formulate slint patterns
This commit is contained in:
@@ -16,8 +16,8 @@ use rog_control_center::system_state::{AuraCreation, SystemState};
|
|||||||
use rog_control_center::tray::init_tray;
|
use rog_control_center::tray::init_tray;
|
||||||
use rog_control_center::update_and_notify::{start_notifications, EnabledNotifications};
|
use rog_control_center::update_and_notify::{start_notifications, EnabledNotifications};
|
||||||
use rog_control_center::{
|
use rog_control_center::{
|
||||||
get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, RogDbusClientBlocking, QUIT_APP,
|
get_ipc_file, on_tmp_dir_exists, print_versions, AvailableSystemProperties, MainWindow,
|
||||||
SHOWING_GUI, SHOW_GUI,
|
RogDbusClientBlocking, SystemPage, QUIT_APP, SHOWING_GUI, SHOW_GUI,
|
||||||
};
|
};
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
// use winit::monitor::VideoMode;
|
// use winit::monitor::VideoMode;
|
||||||
@@ -200,6 +200,31 @@ fn setup_window(_states: Arc<Mutex<SystemState>>) -> MainWindow {
|
|||||||
.ok();
|
.ok();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.global::<SystemPage>().on_set_charge(|v1, v2| {
|
||||||
|
if v1 != v2 {
|
||||||
|
dbg!(v1);
|
||||||
|
dbg!(v2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let props = AvailableSystemProperties {
|
||||||
|
ac_command: true,
|
||||||
|
bat_command: true,
|
||||||
|
charge_limit: true,
|
||||||
|
disable_nvidia_powerd_on_battery: true,
|
||||||
|
mini_led_mode: true,
|
||||||
|
nv_dynamic_boost: true,
|
||||||
|
nv_temp_target: true,
|
||||||
|
panel_od: true,
|
||||||
|
ppt_apu_sppt: true,
|
||||||
|
ppt_fppt: true,
|
||||||
|
ppt_pl1_spl: true,
|
||||||
|
ppt_pl2_sppt: true,
|
||||||
|
ppt_platform_sppt: true,
|
||||||
|
throttle_policy: true,
|
||||||
|
};
|
||||||
|
ui.global::<SystemPage>().set_available(props);
|
||||||
|
|
||||||
ui.on_exit_app(move || {
|
ui.on_exit_app(move || {
|
||||||
slint::quit_event_loop().unwrap();
|
slint::quit_event_loop().unwrap();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ impl SystemState {
|
|||||||
aura,
|
aura,
|
||||||
anime: AnimeState::new(&asus_dbus)
|
anime: AnimeState::new(&asus_dbus)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
let e = format!("Could not get AanimeState state: {e}");
|
let e = format!("Could not get AnimeState state: {e}");
|
||||||
error!("{e}");
|
error!("{e}");
|
||||||
})
|
})
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Button, VerticalBox } from "std-widgets.slint";
|
import { Button, VerticalBox } from "std-widgets.slint";
|
||||||
import { SpinBoxUni, ValueBar, SquareImageButton, RoundImageButton } from "common_widgets.slint";
|
import { SpinBoxUni, ValueBar, SquareImageButton, RoundImageButton } from "common_widgets.slint";
|
||||||
import { Theme, AppSize } from "globals.slint";
|
import { Theme, AppSize } from "globals.slint";
|
||||||
import { PageSystem } from "pages/system.slint";
|
import { PageSystem, AvailableSystemProperties, SystemPage } from "pages/system.slint";
|
||||||
import { SideBar } from "widgets/sidebar.slint";
|
import { SideBar } from "widgets/sidebar.slint";
|
||||||
import { PageAbout } from "pages/about.slint";
|
import { PageAbout } from "pages/about.slint";
|
||||||
import { PageGpu } from "pages/gpu.slint";
|
import { PageGpu } from "pages/gpu.slint";
|
||||||
@@ -9,20 +9,22 @@ import { PageFans } from "pages/fans.slint";
|
|||||||
import { PageAnime } from "pages/anime.slint";
|
import { PageAnime } from "pages/anime.slint";
|
||||||
import { PageAura } from "pages/aura.slint";
|
import { PageAura } from "pages/aura.slint";
|
||||||
|
|
||||||
export { AppSize, Theme }
|
export { AppSize, Theme, AvailableSystemProperties, SystemPage }
|
||||||
|
|
||||||
export component MainWindow inherits Window {
|
export component MainWindow inherits Window {
|
||||||
default-font-family: "DejaVu Sans";
|
default-font-family: "DejaVu Sans";
|
||||||
private property <bool> show-notif;
|
private property <bool> show-notif;
|
||||||
private property <bool> fade-cover;
|
private property <bool> fade-cover;
|
||||||
callback exit-app();
|
callback exit-app();
|
||||||
callback request-increase-value();
|
|
||||||
callback show-notification(bool);
|
callback show-notification(bool);
|
||||||
show-notification(yes) => {
|
show-notification(yes) => {
|
||||||
show-notif = yes;
|
show-notif = yes;
|
||||||
fade-cover = yes;
|
fade-cover = yes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
in-out property <bool> charge-available;
|
||||||
|
|
||||||
height: AppSize.height;
|
height: AppSize.height;
|
||||||
width: AppSize.width;
|
width: AppSize.width;
|
||||||
background: Colors.orange;
|
background: Colors.orange;
|
||||||
@@ -42,7 +44,7 @@ export component MainWindow inherits Window {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
background: Colors.purple;
|
background: Colors.purple;
|
||||||
if(side-bar.current-item == 0): PageSystem {
|
if(side-bar.current-item == 0): page := PageSystem {
|
||||||
width: root.width - side-bar.width;
|
width: root.width - side-bar.width;
|
||||||
height: root.height + 12px;
|
height: root.height + 12px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,38 @@
|
|||||||
import { ValueBar } from "../common_widgets.slint";
|
import { ValueBar } from "../common_widgets.slint";
|
||||||
import { Theme } from "../globals.slint";
|
import { Theme } from "../globals.slint";
|
||||||
import { HorizontalBox , VerticalBox, ScrollView} from "std-widgets.slint";
|
import { HorizontalBox , VerticalBox, ScrollView, Slider} 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 <int> charge-limit;
|
||||||
|
callback set_charge(/* charge limit */ int, /* last limit */ int);
|
||||||
|
in-out property <AvailableSystemProperties> available;
|
||||||
|
in-out property <SystemValues> values;
|
||||||
|
}
|
||||||
|
|
||||||
export component PageSystem inherits Rectangle {
|
export component PageSystem inherits Rectangle {
|
||||||
background: Theme.background-color;
|
background: Theme.background-color;
|
||||||
@@ -9,7 +41,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
// padding: 10px;
|
// padding: 10px;
|
||||||
spacing: 10px;
|
spacing: 10px;
|
||||||
min-height: root.height;
|
min-height: root.height;
|
||||||
Rectangle {
|
if SystemPage.available.charge-limit: Rectangle {
|
||||||
background: Theme.background-color;
|
background: Theme.background-color;
|
||||||
VerticalBox {
|
VerticalBox {
|
||||||
Text {
|
Text {
|
||||||
@@ -21,10 +53,20 @@ export component PageSystem inherits Rectangle {
|
|||||||
color: Theme.text-foreground-color;
|
color: Theme.text-foreground-color;
|
||||||
text: @tr("ChargeLimit" => "Charge limit");
|
text: @tr("ChargeLimit" => "Charge limit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
charge_slider := Slider {
|
||||||
|
value: SystemPage.values.charge_limit;
|
||||||
|
changed => {
|
||||||
|
if SystemPage.values.last_charge_limit != charge_slider.value {
|
||||||
|
SystemPage.set_charge(charge_slider.value, SystemPage.values.last_charge_limit);
|
||||||
|
SystemPage.values.last_charge_limit = charge_slider.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
if SystemPage.available.panel-od: Rectangle {
|
||||||
background: Theme.background-color;
|
background: Theme.background-color;
|
||||||
VerticalBox {
|
VerticalBox {
|
||||||
Text {
|
Text {
|
||||||
|
|||||||
Reference in New Issue
Block a user