From 03f8dd97304059c2e6abfaaeb61be96c48109567 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 9 Nov 2023 14:36:37 -0600 Subject: [PATCH] fixing tweaks to obs initialization... it isn't working just yet. I need to create a default implimentation with obs working somehow... --- TODO.org | 5 +++- src/rust/obs.rs | 44 ++++++++++++++++++++++------------ src/rust/service_item_model.rs | 37 +++++++++++++++------------- 3 files changed, 54 insertions(+), 32 deletions(-) diff --git a/TODO.org b/TODO.org index d24fa47..61c57c8 100644 --- a/TODO.org +++ b/TODO.org @@ -3,9 +3,12 @@ :CATEGORY: dev :END: -* Tasks [0%] [0/0] +* Tasks [58%] [44/75] ** TODO Mouse needs to have resize shape when hovering controls [[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::Controls.SplitView {]] +** TODO Add a way to interact with OBS +The basic implementation is done. In order to make use of it in the odd broken QT way, i needed to implement clone on my stuct, but it worked out. +*** DONE OBWS ** TODO When updating background, it isn't changed in the list [[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::function updateBackground(backgroundType) {]] ** TODO Find segfault in webengine diff --git a/src/rust/obs.rs b/src/rust/obs.rs index 797bf63..8064031 100644 --- a/src/rust/obs.rs +++ b/src/rust/obs.rs @@ -7,7 +7,7 @@ use tracing::debug; pub struct Obs { scenes: Scenes, - client: Client, + client: Option, } impl fmt::Debug for Obs { @@ -23,7 +23,16 @@ impl Clone for Obs { fn clone(&self) -> Self { Self { scenes: self.scenes.clone(), - client: make_client(), + client: Some(make_client()), + } + } +} + +impl Default for Obs { + fn default() -> Self { + Self { + scenes: Scenes::default(), + client: None, } } } @@ -36,7 +45,7 @@ impl Obs { debug!(?scene_list); Ok(Self { scenes: scene_list, - client, + client: Some(client), }) } @@ -58,19 +67,24 @@ impl Obs { self, scene: String, ) -> Result<(), Box> { - if let Some(scene) = self - .scenes - .scenes - .iter() - .filter(|x| x.name == scene) - .next() - { - self.client - .scenes() - .set_current_program_scene(scene.name.as_str()); - Ok(()) + if self.client.is_some() { + if let Some(scene) = self + .scenes + .scenes + .iter() + .filter(|x| x.name == scene) + .next() + { + self.client + .unwrap() + .scenes() + .set_current_program_scene(scene.name.as_str()); + Ok(()) + } else { + Err("Couldn't set the scene".to_owned())? + } } else { - Err("Couldn't set the scene".to_owned())? + Err("There is no client".to_owned())? } } } diff --git a/src/rust/service_item_model.rs b/src/rust/service_item_model.rs index 869bd7b..5ea3323 100644 --- a/src/rust/service_item_model.rs +++ b/src/rust/service_item_model.rs @@ -84,25 +84,30 @@ mod service_item_model { } #[cxx_qt::qobject(base = "QAbstractListModel")] - #[derive(Debug)] + #[derive(Debug, Default)] pub struct ServiceItemMod { id: i32, service_items: Vec, - obs: Obs, + // obs: Obs, } - impl Default for ServiceItemMod { - fn default() -> Self { - let obs = tokio::runtime::Runtime::new() - .unwrap() - .block_on(async { Obs::new().await.ok().unwrap() }); - Self { - id: 0, - service_items: Vec::new(), - obs, - } - } - } + // impl Default for ServiceItemMod { + // fn default() -> Self { + // let obs = tokio::runtime::Runtime::new() + // .unwrap() + // .block_on(async { + // match Obs::new().await { + // Ok(o) => o, + // Err(e) => error!(e), + // } + // }); + // Self { + // id: 0, + // service_items: Vec::new(), + // obs, + // } + // } + // } #[cxx_qt::qsignals(ServiceItemMod)] pub enum Signals<'a> { @@ -600,7 +605,7 @@ mod service_item_model { // println!("service_item is deactivating {:?}", i); service_item.active = false; } - let obs = self.as_mut().obs_mut().clone(); + // let obs = self.as_mut().obs_mut().clone(); if let Some(service_item) = self .as_mut() @@ -612,7 +617,7 @@ mod service_item_model { background = ?service_item.background, background_type = ?service_item.background_type); service_item.active = true; - obs.set_scene(service_item.obs_scene.to_string()); + // obs.set_scene(service_item.obs_scene.to_string()); self.as_mut().emit_data_changed( tl, br,