reveal presentations now move forward using signals

Rather than the logic in qml, I've moved it to rust and am using
signals to tell the ui to change.
This commit is contained in:
Chris Cochrun 2023-11-15 09:48:29 -06:00
parent e2e6c7f428
commit 219e2312c7
4 changed files with 68 additions and 25 deletions

View file

@ -217,18 +217,18 @@ Controls.Page {
console.log("text: " + item.text);
console.log("slide_index: " + item.slideIndex);
console.log("slide_count: " + item.imageCount);
if (item.html) {
let index = item.slideIndex;
let count = item.imageCount;
if (index > 0 && index < count - 1) {
console.log("I should advance revealy");
if (isMoveDown)
presentation.revealNext()
else
presentation.revealPrev()
return
}
}
/* if (item.html) { */
/* let index = item.slideIndex; */
/* let count = item.imageCount; */
/* if (index > 0 && index < count - 1) { */
/* console.log("I should advance revealy"); */
/* if (isMoveDown) */
/* presentation.revealNext() */
/* else */
/* presentation.revealPrev() */
/* return */
/* } */
/* } */
/* presentation.stopVideo(); */
/* pWindow.stopVideo(); */

View file

@ -336,6 +336,9 @@ FocusScope {
previewSlide.playVideo();
pauseVideo();
}
function onRevealNext() {
previewSlide.revealNext();
}
}
Timer {

View file

@ -193,6 +193,18 @@ Item {
}
}
Connections {
target: SlideObject
function onRevealNext() {
console.log("revealNext")
web.runJavaScript("Reveal.next()")
}
function onRevealPrev() {
console.log("revealPrev")
web.runJavaScript("Reveal.prev()")
}
}
function changeText(text) {
lyrics.text = text
}

View file

@ -4,6 +4,8 @@ mod slide_obj {
// use std::path::Path;
// use std::task::Context;
use tracing::debug;
unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString;
@ -14,6 +16,7 @@ mod slide_obj {
type QVariant = cxx_qt_lib::QVariant;
}
#[derive(Debug)]
#[cxx_qt::qsignals(SlideObj)]
pub enum Signals<'a> {
PlayingChanged { is_playing: &'a bool },
@ -21,6 +24,8 @@ mod slide_obj {
SlideSizeChanged { slide_size: &'a i32 },
SlideChanged { slide: &'a i32 },
LoopChanged { looping: &'a bool },
RevealNext,
RevealPrev,
}
#[derive(Clone, Debug)]
@ -93,6 +98,37 @@ mod slide_obj {
item: QMap_QString_QVariant,
index: i32,
) {
let icount_variant = item
.get(&QString::from("imageCount"))
.unwrap_or(QVariant::from(&1));
let count =
icount_variant.value::<i32>().unwrap_or_default();
let slindex = item
.get(&QString::from("slideIndex"))
.unwrap_or(QVariant::from(&0));
let slide_index =
slindex.value::<i32>().unwrap_or_default();
let html = item
.get(&QString::from("html"))
.unwrap_or(QVariant::from(&false));
if let Some(html) = html.value::<bool>() {
if html {
debug!(?html, count, slide_index);
if slide_index > 0 && slide_index < count - 1 {
self.as_mut().emit(Signals::RevealNext);
debug!(signal = ?Signals::RevealNext);
return;
}
// } else if slide_index > 0 {
// self.as_mut().emit(Signals::RevealPrev);
// debug!(Signals::RevealNext);
// return;
// }
}
}
println!("## Slide Details ##");
let text = item
.get(&QString::from("text"))
@ -245,19 +281,11 @@ mod slide_obj {
if let Some(int) = video_start_time.value::<f32>() {
self.as_mut().set_video_start_time(int)
}
let icount = item
.get(&QString::from("imageCount"))
.unwrap_or(QVariant::from(&1));
if let Some(int) = icount.value::<i32>() {
self.as_mut().set_image_count(int);
}
let slindex = item
.get(&QString::from("slideIndex"))
.unwrap_or(QVariant::from(&0));
if let Some(int) = slindex.value::<i32>() {
println!("New slide index = {}", int);
self.as_mut().set_slide_index(int);
};
self.as_mut().set_image_count(count);
self.as_mut().set_slide_index(slide_index);
self.as_mut()
.emit(Signals::SlideChanged { slide: &index });
println!("## Slide End ##");