embedded song_model into the song_editor finally
In order to embed a qobject from another file you need to find the generated .h file in the build path and make sure to include it.
This commit is contained in:
parent
0aa966e8b9
commit
e1cb837249
2 changed files with 49 additions and 9 deletions
3
TODO.org
3
TODO.org
|
@ -38,6 +38,9 @@ modified src/rust/service_item_model.rs
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
This represents an example of what it'd look like to add better types. If I can ensure to model things better I could leave out all the extra pieces in the ServiceItem struct and the Slide struct and include an ItemType. This would then let me jump to the appropriate db and get the right info for each item.
|
This represents an example of what it'd look like to add better types. If I can ensure to model things better I could leave out all the extra pieces in the ServiceItem struct and the Slide struct and include an ItemType. This would then let me jump to the appropriate db and get the right info for each item.
|
||||||
|
|
||||||
|
I've got SlideType enums working
|
||||||
|
|
||||||
*** Move logic of changing slides to slide_model
|
*** Move logic of changing slides to slide_model
|
||||||
Since the slide_object is merely supposed to be the view of the current slide, deciding which slide to switch to should be entirely on the slide_model, not the slide_object. This way slide_object doesn't need to know anything about the which slide is next and instead have a function to update everything to the slide returned from slide_model's new slide.
|
Since the slide_object is merely supposed to be the view of the current slide, deciding which slide to switch to should be entirely on the slide_model, not the slide_object. This way slide_object doesn't need to know anything about the which slide is next and instead have a function to update everything to the slide returned from slide_model's new slide.
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ pub mod song_editor {
|
||||||
include!("cxx-qt-lib/qlist.h");
|
include!("cxx-qt-lib/qlist.h");
|
||||||
type QList_QString = cxx_qt_lib::QList<QString>;
|
type QList_QString = cxx_qt_lib::QList<QString>;
|
||||||
|
|
||||||
// type SongModel = super::song_model::qobject::SongModel;
|
include!("cxx-qt-gen/song_model.cxxqt.h");
|
||||||
|
type SongModel =
|
||||||
|
crate::songs::song_model::song_model::SongModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "RustQt" {
|
unsafe extern "RustQt" {
|
||||||
|
@ -36,17 +38,20 @@ pub mod song_editor {
|
||||||
#[qproperty(i32, font_size)]
|
#[qproperty(i32, font_size)]
|
||||||
#[qproperty(bool, background_exists)]
|
#[qproperty(bool, background_exists)]
|
||||||
#[qproperty(bool, audio_exists)]
|
#[qproperty(bool, audio_exists)]
|
||||||
// #[qproperty(*mut SongModel, song_model)]
|
#[qproperty(*mut SongModel, song_model)]
|
||||||
type SongEditor = super::SongEditorRust;
|
type SongEditor = super::SongEditorRust;
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn check_verse_order(self: Pin<&mut SongEditor>);
|
fn check_verse_order(self: Pin<&mut SongEditor>);
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn check_files(self: Pin<&mut SongEditor>);
|
fn check_files(self: Pin<&mut SongEditor>);
|
||||||
|
#[qinvokable]
|
||||||
|
fn load_song(self: Pin<&mut SongEditor>, song_index: i32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// use crate::songs::song_model::qobject::SongModel;
|
use crate::songs::song_model::song_model::SongModel;
|
||||||
|
use cxx_qt::CxxQtType;
|
||||||
use cxx_qt_lib::QString;
|
use cxx_qt_lib::QString;
|
||||||
use std::{path::PathBuf, pin::Pin};
|
use std::{path::PathBuf, pin::Pin};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
@ -68,7 +73,7 @@ pub struct SongEditorRust {
|
||||||
font_size: i32,
|
font_size: i32,
|
||||||
background_exists: bool,
|
background_exists: bool,
|
||||||
audio_exists: bool,
|
audio_exists: bool,
|
||||||
// song_model: *mut SongModel,
|
song_model: *mut SongModel,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SongEditorRust {
|
impl Default for SongEditorRust {
|
||||||
|
@ -89,20 +94,52 @@ impl Default for SongEditorRust {
|
||||||
font_size: 50,
|
font_size: 50,
|
||||||
background_exists: true,
|
background_exists: true,
|
||||||
audio_exists: true,
|
audio_exists: true,
|
||||||
// song_model: std::ptr::null_mut(),
|
song_model: std::ptr::null_mut(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl song_editor::SongEditor {
|
impl song_editor::SongEditor {
|
||||||
fn idk(self: Pin<&mut Self>) {
|
fn idk(self: Pin<&mut Self>) {
|
||||||
// if let Some(model) = unsafe { self.song_model().as_mut() } {
|
if let Some(model) = unsafe { self.song_model().as_mut() } {
|
||||||
// let pinned_model = unsafe { Pin::new_unchecked(model) };
|
let pinned_model = unsafe { Pin::new_unchecked(model) };
|
||||||
// pinned_model.update_ccli(0, QString::from("idk"));
|
pinned_model.update_ccli(0, QString::from("idk"));
|
||||||
// }
|
}
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_song(mut self: Pin<&mut Self>, song_index: i32) {
|
||||||
|
if let Some(model) = unsafe { self.song_model().as_ref() } {
|
||||||
|
let pinned_model = unsafe { Pin::new_unchecked(model) };
|
||||||
|
if let Some(song) =
|
||||||
|
pinned_model.as_ref().get_song(song_index)
|
||||||
|
{
|
||||||
|
// update internals
|
||||||
|
self.as_mut().set_title(QString::from(&song.title));
|
||||||
|
self.as_mut().set_author(QString::from(&song.author));
|
||||||
|
self.as_mut().set_ccli(QString::from(&song.ccli));
|
||||||
|
self.as_mut().set_audio(QString::from(&song.audio));
|
||||||
|
self.as_mut().set_lyrics(QString::from(&song.lyrics));
|
||||||
|
self.as_mut().set_verse_order(QString::from(
|
||||||
|
&song.verse_order,
|
||||||
|
));
|
||||||
|
self.as_mut()
|
||||||
|
.set_background(QString::from(&song.background));
|
||||||
|
self.as_mut().set_background_type(QString::from(
|
||||||
|
&song.background_type,
|
||||||
|
));
|
||||||
|
self.as_mut().set_font(QString::from(&song.font));
|
||||||
|
self.as_mut().set_font_size(song.font_size);
|
||||||
|
self.as_mut().set_horizontal_text_alignment(
|
||||||
|
QString::from(&song.horizontal_text_alignment),
|
||||||
|
);
|
||||||
|
self.as_mut().set_vertical_text_alignment(
|
||||||
|
QString::from(&song.vertical_text_alignment),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn check_verse_order(mut self: Pin<&mut Self>) {
|
pub fn check_verse_order(mut self: Pin<&mut Self>) {
|
||||||
let vo = self.verse_order().to_string();
|
let vo = self.verse_order().to_string();
|
||||||
let split = vo.split(' ');
|
let split = vo.split(' ');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue