some possible ideas for how obs should work
This commit is contained in:
parent
f125026544
commit
1de0058646
2 changed files with 89 additions and 2 deletions
|
@ -70,6 +70,9 @@ mod presentation_model {
|
||||||
// index: i32,
|
// index: i32,
|
||||||
// updated_path: QString,
|
// updated_path: QString,
|
||||||
// ) -> bool;
|
// ) -> bool;
|
||||||
|
// #[qinvokable]
|
||||||
|
// fn duplicate_item(self: Pin<&mut Self>, index: i32) -> bool;
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn get_item(
|
fn get_item(
|
||||||
self: Pin<&mut PresentationModel>,
|
self: Pin<&mut PresentationModel>,
|
||||||
|
@ -409,6 +412,34 @@ impl presentation_model::PresentationModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fn insert_presentation(
|
||||||
|
// mut self: Pin<&mut Self>,
|
||||||
|
// presentation: Presentation,
|
||||||
|
// index: i32,
|
||||||
|
// ) {
|
||||||
|
// unsafe {
|
||||||
|
// self.as_mut().begin_insert_rows(
|
||||||
|
// &QModelIndex::default(),
|
||||||
|
// index,
|
||||||
|
// index,
|
||||||
|
// );
|
||||||
|
// self.as_mut()
|
||||||
|
// .rust_mut()
|
||||||
|
// .presentations
|
||||||
|
// .insert(index as usize, presentation);
|
||||||
|
// self.as_mut().end_insert_rows();
|
||||||
|
// }
|
||||||
|
// let iter = self
|
||||||
|
// .as_mut()
|
||||||
|
// .presentations
|
||||||
|
// .iter()
|
||||||
|
// .enumerate()
|
||||||
|
// .filter(|p| p.id > index);
|
||||||
|
// for p in iter {
|
||||||
|
// p.id = p.id + 1;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
pub fn get_item(
|
pub fn get_item(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -434,6 +465,21 @@ impl presentation_model::PresentationModel {
|
||||||
qvariantmap
|
qvariantmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn duplicate_item(
|
||||||
|
mut self: Pin<&mut Self>,
|
||||||
|
index: i32,
|
||||||
|
) -> bool {
|
||||||
|
let binding = self.as_mut();
|
||||||
|
let pres = binding.presentations.get(index as usize).clone();
|
||||||
|
if let Some(item) = pres {
|
||||||
|
let item = item.clone();
|
||||||
|
binding.add_presentation(item);
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_title(
|
pub fn update_title(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
|
|
@ -227,6 +227,7 @@ pub struct Slide {
|
||||||
video_start_time: f32,
|
video_start_time: f32,
|
||||||
video_end_time: f32,
|
video_end_time: f32,
|
||||||
html: bool,
|
html: bool,
|
||||||
|
obs_scene: QString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Slide {
|
impl Default for Slide {
|
||||||
|
@ -251,6 +252,7 @@ impl Default for Slide {
|
||||||
video_start_time: 0.0,
|
video_start_time: 0.0,
|
||||||
video_end_time: 0.0,
|
video_end_time: 0.0,
|
||||||
html: false,
|
html: false,
|
||||||
|
obs_scene: QString::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,6 +261,7 @@ impl Default for Slide {
|
||||||
pub struct SlideModelRust {
|
pub struct SlideModelRust {
|
||||||
id: i32,
|
id: i32,
|
||||||
slides: Vec<Slide>,
|
slides: Vec<Slide>,
|
||||||
|
obs: Option<Obs>,
|
||||||
count: i32,
|
count: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,6 +608,35 @@ impl slide_model::SlideModel {
|
||||||
service_item: &QMap_QString_QVariant,
|
service_item: &QMap_QString_QVariant,
|
||||||
) {
|
) {
|
||||||
println!("add rust slide {:?}", index);
|
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
|
let ty = service_item
|
||||||
.get(&QString::from("ty"))
|
.get(&QString::from("ty"))
|
||||||
.unwrap_or(QVariant::from(&QString::from("")))
|
.unwrap_or(QVariant::from(&QString::from("")))
|
||||||
|
@ -632,8 +664,6 @@ impl slide_model::SlideModel {
|
||||||
Vec::<QString>::from(&QList_QString::from(&textlist));
|
Vec::<QString>::from(&QList_QString::from(&textlist));
|
||||||
// let vec_slize: &[usize] = &text_vec;
|
// let vec_slize: &[usize] = &text_vec;
|
||||||
|
|
||||||
let mut slide = Slide::default();
|
|
||||||
|
|
||||||
slide.ty = service_item
|
slide.ty = service_item
|
||||||
.get(&QString::from("type"))
|
.get(&QString::from("type"))
|
||||||
.unwrap_or(QVariant::from(&QString::from("")))
|
.unwrap_or(QVariant::from(&QString::from("")))
|
||||||
|
@ -1014,6 +1044,9 @@ impl slide_model::SlideModel {
|
||||||
// println!("slide is deactivating {:?}", i);
|
// println!("slide is deactivating {:?}", i);
|
||||||
slide.active = false;
|
slide.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let obs = self.as_mut().obs.clone();
|
||||||
|
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().rust_mut().slides.get_mut(index as usize)
|
self.as_mut().rust_mut().slides.get_mut(index as usize)
|
||||||
{
|
{
|
||||||
|
@ -1034,6 +1067,14 @@ impl slide_model::SlideModel {
|
||||||
// );
|
// );
|
||||||
slide.active = true;
|
slide.active = true;
|
||||||
self.as_mut().data_changed(tl, br, &vector_roles);
|
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
|
// We use this signal generated by our signals enum to tell QML that
|
||||||
// the active slide has changed which is used to reposition views.
|
// the active slide has changed which is used to reposition views.
|
||||||
self.as_mut().active_change(&index);
|
self.as_mut().active_change(&index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue