basic implementation of having reveal.js slides working

There is still a lot of work needed to be done here, but the basics
are laid out.
This commit is contained in:
Chris Cochrun 2023-05-01 06:20:45 -05:00
parent b05af23ffa
commit c33b5af588
8 changed files with 88 additions and 24 deletions

12
flake.lock generated
View file

@ -38,11 +38,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1682566018, "lastModified": 1682779028,
"narHash": "sha256-HPzPRFiy2o/7k7mtnwfM1E6NVZHiFbPdmYCMoIpkHO4=", "narHash": "sha256-tFfSbwSLobpHRznAa35KEU3R+fsFWTlmpFhTUdXq8RE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8e3b64db39f2aaa14b35ee5376bd6a2e707cadc2", "rev": "54abe781c482f51ff4ff534ebaba77db5bd97442",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -52,11 +52,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1682526928, "lastModified": 1682692304,
"narHash": "sha256-2cKh4O6t1rQ8Ok+v16URynmb0rV7oZPEbXkU0owNLQs=", "narHash": "sha256-9/lyXN2BpHw+1xE+D2ySBSLMCHWqiWu5tPHBMRDib8M=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d6b863fd9b7bb962e6f9fdf292419a775e772891", "rev": "937a9d1ee7b1351d8c55fff6611a8edf6e7c1c37",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -4,6 +4,7 @@ import QtQuick.Layouts 1.15
import Qt.labs.platform 1.1 as Labs import Qt.labs.platform 1.1 as Labs
import QtQuick.Pdf 5.15 import QtQuick.Pdf 5.15
import QtQml.Models 2.15 import QtQml.Models 2.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
import org.presenter 1.0 import org.presenter 1.0
@ -17,6 +18,8 @@ Item {
property var imgexts: ["jpg", "png", "gif", "jpeg", "JPG", "PNG", "webp", "gif"] property var imgexts: ["jpg", "png", "gif", "jpeg", "JPG", "PNG", "webp", "gif"]
property var presexts: ["pdf", "PDF", "odp", "pptx", "html"] property var presexts: ["pdf", "PDF", "odp", "pptx", "html"]
property bool htmlLoaded: false
Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.colorSet: Kirigami.Theme.View
Rectangle { Rectangle {
@ -316,14 +319,12 @@ Item {
function addPres(url) { function addPres(url) {
console.log(pdf.status); console.log(pdf.status);
let pageCount = 1; 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; pageCount = pdf.pageCount;
} }
}
presProxyModel.presentationModel.newItem(url, pageCount); presProxyModel.presentationModel.newItem(url, pageCount);
selectedLibrary = "presentation"; selectedLibrary = "presentation";
presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count(); presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count();
@ -360,6 +361,9 @@ Item {
} }
if (presexts.includes(extension)) if (presexts.includes(extension))
{ {
if (file.endsWith(".html")) {
web.url = file;
} else
addPres(file); addPres(file);
} }
@ -400,5 +404,38 @@ Item {
PdfDocument { PdfDocument {
id: pdf id: pdf
} }
WebEngineView {
id: web
height: 0
width: 0
onLoadingChanged: {
if (loadRequest.status == 2)
addHtml(url);
}
}
}
function addHtml(url) {
console.log("adding an html");
var pageCount = 1;
web.runJavaScript("Reveal.getSlides()", function(result) {
let str = '';
for (const [p, val] of Object.entries(result[0])) {
str += `${p}::${val}\n`;
}
console.log(str);
pageCount = result.length;
console.log(pageCount);
presProxyModel.presentationModel.newItem(url, pageCount);
selectedLibrary = "presentation";
presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count();
console.log(presProxyModel.getPresentation(presentationLibrary.libraryList.currentIndex));
const presentation = presProxyModel.getPresentation(presentationLibrary.libraryList.currentIndex);
showPassiveNotification("newest image: " + presentation.title);
if (!editMode)
editMode = true;
editSwitch("presentation", presentation);
});
} }
} }

View file

@ -192,7 +192,7 @@ Controls.Page {
slideHelper.chngSlide(item, index, SlideObject); slideHelper.chngSlide(item, index, SlideObject);
/* SlideMod.activate(index); */ /* SlideMod.activate(index); */
presentation.textIndex = 0; presentation.textIndex = 0;
console.log("Slide changed to: " + index); console.log("Slide changed to: ", item.imageBackground);
activeServiceItem = ServiceItemModel.getItem(currentServiceItem).name; activeServiceItem = ServiceItemModel.getItem(currentServiceItem).name;
} }

View file

