some possible ideas for how obs should work

This commit is contained in:
Chris Cochrun 2023-11-29 09:48:09 -06:00
parent f125026544
commit 1de0058646
2 changed files with 89 additions and 2 deletions

View file

@ -227,6 +227,7 @@ pub struct Slide {
video_start_time: f32,
video_end_time: f32,
html: bool,
obs_scene: QString,
}
impl Default for Slide {
@ -251,6 +252,7 @@ impl Default for Slide {
video_start_time: 0.0,
video_end_time: 0.0,
html: false,
obs_scene: QString::default(),
}
}
}
@ -259,6 +261,7 @@ impl Default for Slide {
pub struct SlideModelRust {
id: i32,
slides: Vec<Slide>,
obs: Option<Obs>,
count: i32,
}
@ -605,6 +608,35 @@ impl slide_model::SlideModel {
service_item: &QMap_QString_QVariant,
) {
println!("add rust slide {:?}", index);
let mut slide = Slide::default();
let iter = service_item.iter();
for (key, value) in iter {
debug!(?key);
match key.to_string().to_str() {
"ty" => slide.ty = QString::from(value),
"background" => {
slide.background = QString::from(value)
}
"backgroundType" => {
slide.background_type = QString::from(value)
}
"audio" => slide.audio = QString::from(value),
"font" => slide.font = QString::from(value),
"fontSize" => slide.font_size = QString::from(value),
"looping" => slide.looping = QString::from(value),
"slideCount" => {
slide.slide_count = QString::from(value)
}
"videoEndTime" => {
slide.video_end_time = QString::from(value)
}
"videoStartTime" => {
slide.video_end_time = QString::from(value)
}
}
}
let ty = service_item
.get(&QString::from("ty"))
.unwrap_or(QVariant::from(&QString::from("")))
@ -632,8 +664,6 @@ impl slide_model::SlideModel {
Vec::<QString>::from(&QList_QString::from(&textlist));
// let vec_slize: &[usize] = &text_vec;
let mut slide = Slide::default();
slide.ty = service_item
.get(&QString::from("type"))
.unwrap_or(QVariant::from(&QString::from("")))
@ -1014,6 +1044,9 @@ impl slide_model::SlideModel {
// println!("slide is deactivating {:?}", i);
slide.active = false;
}
let obs = self.as_mut().obs.clone();
if let Some(slide) =
self.as_mut().rust_mut().slides.get_mut(index as usize)
{
@ -1034,6 +1067,14 @@ impl slide_model::SlideModel {
// );
slide.active = true;
self.as_mut().data_changed(tl, br, &vector_roles);
if let Some(obs) = obs {
match obs.set_scene(slide.obs_scene.to_string()) {
Ok(()) => debug!("Successfully set scene"),
Err(e) => error!(e),
}
}
// We use this signal generated by our signals enum to tell QML that
// the active slide has changed which is used to reposition views.
self.as_mut().active_change(&index);