feat: reveal.js presentations are viewable in editor

I have gotten reveal.js presentations to be viewable. I'll still need
to work with how to present them, and fix the presenter piece as well,
but for now, it works.
This commit is contained in:
Chris Cochrun 2023-04-29 07:13:04 -05:00
parent dd1ea7454e
commit b05af23ffa
5 changed files with 47 additions and 15 deletions

View file

@ -55,6 +55,7 @@
#include "cxx-qt-gen/slide_model.cxxqt.h" #include "cxx-qt-gen/slide_model.cxxqt.h"
#include "cxx-qt-gen/settings.cxxqt.h" #include "cxx-qt-gen/settings.cxxqt.h"
#include "cxx-qt-gen/ytdl.cxxqt.h" #include "cxx-qt-gen/ytdl.cxxqt.h"
#include "cxx-qt-gen/presentation_model.cxxqt.h"
// #include "cxx-qt-gen/image_model.cxxqt.h" // #include "cxx-qt-gen/image_model.cxxqt.h"
static QWindow *windowFromEngine(QQmlApplicationEngine *engine) static QWindow *windowFromEngine(QQmlApplicationEngine *engine)
@ -201,6 +202,7 @@ int main(int argc, char *argv[])
qmlRegisterType<VideoProxyModel>("org.presenter", 1, 0, "VideoProxyModel"); qmlRegisterType<VideoProxyModel>("org.presenter", 1, 0, "VideoProxyModel");
qmlRegisterType<ImageProxyModel>("org.presenter", 1, 0, "ImageProxyModel"); qmlRegisterType<ImageProxyModel>("org.presenter", 1, 0, "ImageProxyModel");
qmlRegisterType<PresentationProxyModel>("org.presenter", 1, 0, "PresentationProxyModel"); qmlRegisterType<PresentationProxyModel>("org.presenter", 1, 0, "PresentationProxyModel");
qmlRegisterType<PresentationModel>("org.presenter", 1, 0, "PresentationModel");
qmlRegisterType<SongSqlModel>("org.presenter", 1, 0, "SongSqlModel"); qmlRegisterType<SongSqlModel>("org.presenter", 1, 0, "SongSqlModel");
qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel"); qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel");
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel"); qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");

View file

