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:
parent
e2e6c7f428
commit
219e2312c7
4 changed files with 68 additions and 25 deletions
|
@ -217,18 +217,18 @@ Controls.Page {
|
||||||
console.log("text: " + item.text);
|
console.log("text: " + item.text);
|
||||||
console.log("slide_index: " + item.slideIndex);
|
console.log("slide_index: " + item.slideIndex);
|
||||||
console.log("slide_count: " + item.imageCount);
|
console.log("slide_count: " + item.imageCount);
|
||||||
if (item.html) {
|
/* if (item.html) { */
|
||||||
let index = item.slideIndex;
|
/* let index = item.slideIndex; */
|
||||||
let count = item.imageCount;
|
/* let count = item.imageCount; */
|
||||||
if (index > 0 && index < count - 1) {
|
/* if (index > 0 && index < count - 1) { */
|
||||||
console.log("I should advance revealy");
|
/* console.log("I should advance revealy"); */
|
||||||
if (isMoveDown)
|
/* if (isMoveDown) */
|
||||||
presentation.revealNext()
|
/* presentation.revealNext() */
|
||||||
else
|
/* else */
|
||||||
presentation.revealPrev()
|
/* presentation.revealPrev() */
|
||||||
return
|
/* return */
|
||||||
}
|
/* } */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
/* presentation.stopVideo(); */
|
/* presentation.stopVideo(); */
|
||||||
/* pWindow.stopVideo(); */
|
/* pWindow.stopVideo(); */
|
||||||
|
|
|
@ -336,6 +336,9 @@ FocusScope {
|
||||||
previewSlide.playVideo();
|
previewSlide.playVideo();
|
||||||
pauseVideo();
|
pauseVideo();
|
||||||
}
|
}
|
||||||
|
function onRevealNext() {
|
||||||
|
previewSlide.revealNext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
|
|
|
@ -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) {
|
function changeText(text) {
|
||||||
lyrics.text = text
|
lyrics.text = text
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ mod slide_obj {
|
||||||
// use std::path::Path;
|
// use std::path::Path;
|
||||||
// use std::task::Context;
|
// use std::task::Context;
|
||||||
|
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qstring.h");
|
include!("cxx-qt-lib/qstring.h");
|
||||||
type QString = cxx_qt_lib::QString;
|
type QString = cxx_qt_lib::QString;
|
||||||
|
@ -14,6 +16,7 @@ mod slide_obj {
|
||||||
type QVariant = cxx_qt_lib::QVariant;
|
type QVariant = cxx_qt_lib::QVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
#[cxx_qt::qsignals(SlideObj)]
|
#[cxx_qt::qsignals(SlideObj)]
|
||||||
pub enum Signals<'a> {
|
pub enum Signals<'a> {
|
||||||
PlayingChanged { is_playing: &'a bool },
|
PlayingChanged { is_playing: &'a bool },
|
||||||
|
@ -21,6 +24,8 @@ mod slide_obj {
|
||||||
SlideSizeChanged { slide_size: &'a i32 },
|
SlideSizeChanged { slide_size: &'a i32 },
|
||||||
SlideChanged { slide: &'a i32 },
|
SlideChanged { slide: &'a i32 },
|
||||||
LoopChanged { looping: &'a bool },
|
LoopChanged { looping: &'a bool },
|
||||||
|
RevealNext,
|
||||||
|
RevealPrev,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -93,6 +98,37 @@ mod slide_obj {
|
||||||
item: QMap_QString_QVariant,
|
item: QMap_QString_QVariant,
|
||||||
index: i32,
|
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 ##");
|
println!("## Slide Details ##");
|
||||||
let text = item
|
let text = item
|
||||||
.get(&QString::from("text"))
|
.get(&QString::from("text"))
|
||||||
|
@ -245,19 +281,11 @@ mod slide_obj {
|
||||||
if let Some(int) = video_start_time.value::<f32>() {
|
if let Some(int) = video_start_time.value::<f32>() {
|
||||||
self.as_mut().set_video_start_time(int)
|
self.as_mut().set_video_start_time(int)
|
||||||
}
|
}
|
||||||
let icount = item
|
|
||||||
.get(&QString::from("imageCount"))
|
self.as_mut().set_image_count(count);
|
||||||
.unwrap_or(QVariant::from(&1));
|
|
||||||
if let Some(int) = icount.value::<i32>() {
|
self.as_mut().set_slide_index(slide_index);
|
||||||
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()
|
self.as_mut()
|
||||||
.emit(Signals::SlideChanged { slide: &index });
|
.emit(Signals::SlideChanged { slide: &index });
|
||||||
println!("## Slide End ##");
|
println!("## Slide End ##");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue