From c7e5f1f722d94c33a473fbe653a36b45eb0f14f1 Mon Sep 17 00:00:00 2001 From: kelteseth Date: Thu, 6 Sep 2018 15:54:55 +0200 Subject: [PATCH] Restore qml wallpaper functionality --- ScreenPlayWindow/main.qml | 57 ++++++++++++++++---------- ScreenPlayWindow/src/SPWmainwindow.cpp | 6 +-- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/ScreenPlayWindow/main.qml b/ScreenPlayWindow/main.qml index 3cd21ebc..dd246760 100644 --- a/ScreenPlayWindow/main.qml +++ b/ScreenPlayWindow/main.qml @@ -10,20 +10,16 @@ Rectangle { Connections { target: mainwindow - - onPlayVideo: { - - } - onPlayQmlScene: { - - } - onFillModeChanged: { } onLoopsChanged: { } + onTypeChanged: { + print(mainwindow.type) + } + onVolumeChanged: { if (webView.loadProgress === 100) { webView.runJavaScript( @@ -43,36 +39,55 @@ Rectangle { } } + Component.onCompleted: { + if (mainwindow.type === "qmlScene") { + loader.setSource(Qt.resolvedUrl( + "file:///" + mainwindow.fullContentPath)) + print("LOADING QMLSCENE" + loader.source) + mainwindow.init() + timer.start() + } else if (mainwindow.type === "video") { + webView.visible = true + webView.url = Qt.resolvedUrl("file:///" + mainwindow.getApplicationPath( + ) + "/index.html") + } + } + WebEngineView { id: webView anchors.fill: parent - url: Qt.resolvedUrl("file:///" + mainwindow.getApplicationPath( - ) + "/index.html") + visible: false + onLoadProgressChanged: { if (loadProgress === 100) { runJavaScript((" - var videoPlayer = document.getElementById('videoPlayer'); - var videoSource = document.getElementById('videoSource'); - videoSource.src = \"file:///" + mainwindow.fullContentPath + "\"; - videoPlayer.load(); - videoPlayer.volume = " + mainwindow.volume + ";"), - function (result) { - mainwindow.init() - timer.start() - }) +var videoPlayer = document.getElementById('videoPlayer'); +var videoSource = document.getElementById('videoSource'); +videoSource.src = \"file:///" + mainwindow.fullContentPath + "\"; +videoPlayer.load(); +videoPlayer.volume = " + mainwindow.volume + ";"), function (result) { + mainwindow.init() + timer.start() +}) } } onJavaScriptConsoleMessage: print(message) settings.allowRunningInsecureContent: true } + Loader { + id: loader + anchors.fill: parent + onStatusChanged: { + print(webViewWrapper.errorString()) + } + } + Timer { id: timer interval: 200 onTriggered: { - curtain.opacity = 0 anim.start() - print("start") } } diff --git a/ScreenPlayWindow/src/SPWmainwindow.cpp b/ScreenPlayWindow/src/SPWmainwindow.cpp index 7a5209f2..57efab58 100644 --- a/ScreenPlayWindow/src/SPWmainwindow.cpp +++ b/ScreenPlayWindow/src/SPWmainwindow.cpp @@ -59,13 +59,13 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder, if (m_project.value("type") == "video") { QString tmpPath = m_projectPath.toString() + "/" + m_projectFile; setFullContentPath(tmpPath); - - emit playVideo(tmpPath); + setType("video"); } else if (m_project.value("type") == "scene") { return; } else if (m_project.value("type") == "qmlScene") { QString tmpPath = m_projectPath.toString() + "/" + m_projectFile; - emit playQmlScene(tmpPath); + setFullContentPath(tmpPath); + setType("qmlScene"); } }