mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Trying different strategies for non-blocking UI
This commit is contained in:
106
Cargo.lock
generated
106
Cargo.lock
generated
@@ -128,7 +128,7 @@ dependencies = [
|
||||
"asusd",
|
||||
"cargo-husky",
|
||||
"dmi_id",
|
||||
"gif",
|
||||
"gif 0.12.0",
|
||||
"glam",
|
||||
"gumdrop",
|
||||
"rog_anime",
|
||||
@@ -682,9 +682,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.86"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730"
|
||||
checksum = "3286b845d0fccbdd15af433f61c5970e711987036cb468f437ff6badd70f4e24"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@@ -879,7 +879,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "const-field-offset"
|
||||
version = "0.1.4"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"const-field-offset-macro",
|
||||
"field-offset",
|
||||
@@ -888,7 +888,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "const-field-offset-macro"
|
||||
version = "0.1.4"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1835,6 +1835,16 @@ dependencies = [
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.28.1"
|
||||
@@ -2134,9 +2144,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.6"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd"
|
||||
checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
@@ -2162,7 +2172,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
[[package]]
|
||||
name = "i-slint-backend-linuxkms"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"calloop",
|
||||
"drm",
|
||||
@@ -2181,7 +2191,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-backend-qt"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"const-field-offset",
|
||||
"i-slint-common",
|
||||
@@ -2193,7 +2203,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-backend-selector"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"i-slint-backend-linuxkms",
|
||||
@@ -2206,7 +2216,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-backend-winit"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
@@ -2240,7 +2250,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-common"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"derive_more",
|
||||
@@ -2251,7 +2261,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-compiler"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"by_address",
|
||||
"codemap",
|
||||
@@ -2280,7 +2290,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-core"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"auto_enums",
|
||||
"bytemuck",
|
||||
@@ -2323,7 +2333,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-core-macros"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
@@ -2332,7 +2342,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-renderer-femtovg"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"const-field-offset",
|
||||
@@ -2364,7 +2374,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "i-slint-renderer-skia"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
@@ -2440,15 +2450,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.8"
|
||||
version = "0.24.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23"
|
||||
checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"color_quant",
|
||||
"exr",
|
||||
"gif",
|
||||
"gif 0.13.1",
|
||||
"jpeg-decoder",
|
||||
"num-traits",
|
||||
"png",
|
||||
@@ -2848,9 +2858,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.12.2"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22"
|
||||
checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc"
|
||||
|
||||
[[package]]
|
||||
name = "lyon_algorithms"
|
||||
@@ -3132,7 +3142,7 @@ version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro-crate 3.1.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
@@ -3459,6 +3469,15 @@ dependencies = [
|
||||
"toml_edit 0.20.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284"
|
||||
dependencies = [
|
||||
"toml_edit 0.21.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
@@ -3714,7 +3733,7 @@ version = "5.0.8"
|
||||
dependencies = [
|
||||
"cargo-husky",
|
||||
"dmi_id",
|
||||
"gif",
|
||||
"gif 0.12.0",
|
||||
"glam",
|
||||
"log",
|
||||
"pix",
|
||||
@@ -4151,7 +4170,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "slint"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"const-field-offset",
|
||||
"i-slint-backend-selector",
|
||||
@@ -4167,7 +4186,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "slint-build"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"i-slint-compiler",
|
||||
"spin_on",
|
||||
@@ -4178,7 +4197,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "slint-macros"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"i-slint-compiler",
|
||||
"proc-macro2",
|
||||
@@ -4275,12 +4294,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
|
||||
checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4621,7 +4640,7 @@ dependencies = [
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"pin-project-lite",
|
||||
"socket2 0.5.5",
|
||||
"socket2 0.5.6",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
@@ -4689,6 +4708,17 @@ dependencies = [
|
||||
"winnow 0.5.40",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.21.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"winnow 0.5.40",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.6"
|
||||
@@ -4965,7 +4995,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "vtable"
|
||||
version = "0.1.11"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"const-field-offset",
|
||||
"portable-atomic",
|
||||
@@ -4976,7 +5006,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "vtable-macro"
|
||||
version = "0.1.10"
|
||||
source = "git+https://github.com/slint-ui/slint.git#fa2cf8c28aec3d15e8ba542cb603ef188e01ee94"
|
||||
source = "git+https://github.com/flukejones/sixtyfps.git#f63c4e3b8510e88a8496328a47e8a8dccdb1bcf3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5812,9 +5842,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "4.0.0"
|
||||
version = "4.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e09e8be97d44eeab994d752f341e67b3b0d80512a8b315a0671d47232ef1b65"
|
||||
checksum = "a660524eaa9f4a65c673006b034d2167a9a3ef821e9bd7311b2f1c77b904e312"
|
||||
dependencies = [
|
||||
"endi",
|
||||
"enumflags2",
|
||||
@@ -5825,11 +5855,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_derive"
|
||||
version = "4.0.0"
|
||||
version = "4.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72a5857e2856435331636a9fbb415b09243df4521a267c5bedcd5289b4d5799e"
|
||||
checksum = "55b1565fbb82205a83de0bd1293fb2b5c9e34d4e74250fd4aed54903545b1fa2"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro-crate 3.1.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
||||
@@ -42,18 +42,18 @@ versions.workspace = true
|
||||
nix = "^0.26.1"
|
||||
tempfile = "3.3.0"
|
||||
|
||||
i-slint-backend-selector = { git = "https://github.com/slint-ui/slint.git" }
|
||||
i-slint-core = { git = "https://github.com/slint-ui/slint.git" }
|
||||
i-slint-backend-winit = { git = "https://github.com/slint-ui/slint.git" }
|
||||
i-slint-backend-selector = { git = "https://github.com/flukejones/sixtyfps.git" }
|
||||
i-slint-core = { git = "https://github.com/flukejones/sixtyfps.git" }
|
||||
i-slint-backend-winit = { git = "https://github.com/flukejones/sixtyfps.git" }
|
||||
winit = "*"
|
||||
|
||||
[dependencies.slint]
|
||||
git = "https://github.com/slint-ui/slint.git"
|
||||
git = "https://github.com/flukejones/sixtyfps.git"
|
||||
default-features = false
|
||||
features = ["std", "compat-1-0", "backend-winit-wayland", "backend-linuxkms", "renderer-femtovg"]
|
||||
|
||||
[build-dependencies.slint-build]
|
||||
git = "https://github.com/slint-ui/slint.git"
|
||||
git = "https://github.com/flukejones/sixtyfps.git"
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-husky.workspace = true
|
||||
@@ -19,6 +19,7 @@ use rog_control_center::{
|
||||
get_ipc_file, on_tmp_dir_exists, print_versions, AvailableSystemProperties, MainWindow,
|
||||
RogDbusClientBlocking, SystemPage, QUIT_APP, SHOWING_GUI, SHOW_GUI,
|
||||
};
|
||||
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
|
||||
use tokio::runtime::Runtime;
|
||||
// use winit::monitor::VideoMode;
|
||||
// use winit::window::{Fullscreen, WindowLevel};
|
||||
@@ -176,37 +177,77 @@ fn setup_window(_states: Arc<Mutex<SystemState>>) -> MainWindow {
|
||||
// slint::platform::set_platform(Box::new(i_slint_backend_winit::Backend::new().
|
||||
// unwrap())).unwrap();
|
||||
let ui = MainWindow::new().unwrap();
|
||||
// Example of how to do work in another thread.
|
||||
// The thread itself can keep its own state, and then update vars in the UI
|
||||
// when required.
|
||||
let ui_handle = ui.as_weak();
|
||||
spawn(move || loop {
|
||||
sleep(Duration::from_secs(1));
|
||||
// This is where the actual update happens
|
||||
ui_handle
|
||||
.upgrade_in_event_loop(move |handle| {
|
||||
// handle.set_counter(handle.get_counter() + 1);
|
||||
use i_slint_backend_winit::WinitWindowAccessor;
|
||||
handle
|
||||
.window()
|
||||
.with_winit_window(|winit_window: &winit::window::Window| {
|
||||
// winit_window.set_fullscreen(Some(Fullscreen::Borderless(None)));
|
||||
if !winit_window.has_focus() {
|
||||
// slint::quit_event_loop().unwrap();
|
||||
// handle.hide().unwrap();
|
||||
}
|
||||
});
|
||||
})
|
||||
.ok();
|
||||
|
||||
let handle = ui.as_weak();
|
||||
ui.global::<SystemPage>().on_cancelled(move || {
|
||||
handle.upgrade_in_event_loop(|_handle| {}).ok();
|
||||
});
|
||||
|
||||
ui.global::<SystemPage>().on_set_charge(|v1, v2| {
|
||||
if v1 != v2 {
|
||||
dbg!(v1);
|
||||
dbg!(v2);
|
||||
}
|
||||
// TODO: macro
|
||||
let conn = zbus::blocking::Connection::system().unwrap();
|
||||
let proxy = PlatformProxyBlocking::new(&conn).unwrap();
|
||||
let proxy2 = proxy.clone();
|
||||
ui.global::<SystemPage>().on_set_charge_limit(move |limit| {
|
||||
dbg!(limit);
|
||||
proxy.set_charge_control_end_threshold(limit as u8).unwrap();
|
||||
});
|
||||
|
||||
ui.global::<SystemPage>().on_set_panel_od(move |od| {
|
||||
dbg!(od);
|
||||
proxy2.set_panel_od(od).unwrap();
|
||||
});
|
||||
|
||||
// let handle = ui.as_weak();
|
||||
// ui.global::<SystemPage>().on_applied(move || {
|
||||
// handle
|
||||
// .upgrade_in_event_loop(|handle| {
|
||||
// let data = handle.global::<SystemPage>();
|
||||
// let charge_changed = data.get_charge_limit() as i32 !=
|
||||
// data.get_last_charge_limit(); let charge =
|
||||
// data.get_charge_limit() as u8; tokio::spawn(async move {
|
||||
// let conn = zbus::Connection::system().await.unwrap();
|
||||
// let proxy = PlatformProxy::new(&conn).await.unwrap();
|
||||
// if charge_changed {
|
||||
// proxy
|
||||
// .set_charge_control_end_threshold(charge)
|
||||
// .await
|
||||
// .unwrap();
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
// .ok();
|
||||
// });
|
||||
|
||||
// or
|
||||
// let handle = ui.as_weak();
|
||||
// tokio::spawn(async move {
|
||||
// // TODO: macro
|
||||
// let conn = zbus::Connection::system().await.unwrap();
|
||||
// let proxy = PlatformProxy::new(&conn).await.unwrap();
|
||||
// let proxy2 = proxy.clone();
|
||||
// handle.upgrade_in_event_loop(move |handle| {
|
||||
// handle
|
||||
// .global::<SystemPage>()
|
||||
// .on_set_charge_limit(move |limit| {
|
||||
// let proxy = proxy.clone();
|
||||
// tokio::spawn(async move {
|
||||
// dbg!(limit);
|
||||
// proxy
|
||||
// .set_charge_control_end_threshold(limit as u8)
|
||||
// .await
|
||||
// .unwrap();
|
||||
// });
|
||||
// });
|
||||
// handle.global::<SystemPage>().on_set_panel_od(move |od| {
|
||||
// let proxy2 = proxy2.clone();
|
||||
// tokio::spawn(async move {
|
||||
// dbg!(od);
|
||||
// proxy2.set_panel_od(od).await.unwrap();
|
||||
// });
|
||||
// });
|
||||
// }).ok();
|
||||
// });
|
||||
|
||||
let props = AvailableSystemProperties {
|
||||
ac_command: true,
|
||||
bat_command: true,
|
||||
|
||||
@@ -2,8 +2,6 @@ import { VerticalBox , StandardButton, Button} from "std-widgets.slint";
|
||||
import { Theme } from "globals.slint";
|
||||
|
||||
export component SquareImageButton inherits Rectangle {
|
||||
// if (AppConsts.sdfsdf.length < 0): Rectangle { background: red; }
|
||||
|
||||
callback clicked;
|
||||
in-out property <image> img;
|
||||
border-radius: 7px;
|
||||
@@ -13,7 +11,7 @@ export component SquareImageButton inherits Rectangle {
|
||||
touch := TouchArea {
|
||||
clicked => {
|
||||
root.clicked();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +39,7 @@ export component RoundImageButton inherits Rectangle {
|
||||
touch := TouchArea {
|
||||
clicked => {
|
||||
root.clicked();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +64,7 @@ export component SquareCharButton inherits Rectangle {
|
||||
touch := TouchArea {
|
||||
clicked => {
|
||||
root.clicked();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,26 +92,26 @@ export component ValueBar inherits Rectangle {
|
||||
// do a percentage of each half as 0-50%
|
||||
if (value >= max + min) {
|
||||
return (value - (max + min) / 2) / (max - min);
|
||||
|
||||
|
||||
}
|
||||
return 0.50 - (value - (min - max) / 2) / (max - min);
|
||||
|
||||
|
||||
}
|
||||
return (value - min) / (max - min);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function set_x(min: float, max: float, value: float, width: length) -> length{
|
||||
if (min < 0.0 && max > 0.0) {
|
||||
if (value < max + min) {
|
||||
return width / 2 - width * (percentage(min, max, value));
|
||||
|
||||
|
||||
}
|
||||
return width / 2;
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -152,7 +150,7 @@ export component SpinBoxUni inherits Rectangle {
|
||||
clicked => {
|
||||
if (root.value > root.minimum) {
|
||||
root.value -= 1;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +176,7 @@ export component SpinBoxUni inherits Rectangle {
|
||||
clicked => {
|
||||
if (root.value < root.maximum) {
|
||||
root.value += 1;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,7 +238,7 @@ export component PopupNotification {
|
||||
|
||||
public function show() {
|
||||
_p.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ValueBar } from "../common_widgets.slint";
|
||||
import { ValueBar, SquareCharButton } from "../common_widgets.slint";
|
||||
import { Theme } from "../globals.slint";
|
||||
import { HorizontalBox , VerticalBox, ScrollView, Slider} from "std-widgets.slint";
|
||||
import { HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch} from "std-widgets.slint";
|
||||
|
||||
export struct AvailableSystemProperties {
|
||||
charge_limit: bool,
|
||||
@@ -28,126 +28,175 @@ export struct SystemValues {
|
||||
}
|
||||
|
||||
export global SystemPage {
|
||||
in-out property <int> charge-limit;
|
||||
callback set_charge(/* charge limit */ int, /* last limit */ int);
|
||||
in-out property <float> charge_limit;
|
||||
in-out property <int> last_charge_limit;
|
||||
callback set_charge_limit(/* charge limit */ int);
|
||||
|
||||
in-out property <bool> panel_od;
|
||||
in-out property <bool> last_panel_od;
|
||||
callback set_panel_od(/* panel_od */ bool);
|
||||
|
||||
callback applied();
|
||||
callback cancelled();
|
||||
|
||||
in-out property <AvailableSystemProperties> available;
|
||||
in-out property <SystemValues> values;
|
||||
}
|
||||
|
||||
export component PageSystem inherits Rectangle {
|
||||
background: Theme.background-color;
|
||||
ScrollView {
|
||||
VerticalLayout {
|
||||
// padding: 10px;
|
||||
|
||||
VerticalLayout {
|
||||
ScrollView {
|
||||
VerticalLayout {
|
||||
// padding: 10px;
|
||||
spacing: 10px;
|
||||
min-height: root.height;
|
||||
if SystemPage.available.charge-limit: Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("ChargeMode" => "Charging mode");
|
||||
}
|
||||
min-height: root.height;
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("ChargeLimit" => "Charge limit");
|
||||
}
|
||||
if SystemPage.available.charge-limit: Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
|
||||
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;
|
||||
HorizontalBox {
|
||||
alignment: LayoutAlignment.start;
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("ChargeLimit" => "Charge limit");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: "\{Math.floor(SystemPage.charge_limit)}";
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalBox {
|
||||
TouchArea { }
|
||||
|
||||
charge_slider := Slider {
|
||||
maximum: 100;
|
||||
minimum: 20;
|
||||
value <=> SystemPage.charge_limit;
|
||||
released => {
|
||||
SystemPage.set_charge_limit(SystemPage.charge_limit)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if SystemPage.available.panel-od: Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
if SystemPage.available.panel-od: Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
HorizontalBox {
|
||||
alignment: LayoutAlignment.start;
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
}
|
||||
Switch {
|
||||
checked <=> SystemPage.panel_od;
|
||||
toggled => {
|
||||
SystemPage.set_panel_od(SystemPage.panel_od)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("nv_dynamic_boost" => "nv_dynamic_boost");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("nv_temp_target" => "nv_temp_target");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("ppt_pl1_spl" => "ppt_pl1_spl");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("ppt_pl2_sppt" => "ppt_pl2_sppt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("nv_dynamic_boost" => "nv_dynamic_boost");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("nv_temp_target" => "nv_temp_target");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("ppt_pl1_spl" => "ppt_pl1_spl");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("ppt_pl2_sppt" => "ppt_pl2_sppt");
|
||||
HorizontalLayout {
|
||||
Button {
|
||||
text: "Apply";
|
||||
clicked => {
|
||||
if SystemPage.last_charge_limit != Math.floor(SystemPage.charge_limit) {
|
||||
SystemPage.set_charge_limit(SystemPage.charge_limit);
|
||||
SystemPage.last_charge_limit = Math.floor(SystemPage.charge_limit);
|
||||
}
|
||||
SystemPage.applied();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
background: Theme.background-color;
|
||||
VerticalBox {
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PanelOverdrive" => "Panel Overdrive");
|
||||
}
|
||||
|
||||
Text {
|
||||
color: Theme.text-foreground-color;
|
||||
text: @tr("PerformanceProfile" => "Performance Profile");
|
||||
}
|
||||
Button {
|
||||
text: "Cancel";
|
||||
clicked => {
|
||||
SystemPage.charge_limit = SystemPage.last_charge_limit;
|
||||
SystemPage.cancelled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user