From da258433d94de756cc5b21b66c061503d85d8390 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 17 Jan 2024 11:26:04 -0600 Subject: [PATCH] Adding reveal next and previous buttons In order to make this work, I had to determine in rust which were html and essentially not call the change_slide function and instead call the reveal_next/previous functions and then tweak it from there. --- src/qml/presenter/Presentation.qml | 19 ++++++++++++------- src/qml/presenter/PresentationWindow.qml | 6 +++--- src/qml/presenter/Slide.qml | 3 +++ src/rust/slide_model.rs | 7 +++---- src/rust/slide_object.rs | 17 ++++++++++++++--- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/qml/presenter/Presentation.qml b/src/qml/presenter/Presentation.qml index d14cf06..0d3e420 100644 --- a/src/qml/presenter/Presentation.qml +++ b/src/qml/presenter/Presentation.qml @@ -120,9 +120,9 @@ FocusScope { implicitHeight: width / 16 * 9 anchors.centerIn: parent itemType: SlideObject.ty - imageSource: SlideObject.imageBackground.endsWith(".html") ? "" : SlideObject.imageBackground - webSource: SlideObject.imageBackground.endsWith(".html") ? SlideObject.imageBackground : "" - htmlVisible: SlideObject.imageBackground.endsWith(".html") + imageSource: SlideObject.html ? "" : SlideObject.imageBackground + webSource: SlideObject.html ? SlideObject.imageBackground : "" + htmlVisible: SlideObject.html videoSource: SlideObject.videoBackground audioSource: SlideObject.audio chosenFont: SlideObject.font @@ -467,9 +467,8 @@ FocusScope { keyHandler.forceActiveFocus(); const nextSlideIdx = currentSlide + 1; const nextSlide = SlideModel.getItem(nextSlideIdx); - /* if (!SlideObject.imageBackground.endsWith(".html") && */ - /* (nextSlideIdx > totalSlides || nextSlideIdx < 0)) */ - /* return; */ + if (nextSlideIdx > totalSlides || nextSlideIdx < 0) + return; console.log("currentServiceItem " + currentServiceItem); console.log("totalSlides " + totalSlides); console.log("currentSlide " + currentSlide); @@ -491,12 +490,18 @@ FocusScope { function previousSlideAction() { keyHandler.forceActiveFocus(); const prevSlideIdx = currentSlide - 1; + const prevSlide = SlideModel.getItem(prevSlideIdx); if (prevSlideIdx > totalSlides || prevSlideIdx < 0) return; console.log("currentServiceItem " + currentServiceItem); + console.log("totalSlides " + totalSlides); console.log("currentSlide " + currentSlide); console.log("prevSlideIdx " + prevSlideIdx); - changeSlide(prevSlideIdx); + /* changeSlide(prevSlideIdx); */ + if (SlideObject.previous(prevSlide)) { + currentSlide = prevSlideIdx; + currentServiceItem = prevSlide.serviceItemId; + } } function previousSlide() { diff --git a/src/qml/presenter/PresentationWindow.qml b/src/qml/presenter/PresentationWindow.qml index 8a0f5a8..9ee7d70 100644 --- a/src/qml/presenter/PresentationWindow.qml +++ b/src/qml/presenter/PresentationWindow.qml @@ -49,9 +49,9 @@ Item { Presenter.Slide { id: presentationSlide anchors.fill: parent - imageSource: SlideObj.imageBackground.endsWith(".html") ? "" : SlideObj.imageBackground - webSource: SlideObj.imageBackground.endsWith(".html") ? SlideObj.imageBackground : "" - htmlVisible: SlideObj.imageBackground.endsWith(".html") + imageSource: SlideObj.html ? "" : SlideObj.imageBackground + webSource: SlideObj.html ? SlideObj.imageBackground : "" + htmlVisible: SlideObj.html videoSource: presentationWindow.visible ? SlideObj.videoBackground : "" audioSource: SlideObj.audio text: SlideObj.text diff --git a/src/qml/presenter/Slide.qml b/src/qml/presenter/Slide.qml index 9faa36f..b894809 100644 --- a/src/qml/presenter/Slide.qml +++ b/src/qml/presenter/Slide.qml @@ -191,11 +191,14 @@ Item { anchors.fill: parent url: webSource visible: htmlVisible + enabled: htmlVisible zoomFactor: preview ? 0.25 : 1.0 onLoadingChanged: { if (loadRequest.status == 2) showPassiveNotification("yahoo?"); } + settings.playbackRequiresUserGesture: false + audioMuted: root.preview /* function moveToSlideIndex(index) { */ /* web.runJavaScript(" */ diff --git a/src/rust/slide_model.rs b/src/rust/slide_model.rs index 3602d1f..ce7c7d5 100644 --- a/src/rust/slide_model.rs +++ b/src/rust/slide_model.rs @@ -592,9 +592,8 @@ impl slide_model::SlideModel { slide.html = true; slide.image_background = background.clone(); slide.video_background = QString::from(""); - slide.slide_index = i; - self.as_mut() - .insert_slide(&slide, slide_index + i); + slide.slide_index = 0; + self.as_mut().insert_slide(&slide, slide_index); } else { for i in 0..slide.slide_count { slide.ty = ty.clone(); @@ -787,7 +786,7 @@ impl slide_model::SlideModel { slide.html = true; slide.image_background = background.clone(); slide.video_background = QString::from(""); - slide.slide_index = i; + slide.slide_index = 0; self.as_mut().add_slide(&slide); } else { for i in 0..slide.slide_count { diff --git a/src/rust/slide_object.rs b/src/rust/slide_object.rs index a19c1df..fb0c224 100644 --- a/src/rust/slide_object.rs +++ b/src/rust/slide_object.rs @@ -49,7 +49,7 @@ mod slide_object { #[qproperty(QString, audio)] #[qproperty(QString, image_background)] #[qproperty(QString, video_background)] - #[qproperty(QString, html)] + #[qproperty(bool, html)] #[qproperty(QString, vtext_alignment)] #[qproperty(QString, htext_alignment)] #[qproperty(QString, font)] @@ -104,7 +104,7 @@ pub struct SlideObjectRust { audio: QString, image_background: QString, video_background: QString, - html: QString, + html: bool, vtext_alignment: QString, htext_alignment: QString, font: QString, @@ -125,7 +125,7 @@ impl Default for SlideObjectRust { ty: QString::from(""), audio: QString::from(""), image_background: QString::from(""), - html: QString::from(""), + html: false, video_background: QString::from(""), vtext_alignment: QString::from(""), htext_alignment: QString::from(""), @@ -315,6 +315,13 @@ impl slide_object::SlideObject { self.as_mut().set_video_start_time(int) } + let html = + image_background.value_or_default::().ends_with( + &QString::from(".html"), + CaseSensitivity::CaseInsensitive, + ); + self.as_mut().set_html(html); + self.as_mut().set_image_count(count); self.as_mut().set_slide_index(slide_index); @@ -361,6 +368,8 @@ impl slide_object::SlideObject { return false; } } + // reset to empty before change to ensure that the web source gets unloaded + self.as_mut().set_image_background(QString::from("")); self.as_mut().change_slide(next_item, service_item); debug!(service_item, "returning true"); true @@ -389,6 +398,8 @@ impl slide_object::SlideObject { return false; } } + // reset to empty before change to ensure that the web source gets unloaded + self.as_mut().set_image_background(QString::from("")); self.as_mut().change_slide(prev_item, new_id); true }