#[cxx_qt::bridge] pub mod slide_model { unsafe extern "C++" { include!(< QAbstractListModel >); type QAbstractListModel; include!("cxx-qt-lib/qhash.h"); type QHash_i32_QByteArray = cxx_qt_lib::QHash; include!("cxx-qt-lib/qmap.h"); type QMap_QString_QVariant = cxx_qt_lib::QMap; include!("cxx-qt-lib/qvariant.h"); type QVariant = cxx_qt_lib::QVariant; include!("cxx-qt-lib/qstring.h"); type QString = cxx_qt_lib::QString; include!("cxx-qt-lib/qmodelindex.h"); type QModelIndex = cxx_qt_lib::QModelIndex; include!("cxx-qt-lib/qvector.h"); type QVector_i32 = cxx_qt_lib::QVector; include!("cxx-qt-lib/qlist.h"); type QList_QString = cxx_qt_lib::QList; include!("liblumina/src/rust/slide_object.cxxqt.h"); type SlideObject = crate::slide_object::qobject::SlideObject; include!("liblumina/src/rust/songs/song_model.cxxqt.h"); type SongModel = crate::songs::song_model::song_model::SongModel; include!("liblumina/src/rust/video_model.cxxqt.h"); type VideoModel = crate::video_model::video_model::VideoModel; include!("liblumina/src/rust/image_model.cxxqt.h"); type ImageModel = crate::image_model::image_model::ImageModel; include!("liblumina/src/rust/presentation_model.cxxqt.h"); type PresentationModel = crate::presentation_model::presentation_model::PresentationModel; } // extern "C++" { // type SlideObject = crate::slide_object::qobject::SlideObject; // } #[qenum(SlideModel)] enum SlideRoles { Ty, Text, Audio, ImageBackground, VideoBackground, HTextAlignment, VTextAlignment, Font, FontSize, ServiceItemId, SlideIndex, SlideCount, Active, Selected, Looping, VideoThumbnail, VideoStartTime, VideoEndTime, Html, ObsScene, } #[auto_cxx_name] #[auto_rust_name] unsafe extern "RustQt" { #[qobject] #[base = QAbstractListModel] #[qml_element] #[qproperty(i32, count)] #[qproperty(*mut SlideObject, slide_object)] // #[qproperty(*mut SongModel, song_model)] // #[qproperty(*mut VideoModel, video_model)] // #[qproperty(*mut ImageModel, image_model)] // #[qproperty(*mut PresentationModel, presentation_model)] type SlideModel = super::SlideModelRust; #[inherit] #[qsignal] #[cxx_name = "dataChanged"] fn data_changed( self: Pin<&mut SlideModel>, top_left: &QModelIndex, bottom_right: &QModelIndex, roles: &QVector_i32, ); #[qsignal] fn active_changed(self: Pin<&mut SlideModel>, index: &i32); #[qinvokable] fn add_video_thumbnail( self: Pin<&mut SlideModel>, index: i32, ) -> bool; #[qinvokable] fn clear(self: Pin<&mut SlideModel>); #[qinvokable] fn remove_item_from_service( self: Pin<&mut SlideModel>, index: i32, _service_item: &QMap_QString_QVariant, ); #[qinvokable] fn remove_item(self: Pin<&mut SlideModel>, index: i32); #[qinvokable] fn insert_item_from_service( self: Pin<&mut SlideModel>, index: i32, item_model_id: i32, kind: &QString, ) -> Result<()>; #[qinvokable] fn add_item_from_service( self: Pin<&mut SlideModel>, item_model_id: i32, kind: &QString, ) -> Result<()>; #[qinvokable] fn move_item_from_service( self: Pin<&mut SlideModel>, source_index: i32, destination_index: i32, _service_item: &QMap_QString_QVariant, ); #[qinvokable] fn get_item( self: Pin<&mut SlideModel>, index: i32, ) -> QMap_QString_QVariant; #[qinvokable] fn next(self: Pin<&mut SlideModel>) -> bool; #[qinvokable] fn prev(self: Pin<&mut SlideModel>) -> bool; #[qinvokable] fn get_slide_from_service( self: Pin<&mut SlideModel>, index: i32, ) -> i32; #[qinvokable] fn activate(self: Pin<&mut SlideModel>, index: i32) -> bool; #[qinvokable] fn update_obs_scene( self: Pin<&mut SlideModel>, index: i32, obs_scene: QString, ); } impl cxx_qt::Threading for SlideModel {} #[auto_cxx_name] #[auto_rust_name] unsafe extern "RustQt" { #[inherit] #[cxx_name = "beginInsertRows"] unsafe fn begin_insert_rows( self: Pin<&mut SlideModel>, parent: &QModelIndex, first: i32, last: i32, ); #[inherit] #[cxx_name = "endInsertRows"] unsafe fn end_insert_rows(self: Pin<&mut SlideModel>); #[inherit] #[cxx_name = "beginRemoveRows"] unsafe fn begin_remove_rows( self: Pin<&mut SlideModel>, parent: &QModelIndex, first: i32, last: i32, ); #[inherit] #[cxx_name = "endRemoveRows"] unsafe fn end_remove_rows(self: Pin<&mut SlideModel>); #[inherit] #[cxx_name = "beginResetModel"] unsafe fn begin_reset_model(self: Pin<&mut SlideModel>); #[inherit] #[cxx_name = "endResetModel"] unsafe fn end_reset_model(self: Pin<&mut SlideModel>); #[inherit] #[cxx_name = "beginMoveRows"] unsafe fn begin_move_rows( self: Pin<&mut SlideModel>, source_parent: &QModelIndex, source_first: i32, source_last: i32, destination_parent: &QModelIndex, destination_child: i32, ) -> bool; #[inherit] #[cxx_name = "endMoveRows"] unsafe fn end_move_rows(self: Pin<&mut SlideModel>); #[inherit] #[cxx_name = "canFetchMore"] fn can_fetch_more( self: &SlideModel, parent: &QModelIndex, ) -> bool; #[inherit] fn index( self: &SlideModel, row: i32, column: i32, parent: &QModelIndex, ) -> QModelIndex; #[qinvokable] #[cxx_override] fn data( self: &SlideModel, index: &QModelIndex, role: i32, ) -> QVariant; #[qinvokable] #[cxx_override] #[cxx_name = "roleNames"] fn role_names(self: &SlideModel) -> QHash_i32_QByteArray; #[qinvokable] #[cxx_override] #[cxx_name = "rowCount"] fn row_count(self: &SlideModel, _parent: &QModelIndex) -> i32; } } use crate::image_model::image_model::ImageModel; use crate::image_model::{self, Image, ImageModelRust}; use crate::obs::Obs; use crate::presentation_model::presentation_model::PresentationModel; use crate::presentation_model::{ self, Presentation, PresentationModelRust, }; use crate::slide_model::slide_model::QList_QString; use crate::songs::song_model::song_model::{self, SongModel}; use crate::songs::song_model::{Song, SongModelRust, get_song}; use crate::video_model::video_model::VideoModel; use crate::video_model::{self, Video, VideoModelRust}; use crate::{ffmpeg, slide_types::SlideType}; use color_eyre::Section; use color_eyre::eyre::Result; use cxx_qt::{CxxQtType, Threading}; use cxx_qt_lib::{ CaseSensitivity, QByteArray, QList, QModelIndex, QString, QStringList, QVariant, }; use slide_model::SlideObject; use std::error::Error; use std::fmt::Display; use std::{path::PathBuf, pin::Pin}; use tracing::{debug, error, warn}; use self::slide_model::{ QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, SlideRoles, }; #[derive(Clone, Debug)] pub struct Slide { pub text: String, pub ty: SlideType, pub audio: String, pub image_background: String, pub video_background: String, pub htext_alignment: String, pub vtext_alignment: String, pub font: String, pub font_size: i32, pub slide_count: i32, pub slide_index: i32, pub service_item_id: i32, pub active: bool, pub selected: bool, pub looping: bool, pub video_thumbnail: String, pub video_start_time: f32, pub video_end_time: f32, pub html: bool, pub obs_scene: String, } impl Default for Slide { fn default() -> Self { Self { text: String::default(), ty: SlideType::Image, audio: String::default(), image_background: String::default(), video_background: String::default(), htext_alignment: String::default(), vtext_alignment: String::default(), font: String::default(), font_size: 50, slide_count: 1, slide_index: 0, service_item_id: 0, active: false, selected: false, looping: false, video_thumbnail: String::default(), video_start_time: 0.0, video_end_time: 0.0, html: false, obs_scene: String::default(), } } } #[derive(Debug)] pub enum ParseSlideError { UnknownType, } impl Error for ParseSlideError {} impl Display for ParseSlideError { fn fmt( &self, f: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { let message = match self { Self::UnknownType => { "The type does not exist. It needs to be one of 'song', 'video', 'image', 'presentation', or 'content'" } }; write!(f, "Error: {message}") } } impl TryFrom