From e30066b1018028b52ac9eeb3b08845e8e9fcc2ea Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 14 Nov 2023 21:39:30 -0600 Subject: [PATCH] revealJS presentations work sorta I still have lots of bugs, but the groundwork is there. At least a proof of concept. --- src/qml/presenter/MainWindow.qml | 19 ++++++++++++++++++- src/qml/presenter/Presentation.qml | 7 +++++++ src/qml/presenter/PresentationEditor.qml | 23 ++++++++++++++++++++++- src/qml/presenter/PresentationWindow.qml | 8 ++++++++ src/qml/presenter/Slide.qml | 5 +++-- src/rust/slide_model.rs | 13 +++++++++++++ 6 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/qml/presenter/MainWindow.qml b/src/qml/presenter/MainWindow.qml index 7d42527..59a816f 100644 --- a/src/qml/presenter/MainWindow.qml +++ b/src/qml/presenter/MainWindow.qml @@ -208,10 +208,27 @@ Controls.Page { function changeSlide(index) { console.log("index grabbed: " + index); const item = SlideModel.getItemRust(index, SlideMod); + const isMoveDown = currentSlide < index; currentSlide = index; currentServiceItem = item.serviceItemId; console.log("index grabbed: " + index); - console.log(item); + console.log("html?: " + item.html); + console.log("type: " + item.type); + 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 + } + } /* presentation.stopVideo(); */ /* pWindow.stopVideo(); */ diff --git a/src/qml/presenter/Presentation.qml b/src/qml/presenter/Presentation.qml index c03fa5d..a18bd27 100644 --- a/src/qml/presenter/Presentation.qml +++ b/src/qml/presenter/Presentation.qml @@ -413,4 +413,11 @@ FocusScope { function playAudio() { } + function revealNext() { + previewSlide.revealNext(); + } + + function revealPrev() { + previewSlide.revealPrev(); + } } diff --git a/src/qml/presenter/PresentationEditor.qml b/src/qml/presenter/PresentationEditor.qml index c72448e..3f98828 100644 --- a/src/qml/presenter/PresentationEditor.qml +++ b/src/qml/presenter/PresentationEditor.qml @@ -30,17 +30,38 @@ Item { Controls.TextField { id: presentationTitleField - Layout.preferredWidth: 300 + implicitWidth: 300 placeholderText: "Title..." text: presentation.title padding: 10 onEditingFinished: updateTitle(text); + background: Presenter.TextBackground { + control: fontBox + } } Controls.ComboBox { model: ["PRESENTATIONS", "Center", "Right", "Justify"] implicitWidth: 100 hoverEnabled: true + background: Presenter.TextBackground { + control: fontBox + } + indicator: Kirigami.Icon { + anchors {right: parent.right + verticalCenter: parent.verticalCenter + rightMargin: 2} + source: "arrow-down" + rotation: fontBox.down ? 180 : 0 + color: fontBox.pressed ? Kirigami.Theme.focusColor : Kirigami.Theme.textColor + + Behavior on rotation { + NumberAnimation { + easing.type: Easing.OutCubic + duration: 300 + } + } + } } Controls.ToolSeparator {} Item { Layout.fillWidth: true } diff --git a/src/qml/presenter/PresentationWindow.qml b/src/qml/presenter/PresentationWindow.qml index a07afbd..b10fded 100644 --- a/src/qml/presenter/PresentationWindow.qml +++ b/src/qml/presenter/PresentationWindow.qml @@ -107,4 +107,12 @@ Item { function loopVideo() { presentationSlide.loopVideo(); } + + function revealNext() { + presentationSlide.revealNext(); + } + + function revealPrev() { + presentationSlide.revealPrev(); + } } diff --git a/src/qml/presenter/Slide.qml b/src/qml/presenter/Slide.qml index 38e75c9..bc7db94 100644 --- a/src/qml/presenter/Slide.qml +++ b/src/qml/presenter/Slide.qml @@ -177,6 +177,7 @@ Item { anchors.fill: parent url: webSource visible: htmlVisible + zoomFactor: preview ? 0.25 : 1.0 onLoadingChanged: { if (loadRequest.status == 2) showPassiveNotification("yahoo?"); @@ -247,10 +248,10 @@ Item { } function revealNext() { - web.runJavascript("Reveal.next()") + web.runJavaScript("Reveal.next()") } function revealPrev() { - web.runJavascript("Reveal.prev()") + web.runJavaScript("Reveal.prev()") } } diff --git a/src/rust/slide_model.rs b/src/rust/slide_model.rs index e911f7a..5a27b0b 100644 --- a/src/rust/slide_model.rs +++ b/src/rust/slide_model.rs @@ -1,5 +1,6 @@ #[cxx_qt::bridge] mod slide_model { + use cxx_qt_lib::CaseSensitivity; use tracing::{debug, debug_span, error, info, instrument}; unsafe extern "C++" { include!(< QAbstractListModel >); @@ -48,6 +49,7 @@ mod slide_model { video_thumbnail: QString, video_start_time: f32, video_end_time: f32, + html: bool, } impl Default for Slidey { @@ -71,6 +73,7 @@ mod slide_model { video_thumbnail: QString::default(), video_start_time: 0.0, video_end_time: 0.0, + html: false, } } } @@ -437,6 +440,12 @@ mod slide_model { Some(ty) if ty == QString::from("presentation") => { for i in 0..slide.slide_count { slide.ty = ty.clone(); + if background.ends_with( + &QString::from(".html"), + CaseSensitivity::CaseInsensitive, + ) { + slide.html = true; + } slide.image_background = background.clone(); slide.video_background = QString::from(""); slide.slide_index = i; @@ -978,6 +987,9 @@ mod slide_model { 13 => QVariant::from(&slide.selected), 14 => QVariant::from(&slide.looping), 15 => QVariant::from(&slide.video_thumbnail), + 16 => QVariant::from(&slide.video_start_time), + 17 => QVariant::from(&slide.video_end_time), + 18 => QVariant::from(&slide.html), _ => QVariant::default(), }; } @@ -1043,6 +1055,7 @@ mod slide_model { 17, cxx_qt_lib::QByteArray::from("videoEndTime"), ); + roles.insert(18, cxx_qt_lib::QByteArray::from("html")); roles }