fixing tweaks to obs initialization...

it isn't working just yet. I need to create a default implimentation
with obs working somehow...
This commit is contained in:
Chris Cochrun 2023-11-09 14:36:37 -06:00
parent 07b6663a35
commit 03f8dd9730
3 changed files with 54 additions and 32 deletions

View file

@ -3,9 +3,12 @@
:CATEGORY: dev :CATEGORY: dev
:END: :END:
* Tasks [0%] [0/0] * Tasks [58%] [44/75]
** TODO Mouse needs to have resize shape when hovering controls ** TODO Mouse needs to have resize shape when hovering controls
[[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::Controls.SplitView {]] [[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 ** TODO When updating background, it isn't changed in the list
[[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::function updateBackground(backgroundType) {]] [[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::function updateBackground(backgroundType) {]]
** TODO Find segfault in webengine ** TODO Find segfault in webengine

View file

@ -7,7 +7,7 @@ use tracing::debug;
pub struct Obs { pub struct Obs {
scenes: Scenes, scenes: Scenes,
client: Client, client: Option<Client>,
} }
impl fmt::Debug for Obs { impl fmt::Debug for Obs {
@ -23,7 +23,16 @@ impl Clone for Obs {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
scenes: self.scenes.clone(), 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); debug!(?scene_list);
Ok(Self { Ok(Self {
scenes: scene_list, scenes: scene_list,
client, client: Some(client),
}) })
} }
@ -58,6 +67,7 @@ impl Obs {
self, self,
scene: String, scene: String,
) -> Result<(), Box<dyn Error>> { ) -> Result<(), Box<dyn Error>> {
if self.client.is_some() {
if let Some(scene) = self if let Some(scene) = self
.scenes .scenes
.scenes .scenes
@ -66,12 +76,16 @@ impl Obs {
.next() .next()
{ {
self.client self.client
.unwrap()
.scenes() .scenes()
.set_current_program_scene(scene.name.as_str()); .set_current_program_scene(scene.name.as_str());
Ok(()) Ok(())
} else { } else {
Err("Couldn't set the scene".to_owned())? Err("Couldn't set the scene".to_owned())?
} }
} else {
Err("There is no client".to_owned())?
}
} }
} }

View file

@ -84,25 +84,30 @@ mod service_item_model {
} }
#[cxx_qt::qobject(base = "QAbstractListModel")] #[cxx_qt::qobject(base = "QAbstractListModel")]
#[derive(Debug)] #[derive(Debug, Default)]
pub struct ServiceItemMod { pub struct ServiceItemMod {
id: i32, id: i32,
service_items: Vec<ServiceItm>, service_items: Vec<ServiceItm>,
obs: Obs, // obs: Obs,
} }
impl Default for ServiceItemMod { // impl Default for ServiceItemMod {
fn default() -> Self { // fn default() -> Self {
let obs = tokio::runtime::Runtime::new() // let obs = tokio::runtime::Runtime::new()
.unwrap() // .unwrap()
.block_on(async { Obs::new().await.ok().unwrap() }); // .block_on(async {
Self { // match Obs::new().await {
id: 0, // Ok(o) => o,
service_items: Vec::new(), // Err(e) => error!(e),
obs, // }
} // });
} // Self {
} // id: 0,
// service_items: Vec::new(),
// obs,
// }
// }
// }
#[cxx_qt::qsignals(ServiceItemMod)] #[cxx_qt::qsignals(ServiceItemMod)]
pub enum Signals<'a> { pub enum Signals<'a> {
@ -600,7 +605,7 @@ mod service_item_model {
// println!("service_item is deactivating {:?}", i); // println!("service_item is deactivating {:?}", i);
service_item.active = false; 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 if let Some(service_item) = self
.as_mut() .as_mut()
@ -612,7 +617,7 @@ mod service_item_model {
background = ?service_item.background, background = ?service_item.background,
background_type = ?service_item.background_type); background_type = ?service_item.background_type);
service_item.active = true; 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( self.as_mut().emit_data_changed(
tl, tl,
br, br,