@ -120,8 +120,9 @@ FocusScope {
implicitHeight: width / 16 * 9 implicitHeight: width / 16 * 9
anchors.centerIn: parent anchors.centerIn: parent
itemType: SlideObject.ty itemType: SlideObject.ty
imageSource: SlideObject.imageBackground imageSource: SlideObject.imageBackground.endsWith(".html") ? "" : SlideObject.imageBackground
webSource: SlideObject.imageBackground.endsWith(".html") ? SlideObject.imageBackground : "" webSource: SlideObject.imageBackground.endsWith(".html") ? SlideObject.imageBackground : ""
htmlVisible: SlideObject.imageBackground.endsWith(".html")
videoSource: SlideObject.videoBackground videoSource: SlideObject.videoBackground
audioSource: SlideObject.audio audioSource: SlideObject.audio
chosenFont: SlideObject.font chosenFont: SlideObject.font

View file

@ -140,7 +140,7 @@ Item {
icon.name: "back" icon.name: "back"
onClicked: { onClicked: {
if (isHtml) { if (isHtml) {
webPresentationPreview.runJavaScript("Reveal.navigatePrev()"); webPresentationPreview.runJavaScript("Reveal.prev()");
} else } else
presentationPreview.currentFrame = presentationPreview.currentFrame - 1 presentationPreview.currentFrame = presentationPreview.currentFrame - 1
} }
@ -154,7 +154,7 @@ Item {
icon.name: "next" icon.name: "next"
onClicked: { onClicked: {
if (isHtml) { if (isHtml) {
webPresentationPreview.runJavaScript("Reveal.navigateNext()"); webPresentationPreview.runJavaScript("Reveal.next()");
} else } else
presentationPreview.currentFrame = presentationPreview.currentFrame + 1 presentationPreview.currentFrame = presentationPreview.currentFrame + 1
} }

View file

@ -1,6 +1,7 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 as Controls import QtQuick.Controls 2.15 as Controls
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
import org.presenter 1.0 import org.presenter 1.0
@ -36,12 +37,27 @@ Item {
implicitHeight: parent.height - Kirigami.Units.smallSpacing * 2 implicitHeight: parent.height - Kirigami.Units.smallSpacing * 2
textSize: model.fontSize textSize: model.fontSize
itemType: model.type itemType: model.type
imageSource: model.videoBackground != "" ? model.videoThumbnail : model.imageBackground imageSource: {
if (model.videoBackground != "") {
return model.videoThumbnail;
} else if (model.imageBackground.endsWith(".html")) {
return "";
} else
return model.imageBackground;
}
chosenFont: model.font chosenFont: model.font
text: model.text text: model.text
pdfIndex: model.slideIndex pdfIndex: model.slideIndex
} }
WebEngineView {
id: web
anchors.centerIn: parent
implicitWidth: height / 9 * 16
implicitHeight: parent.height - Kirigami.Units.smallSpacing * 2
url: model.imageBackground.endsWith(".html") ? model.imageBackground : ""
visible: model.imageBackground.endsWith(".html")
}
} }
Controls.Label { Controls.Label {

View file

@ -20,6 +20,7 @@ Item {
property bool dropShadow: false property bool dropShadow: false
property url imageSource property url imageSource
property url webSource property url webSource
property bool htmlVisible: false
property url videoSource property url videoSource
property url audioSource property url audioSource
property bool vidLoop property bool vidLoop
@ -128,7 +129,7 @@ Item {
source: imageSource source: imageSource
fillMode: itemType == "song" ? Image.PreserveAspectCrop : Image.PreserveAspectFit fillMode: itemType == "song" ? Image.PreserveAspectCrop : Image.PreserveAspectFit
clip: true clip: true
visible: true visible: webSource.length == 0
currentFrame: pdfIndex currentFrame: pdfIndex
} }
@ -172,7 +173,11 @@ Item {
id: web id: web
anchors.fill: parent anchors.fill: parent
url: webSource url: webSource
visible: false visible: htmlVisible
onLoadingChanged: {
if (loadRequest.status == 2)
showPassiveNotification("YAHOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!");
}
} }
} }

View file

@ -61,6 +61,7 @@ mod presentation_model {
PathRole, PathRole,
TitleRole, TitleRole,
HtmlRole, HtmlRole,
PageCountRole,
} }
// use crate::entities::{presentations, prelude::Presentations}; // use crate::entities::{presentations, prelude::Presentations};
@ -100,9 +101,9 @@ mod presentation_model {
let pres = 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: presentation.path.ends_with(".html"),
path: QString::from(&presentation.path), path: QString::from(&presentation.path),
page_count: 1, page_count: presentation.page_count.unwrap(),
}; };
self.as_mut().add_presentation(pres); self.as_mut().add_presentation(pres);
@ -201,6 +202,7 @@ mod presentation_model {
title.eq(&presentation_title.to_string()), title.eq(&presentation_title.to_string()),
path.eq(&presentation_path.to_string()), path.eq(&presentation_path.to_string()),
html.eq(&presentation_html), html.eq(&presentation_html),
page_count.eq(&presentation.page_count),
)) ))
.execute(db); .execute(db);
println!("{:?}", result); println!("{:?}", result);
@ -256,6 +258,7 @@ mod presentation_model {
Role::TitleRole => 1, Role::TitleRole => 1,
Role::PathRole => 2, Role::PathRole => 2,
Role::HtmlRole => 3, Role::HtmlRole => 3,
Role::PageCountRole => 4,
_ => 0, _ => 0,
} }
} }
@ -307,6 +310,7 @@ mod presentation_model {
1 => QVariant::from(&presentation.title), 1 => QVariant::from(&presentation.title),
2 => QVariant::from(&presentation.path), 2 => QVariant::from(&presentation.path),
3 => QVariant::from(&presentation.html), 3 => QVariant::from(&presentation.html),
4 => QVariant::from(&presentation.page_count),
_ => QVariant::default(), _ => QVariant::default(),
}; };
} }
@ -327,6 +331,7 @@ mod presentation_model {
roles.insert(1, cxx_qt_lib::QByteArray::from("title")); roles.insert(1, cxx_qt_lib::QByteArray::from("title"));
roles.insert(2, cxx_qt_lib::QByteArray::from("filePath")); roles.insert(2, cxx_qt_lib::QByteArray::from("filePath"));
roles.insert(3, cxx_qt_lib::QByteArray::from("html")); roles.insert(3, cxx_qt_lib::QByteArray::from("html"));
roles.insert(4, cxx_qt_lib::QByteArray::from("pageCount"));
roles roles
} }