starting to change slide_model to have the logic of changing slides

In order to make slide_object dumber and and not need to keep track of
slide info, we are moving the business logic to slide_model so that
the model can keep track of whether presentations are ready to switch
and don't need to run reveal_next or something.
This commit is contained in:
Chris Cochrun 2024-09-26 14:11:30 -05:00
parent 4c403d9f3c
commit 8c7f2d794f
4 changed files with 84 additions and 56 deletions

View file

@ -1,13 +1,13 @@
#[cxx_qt::bridge]
mod slide_object {
pub mod slide_object {
unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString;
include!("cxx-qt-lib/qmap.h");
type QMap_QString_QVariant =
cxx_qt_lib::QMap<cxx_qt_lib::QMapPair_QString_QVariant>;
include!("cxx-qt-gen/slide_model.cxxqt.h");
type SlideModel = crate::slide_model::slide_model::SlideModel;
// include!("cxx-qt-gen/slide_model.cxxqt.h");
// type SlideModel = crate::slide_model::slide_model::SlideModel;
}
unsafe extern "RustQt" {
@ -54,7 +54,7 @@ mod slide_object {
#[qproperty(i32, font_size)]
#[qproperty(f32, video_start_time)]
#[qproperty(f32, video_end_time)]
#[qproperty(*mut SlideModel, slide_model)]
// #[qproperty(*mut SlideModel, slide_model)]
type SlideObject = super::SlideObjectRust;
#[qinvokable]
@ -89,7 +89,7 @@ use cxx_qt_lib::{CaseSensitivity, QString, QVariant};
use tracing::{debug, error};
use crate::{
slide_model::slide_model, slide_types::{PresType, SlideType}, songs::song_model::{song_model::SongModel, SongModelRust}
slide_model::{slide_model, Slide}, slide_types::SlideType
};
use self::slide_object::QMap_QString_QVariant;
@ -113,7 +113,7 @@ pub struct SlideObjectRust {
font_size: i32,
video_start_time: f32,
video_end_time: f32,
slide_model: *mut slide_model::SlideModel,
// slide_model: *mut slide_model::SlideModel,
}
impl Default for SlideObjectRust {
@ -136,7 +136,7 @@ impl Default for SlideObjectRust {
inner_slide_index: 0,
video_start_time: 0.0,
video_end_time: 0.0,
slide_model: std::ptr::null_mut(),
// slide_model: std::ptr::null_mut(),
}
}
}
@ -477,4 +477,23 @@ impl slide_object::SlideObject {
self.as_mut().playing_changed(!playing);
!playing
}
pub fn set_slide(mut self: Pin<&mut Self>, slide: &Slide) {
self.as_mut().set_slide_index(slide.service_item_id);
self.as_mut().set_slide_size(slide.slide_count);
self.as_mut().set_looping(slide.looping);
self.as_mut().set_text(QString::from(&slide.text));
self.as_mut().set_ty(QString::from(&slide.ty));
self.as_mut().set_audio(QString::from(&slide.audio));
self.as_mut().set_image_background(QString::from(&slide.image_background));
self.as_mut().set_video_background(QString::from(&slide.video_background));
self.as_mut().set_vtext_alignment(QString::from(&slide.vtext_alignment));
self.as_mut().set_htext_alignment(QString::from(&slide.htext_alignment));
self.as_mut().set_font(QString::from(&slide.font));
self.as_mut().set_font_size(slide.font_size);
self.as_mut().set_video_start_time(slide.video_start_time);
self.as_mut().set_video_end_time(slide.video_end_time);
self.as_mut().set_html(slide.html);
self.as_mut().set_inner_slide_index(slide.slide_index);
self.as_mut().set_is_playing(true);
}
}