making obs an option so that incase of errors we can set to None

This is really effective since it means we can still launch the app
without obs running too. Now I'll still need to figure out why it's
having problems though.
This commit is contained in:
Chris Cochrun 2023-11-13 10:36:49 -06:00
parent b1eef88c8a
commit 7bf4341819

View file

@ -84,30 +84,33 @@ mod service_item_model {
} }
#[cxx_qt::qobject(base = "QAbstractListModel")] #[cxx_qt::qobject(base = "QAbstractListModel")]
#[derive(Debug, Default)] #[derive(Debug)]
pub struct ServiceItemMod { pub struct ServiceItemMod {
id: i32, id: i32,
service_items: Vec<ServiceItm>, service_items: Vec<ServiceItm>,
// obs: Obs, obs: Option<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 { .block_on(async {
// match Obs::new().await { match Obs::new().await {
// Ok(o) => o, Ok(o) => Some(o),
// Err(e) => error!(e), Err(e) => {
// } error!(e);
// }); None
// Self { },
// id: 0, }
// service_items: Vec::new(), });
// 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> {
@ -605,7 +608,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()
@ -617,7 +620,9 @@ 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()); if let Some(obs) = obs {
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,