@ -315,16 +315,20 @@ Item {
function addPres(url) { function addPres(url) {
console.log(pdf.status); console.log(pdf.status);
let pageCount = 1;
if (url.endsWith(".pdf")) {
pdf.source = url; pdf.source = url;
while (pdf.status != 2) { while (pdf.status != 2) {
console.log(pdf.status); console.log(pdf.status);
console.log("PAGECOUNT: " + pdf.pageCount); console.log("PAGECOUNT: " + pdf.pageCount);
pageCount = pdf.pageCount;
} }
presProxyModel.presentationModel.newPresentation(url, pdf.pageCount); }
presProxyModel.presentationModel.newItem(url, pageCount);
selectedLibrary = "presentation"; selectedLibrary = "presentation";
presentationLibraryList.currentIndex = presProxyModel.presentationModel.rowCount(); presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count();
console.log(presProxyModel.presentationModel.getPresentation(presentationLibraryList.currentIndex)); console.log(presProxyModel.getPresentation(presentationLibrary.libraryList.currentIndex));
const presentation = presProxyModel.presentationModel.getImage(presentationLibraryList.currentIndex); const presentation = presProxyModel.getPresentation(presentationLibrary.libraryList.currentIndex);
showPassiveNotification("newest image: " + presentation.title); showPassiveNotification("newest image: " + presentation.title);
if (!editMode) if (!editMode)
editMode = true; editMode = true;

View file

@ -121,7 +121,7 @@ FocusScope {
anchors.centerIn: parent anchors.centerIn: parent
itemType: SlideObject.ty itemType: SlideObject.ty
imageSource: SlideObject.imageBackground imageSource: SlideObject.imageBackground
webSource: SlideObject.html webSource: SlideObject.imageBackground.endsWith(".html") ? SlideObject.imageBackground : ""
videoSource: SlideObject.videoBackground videoSource: SlideObject.videoBackground
audioSource: SlideObject.audio audioSource: SlideObject.audio
chosenFont: SlideObject.font chosenFont: SlideObject.font

View file

@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 as Controls import QtQuick.Controls 2.15 as Controls
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtWebEngine 1.10
import org.kde.kirigami 2.13 as Kirigami import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter import "./" as Presenter
@ -10,6 +11,7 @@ Item {
property string type: "presentation" property string type: "presentation"
property var presentation property var presentation
property bool isHtml: presentation.filePath.endsWith(".html")
GridLayout { GridLayout {
id: mainLayout id: mainLayout
@ -112,11 +114,20 @@ Item {
Layout.preferredHeight: Layout.preferredWidth / 16 * 9 Layout.preferredHeight: Layout.preferredWidth / 16 * 9
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: presentation.filePath source: isHtml ? "" : presentation.filePath
Component.onCompleted: { Component.onCompleted: {
updatePageCount(frameCount); updatePageCount(frameCount);
showPassiveNotification(presentation.pageCount); showPassiveNotification(presentation.pageCount);
} }
visible: !isHtml
}
WebEngineView {
id: webPresentationPreview
Layout.preferredWidth: root.width - Kirigami.Units.largeSpacing
Layout.preferredHeight: Layout.preferredWidth / 16 * 9
Layout.alignment: Qt.AlignCenter
url: isHtml ? presentation.filePath : ""
visible: isHtml
} }
RowLayout { RowLayout {
Layout.fillWidth: true; Layout.fillWidth: true;
@ -127,7 +138,12 @@ Item {
id: leftArrow id: leftArrow
text: "Back" text: "Back"
icon.name: "back" icon.name: "back"
onClicked: presentationPreview.currentFrame = presentationPreview.currentFrame - 1 onClicked: {
if (isHtml) {
webPresentationPreview.runJavaScript("Reveal.navigatePrev()");
} else
presentationPreview.currentFrame = presentationPreview.currentFrame - 1
}
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
@ -136,7 +152,12 @@ Item {
id: rightArrow id: rightArrow
text: "Next" text: "Next"
icon.name: "next" icon.name: "next"
onClicked: presentationPreview.currentFrame = presentationPreview.currentFrame + 1 onClicked: {
if (isHtml) {
webPresentationPreview.runJavaScript("Reveal.navigateNext()");
} else
presentationPreview.currentFrame = presentationPreview.currentFrame + 1
}
} }
} }
Item { Item {

View file

@ -36,6 +36,7 @@ mod presentation_model {
title: QString, title: QString,
html: bool, html: bool,
path: QString, path: QString,
page_count: i32,
} }
#[cxx_qt::qobject(base = "QAbstractListModel")] #[cxx_qt::qobject(base = "QAbstractListModel")]
@ -96,14 +97,15 @@ mod presentation_model {
self.as_mut().set_highest_id(presentation.id); self.as_mut().set_highest_id(presentation.id);
} }
let img = self::Presentation { let pres = self::Presentation {
id: presentation.id, id: presentation.id,
title: QString::from(&presentation.title), title: QString::from(&presentation.title),
html: false, html: false,
path: QString::from(&presentation.path), path: QString::from(&presentation.path),
page_count: 1,
}; };
self.as_mut().add_presentation(img); self.as_mut().add_presentation(pres);
} }
println!("--------------------------------------"); println!("--------------------------------------");
println!("{:?}", self.as_mut().presentations()); println!("{:?}", self.as_mut().presentations());
@ -149,7 +151,7 @@ mod presentation_model {
} }
#[qinvokable] #[qinvokable]
pub fn new_item(mut self: Pin<&mut Self>, url: QUrl) { pub fn new_item(mut self: Pin<&mut Self>, url: QUrl, new_page_count: i32) {
println!("LETS INSERT THIS SUCKER!"); println!("LETS INSERT THIS SUCKER!");
let file_path = PathBuf::from(url.path().to_string()); let file_path = PathBuf::from(url.path().to_string());
let name = file_path.file_stem().unwrap().to_str().unwrap(); let name = file_path.file_stem().unwrap().to_str().unwrap();
@ -164,6 +166,7 @@ mod presentation_model {
presentation_title, presentation_title,
presentation_path, presentation_path,
presentation_html, presentation_html,
new_page_count,
) { ) {
println!("filename: {:?}", name); println!("filename: {:?}", name);
self.as_mut().set_highest_id(presentation_id); self.as_mut().set_highest_id(presentation_id);
@ -179,6 +182,7 @@ mod presentation_model {
presentation_title: QString, presentation_title: QString,
presentation_path: QString, presentation_path: QString,
presentation_html: bool, presentation_html: bool,
new_page_count: i32,
) -> bool { ) -> bool {
let db = &mut self.as_mut().get_db(); let db = &mut self.as_mut().get_db();
// println!("{:?}", db); // println!("{:?}", db);
@ -187,6 +191,7 @@ mod presentation_model {
title: presentation_title.clone(), title: presentation_title.clone(),
html: false, html: false,
path: presentation_path.clone(), path: presentation_path.clone(),
page_count: new_page_count,
}; };
println!("{:?}", presentation); println!("{:?}", presentation);