diff --git a/ScreenPlayWallpaper/WebView.qml b/ScreenPlayWallpaper/WebView.qml index b4faf19d..8df63ccc 100644 --- a/ScreenPlayWallpaper/WebView.qml +++ b/ScreenPlayWallpaper/WebView.qml @@ -1,9 +1,11 @@ import QtQuick 2.0 -import ScreenPlay.Wallpaper 1.0 import QtWebEngine 1.8 +import ScreenPlay.Wallpaper 1.0 + Item { - property string url: webView.url + id:root + property alias url: webView.url signal requestFadeIn() @@ -21,28 +23,32 @@ Item { id: webView anchors.fill: parent url: Qt.resolvedUrl(window.getApplicationPath() + "/index.html") + onUrlChanged: print(url) + onJavaScriptConsoleMessage: print(lineNumber, message) onLoadProgressChanged: { - if (loadProgress === 100) { + if ((loadProgress === 100)) { - // TODO 30: - // Currently wont work. Commit anyways til QtCreator and Qt work with js template literals - var src = "" - src += "var videoPlayer = document.getElementById('videoPlayer');" - src += "var videoSource = document.getElementById('videoSource');" - src += "videoSource.src = '" + window.fullContentPath + "';" - src += "videoPlayer.load();" - src += "videoPlayer.volume = " + window.volume + ";" - src += "videoPlayer.setAttribute('style', 'object-fit :" + window.fillMode + ";');" - src += "videoPlayer.play();" + if(window.type === Wallpaper.WallpaperType.Video){ + // TODO 30: + // Currently wont work. Commit anyways til QtCreator and Qt work with js template literals + var src = "" + src += "var videoPlayer = document.getElementById('videoPlayer');" + src += "var videoSource = document.getElementById('videoSource');" + src += "videoSource.src = '" + window.fullContentPath + "';" + src += "videoPlayer.load();" + src += "videoPlayer.volume = " + window.volume + ";" + src += "videoPlayer.setAttribute('style', 'object-fit :" + window.fillMode + ";');" + src += "videoPlayer.play();" - webView.runJavaScript(src, function (result) { + webView.runJavaScript(src, function (result) { + fadeInTimer.start() + }) + } else { fadeInTimer.start() - - }) + } } } - onJavaScriptConsoleMessage: print(lineNumber, message) } Timer { diff --git a/ScreenPlayWallpaper/mainWindow.qml b/ScreenPlayWallpaper/mainWindow.qml index e2515572..718e8f68 100644 --- a/ScreenPlayWallpaper/mainWindow.qml +++ b/ScreenPlayWallpaper/mainWindow.qml @@ -38,15 +38,14 @@ Rectangle { switch (window.type) { case Wallpaper.WallpaperType.Video: loader.source = "qrc:/WebView.qml" - break case Wallpaper.WallpaperType.Html: - loader.source = "qrc:/WebView.qml" loader.webViewUrl = Qt.resolvedUrl(window.fullContentPath) + loader.source = "qrc:/WebView.qml" break case Wallpaper.WallpaperType.ThreeJSScene: - loader.source = "qrc:/WebView.qml" loader.webViewUrl = Qt.resolvedUrl(window.fullContentPath) + loader.source = "qrc:/WebView.qml" break case Wallpaper.WallpaperType.Qml: loader.source = Qt.resolvedUrl(window.fullContentPath) @@ -56,9 +55,7 @@ Rectangle { } function fadeIn() { - print("fadeIn()") window.setVisible(true) - print("setVisible()") if (canFadeByWallpaperFillMode && window.canFade) { print("fadein") imgCover.state = "out" @@ -75,8 +72,10 @@ Rectangle { property string webViewUrl onStatusChanged: { if (loader.status === Loader.Ready) { - if (window.type === Wallpaper.WallpaperType.Video) { + if (window.type === Wallpaper.WallpaperType.Html + || window.type === Wallpaper.WallpaperType.ThreeJSScene) { loader.item.url = loader.webViewUrl + print(loader.item.url," --- ",loader.webViewUrl) } } } @@ -84,7 +83,7 @@ Rectangle { Connections { ignoreUnknownSignals: true target: loader.item - onRequestFadeIn:fadeIn() + onRequestFadeIn: fadeIn() } }