diff --git a/build.rs b/build.rs index b3ceb3e..ee5f750 100644 --- a/build.rs +++ b/build.rs @@ -12,6 +12,7 @@ fn main() { .file("src/rust/video_model.rs") .file("src/rust/presentation_model.rs") .file("src/rust/songs/song_model.rs") + .file("src/rust/songs/song_editor.rs") .file("src/rust/ytdl.rs") .file("src/rust/utils.rs") .build(); diff --git a/src/main.cpp b/src/main.cpp index 7e1de18..e1f6208 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -222,6 +222,7 @@ int main(int argc, char *argv[]) qmlRegisterType("org.presenter", 1, 0, "ImageProxyModel"); qmlRegisterType("org.presenter", 1, 0, "PresentationProxyModel"); qmlRegisterType("org.presenter", 1, 0, "SongModel"); + qmlRegisterType("org.presenter", 1, 0, "SongEditor"); qmlRegisterType("org.presenter", 1, 0, "VideoModel"); qmlRegisterType("org.presenter", 1, 0, "ImageModel"); qmlRegisterType("org.presenter", 1, 0, "PresentationModel"); diff --git a/src/qml/presenter/MainWindow.qml b/src/qml/presenter/MainWindow.qml index abb5740..abdb7d1 100644 --- a/src/qml/presenter/MainWindow.qml +++ b/src/qml/presenter/MainWindow.qml @@ -144,6 +144,10 @@ Controls.Page { ServiceThing { id: serviceThing } FileHelper { id: fileHelper } SlideHelper { id: slideHelper } + SongEditor { + id: songEditor + songModel: songProxyModel.songModel() + } function changeServiceItem(index) { console.log("change-service-item: " + index); diff --git a/src/rust/songs/song_editor.rs b/src/rust/songs/song_editor.rs index 6194523..fde7e4c 100644 --- a/src/rust/songs/song_editor.rs +++ b/src/rust/songs/song_editor.rs @@ -1,21 +1,62 @@ +#[cxx_qt::bridge] mod song_editor { - pub enum Yes { - Yes, - No, + use crate::songs::song_model::qobject::SongModel; + + unsafe extern "C++" { + 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/qstringlist.h"); + type QStringList = cxx_qt_lib::QStringList; + include!("cxx-qt-lib/qlist.h"); + type QList_QString = cxx_qt_lib::QList; + #[cxx_name = "SongModel"] + type SongModel = SongModel; } - pub struct EditableSong { - title: String, - lyrics: String, - author: String, - ccli: String, - audio: String, - verse_order: String, - background: String, - background_type: String, - horizontal_text_alignment: String, - vertical_text_alignment: String, - font: String, + #[derive(Clone, Debug)] + #[cxx_qt::qobject] + pub struct SongEditor { + #[qproperty] + title: QString, + #[qproperty] + lyrics: QString, + #[qproperty] + author: QString, + #[qproperty] + ccli: QString, + #[qproperty] + audio: QUrl, + #[qproperty] + verse_order: QString, + #[qproperty] + verse_order_format: bool, + #[qproperty] + background: QUrl, + #[qproperty] + background_type: QString, + #[qproperty] + horizontal_text_alignment: QString, + #[qproperty] + vertical_text_alignment: QString, + #[qproperty] + font: QString, + #[qproperty] font_size: i32, + #[qproperty] + song_model: *mut SongModel, + } + + impl SongEditor { + fn idk(mut self: Pin<&mut Self>) { + // let mut model = self.song_model().as_mut().unwrap(); + // let pinned_model = Pin::new_unchecked(model); + // pinned_model.update_ccli(0, QString::from("idk")); + todo!(); + } } }