1786089862

This commit is contained in:
2026-08-07 10:04:22 +02:00
parent 106af2a13d
commit 7d9bda13e9
4 changed files with 268 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
use std::{thread::sleep, time::Duration};
use slint::{ModelRc, VecModel};
mod rgba;
#[cfg(not(feature = "dev"))]
@@ -6,21 +6,31 @@ mod trekstor;
slint::include_modules!();
fn main() -> Result<(), slint::PlatformError> {
#[tokio::main]
async fn main() -> Result<(), slint::PlatformError> {
#[cfg(not(feature = "dev"))]
slint::platform::set_platform(Box::new(crate::trekstor::Trekstor::new()))
.expect("set platform");
let main_window = MainWindow::new()?;
let weak_window = main_window.as_weak();
slint::spawn_local(async move {
sleep(Duration::from_secs(5));
weak_window.upgrade_in_event_loop(move |ui| {
ui.set_text("GoodBye!".into());
})
})
.unwrap();
let lights = vec![LightData {
available: true,
entity_id: "light.living_room".into(),
name: "Living Room Lights".into(),
on: false,
}];
main_window.set_lights(ModelRc::new(VecModel::from(lights)));
// let weak_window = main_window.as_weak();
// slint::spawn_local(async move {
// sleep(Duration::from_secs(5));
// weak_window.upgrade_in_event_loop(move |ui| {
// ui.set_text("GoodBye!".into());
// })
// })
// .unwrap();
main_window.run()
}