From bb5e753291dc30abf75089142b675863de538d10 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 14 Aug 2021 13:38:24 +0200 Subject: [PATCH] Move all qml files from all project into qml subfolder This makes the build script easier --- .../{assets.qrc => ScreenPlayAssets.qrc} | 0 ScreenPlay/{qml.qrc => ScreenPlayQML.qrc} | 0 ScreenPlayWallpaper/SPWResources.qrc | 10 +- .../{ => qml}/GifWallpaper.qml | 0 ScreenPlayWallpaper/{ => qml}/Test.qml | 0 ScreenPlayWallpaper/{ => qml}/Wallpaper.qml | 10 +- ScreenPlayWallpaper/{ => qml}/WebView.qml | 95 ++++++++++--------- .../{ => qml}/WebsiteWallpaper.qml | 0 ScreenPlayWallpaper/src/basewindow.cpp | 2 +- ScreenPlayWallpaper/src/winwindow.cpp | 2 +- ScreenPlayWidget/SPWidgetResources.qrc | 4 +- ScreenPlayWidget/{test.qml => qml/Test.qml} | 0 ScreenPlayWidget/{ => qml}/Widget.qml | 0 ScreenPlayWidget/src/widgetwindow.cpp | 4 +- 14 files changed, 66 insertions(+), 61 deletions(-) rename ScreenPlay/{assets.qrc => ScreenPlayAssets.qrc} (100%) rename ScreenPlay/{qml.qrc => ScreenPlayQML.qrc} (100%) rename ScreenPlayWallpaper/{ => qml}/GifWallpaper.qml (100%) rename ScreenPlayWallpaper/{ => qml}/Test.qml (100%) rename ScreenPlayWallpaper/{ => qml}/Wallpaper.qml (96%) rename ScreenPlayWallpaper/{ => qml}/WebView.qml (50%) rename ScreenPlayWallpaper/{ => qml}/WebsiteWallpaper.qml (100%) rename ScreenPlayWidget/{test.qml => qml/Test.qml} (100%) rename ScreenPlayWidget/{ => qml}/Widget.qml (100%) diff --git a/ScreenPlay/assets.qrc b/ScreenPlay/ScreenPlayAssets.qrc similarity index 100% rename from ScreenPlay/assets.qrc rename to ScreenPlay/ScreenPlayAssets.qrc diff --git a/ScreenPlay/qml.qrc b/ScreenPlay/ScreenPlayQML.qrc similarity index 100% rename from ScreenPlay/qml.qrc rename to ScreenPlay/ScreenPlayQML.qrc diff --git a/ScreenPlayWallpaper/SPWResources.qrc b/ScreenPlayWallpaper/SPWResources.qrc index fd8f9b66..3ddab174 100644 --- a/ScreenPlayWallpaper/SPWResources.qrc +++ b/ScreenPlayWallpaper/SPWResources.qrc @@ -1,12 +1,12 @@ - Wallpaper.qml - Test.qml dot.png qtquickcontrols2.conf - WebView.qml index.html - GifWallpaper.qml - WebsiteWallpaper.qml + qml/GifWallpaper.qml + qml/Test.qml + qml/Wallpaper.qml + qml/WebsiteWallpaper.qml + qml/WebView.qml diff --git a/ScreenPlayWallpaper/GifWallpaper.qml b/ScreenPlayWallpaper/qml/GifWallpaper.qml similarity index 100% rename from ScreenPlayWallpaper/GifWallpaper.qml rename to ScreenPlayWallpaper/qml/GifWallpaper.qml diff --git a/ScreenPlayWallpaper/Test.qml b/ScreenPlayWallpaper/qml/Test.qml similarity index 100% rename from ScreenPlayWallpaper/Test.qml rename to ScreenPlayWallpaper/qml/Test.qml diff --git a/ScreenPlayWallpaper/Wallpaper.qml b/ScreenPlayWallpaper/qml/Wallpaper.qml similarity index 96% rename from ScreenPlayWallpaper/Wallpaper.qml rename to ScreenPlayWallpaper/qml/Wallpaper.qml index 7428eb5c..3c005594 100644 --- a/ScreenPlayWallpaper/Wallpaper.qml +++ b/ScreenPlayWallpaper/qml/Wallpaper.qml @@ -14,10 +14,10 @@ Rectangle { function init() { switch (Wallpaper.type) { case InstalledType.VideoWallpaper: - loader.source = "qrc:/WebView.qml"; + loader.source = "qrc:/qml/WebView.qml"; break; case InstalledType.HTMLWallpaper: - loader.setSource("qrc:/WebView.qml", { + loader.setSource("qrc:/qml/WebView.qml", { "url": Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute) }); break; @@ -26,13 +26,13 @@ Rectangle { fadeIn(); break; case InstalledType.WebsiteWallpaper: - loader.setSource("qrc:/WebsiteWallpaper.qml", { + loader.setSource("qrc:/qml/WebsiteWallpaper.qml", { "url": Wallpaper.projectSourceFileAbsolute }); fadeIn(); break; case InstalledType.GifWallpaper: - loader.setSource("qrc:/GifWallpaper.qml", { + loader.setSource("qrc:/qml/GifWallpaper.qml", { "source": Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute) }); fadeIn(); @@ -96,7 +96,7 @@ Rectangle { return ; imgCover.state = "showDefaultBackgroundImage"; - loader.source = "qrc:/WebView.qml"; + loader.source = "qrc:/qml/WebView.qml"; } target: Wallpaper diff --git a/ScreenPlayWallpaper/WebView.qml b/ScreenPlayWallpaper/qml/WebView.qml similarity index 50% rename from ScreenPlayWallpaper/WebView.qml rename to ScreenPlayWallpaper/qml/WebView.qml index cd5dbacd..e48b707c 100644 --- a/ScreenPlayWallpaper/WebView.qml +++ b/ScreenPlayWallpaper/qml/WebView.qml @@ -8,31 +8,31 @@ Item { property alias url: webView.url - signal requestFadeIn() + signal requestFadeIn function getSetVideoCommand() { // 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 = '" + Wallpaper.projectSourceFileAbsolute + "';"; - src += "videoPlayer.load();"; - src += "videoPlayer.volume = " + Wallpaper.volume + ";"; - src += "videoPlayer.setAttribute('style', 'object-fit :" + Wallpaper.fillMode + ";');"; - src += "videoPlayer.play();"; - return src; + var src = "" + src += "var videoPlayer = document.getElementById('videoPlayer');" + src += "var videoSource = document.getElementById('videoSource');" + src += "videoSource.src = '" + Wallpaper.projectSourceFileAbsolute + "';" + src += "videoPlayer.load();" + src += "videoPlayer.volume = " + Wallpaper.volume + ";" + src += "videoPlayer.setAttribute('style', 'object-fit :" + Wallpaper.fillMode + ";');" + src += "videoPlayer.play();" + return src } Component.onCompleted: { - WebEngine.settings.localContentCanAccessFileUrls = true; - WebEngine.settings.localContentCanAccessRemoteUrls = true; - WebEngine.settings.allowRunningInsecureContent = true; - WebEngine.settings.accelerated2dCanvasEnabled = true; - WebEngine.settings.javascriptCanOpenWindows = false; - WebEngine.settings.showScrollBars = false; - WebEngine.settings.playbackRequiresUserGesture = false; - WebEngine.settings.focusOnNavigationEnabled = true; + WebEngine.settings.localContentCanAccessFileUrls = true + WebEngine.settings.localContentCanAccessRemoteUrls = true + WebEngine.settings.allowRunningInsecureContent = true + WebEngine.settings.accelerated2dCanvasEnabled = true + WebEngine.settings.javascriptCanOpenWindows = false + WebEngine.settings.showScrollBars = false + WebEngine.settings.playbackRequiresUserGesture = false + WebEngine.settings.focusOnNavigationEnabled = true } WebEngineView { @@ -45,18 +45,18 @@ Item { onLoadProgressChanged: { if ((loadProgress === 100)) { if (Wallpaper.type === InstalledType.VideoWallpaper) - webView.runJavaScript(root.getSetVideoCommand(), function(result) { - requestFadeIn(); - }); + webView.runJavaScript(root.getSetVideoCommand(), + function (result) { + requestFadeIn() + }) else - requestFadeIn(); + requestFadeIn() } } } Text { id: txtVisualsPaused - text: qsTr("If you can read this, then the VisualsPaused optimization does not work on your system. You can fix this by disable this in: \n Settings -> Perfromance -> Pause wallpaper video rendering while another app is in the foreground ") font.pointSize: 32 visible: false @@ -73,77 +73,82 @@ Item { interval: 300 onTriggered: { - webView.visible = !Wallpaper.visualsPaused; - txtVisualsPaused.visible = Wallpaper.visualsPaused; + webView.visible = !Wallpaper.visualsPaused + txtVisualsPaused.visible = Wallpaper.visualsPaused } } Connections { function onReloadVideo(oldType) { - webView.runJavaScript(root.getSetVideoCommand()); + webView.runJavaScript(root.getSetVideoCommand()) } function onQmlExit() { - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;"); + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;") } function onMutedChanged(muted) { if (muted) - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;"); + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;") else - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + Wallpaper.volume + ";"); + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + Wallpaper.volume + ";") } function onFillModeChanged(fillMode) { if (webView.loadProgress === 100) - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.setAttribute('style', 'object-fit :" + fillMode + ";');"); - + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.setAttribute('style', 'object-fit :" + fillMode + ";');") } function onLoopsChanged(loops) { if (webView.loadProgress === 100) - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.loop = " + loops + ";"); - + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.loop = " + loops + ";") } function onVolumeChanged(volume) { if (webView.loadProgress === 100) - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + volume + ";"); - + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + volume + ";") } function onCurrentTimeChanged(currentTime) { if (webView.loadProgress === 100) - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.currentTime = " + currentTime + " * videoPlayer.duration;"); - + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.currentTime = " + + currentTime + " * videoPlayer.duration;") } function onPlaybackRateChanged(playbackRate) { if (webView.loadProgress === 100) - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.playbackRate = " + playbackRate + ";"); - + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.playbackRate = " + playbackRate + ";") } function onVisualsPausedChanged(visualsPaused) { if (visualsPaused) { // Wait until Wallpaper animation is finsihed - timerCover.restart(); + timerCover.restart() } else { - webView.visible = true; - txtVisualsPaused.visible = false; + webView.visible = true + txtVisualsPaused.visible = false } } function onIsPlayingChanged(isPlaying) { if (webView.loadProgress === 100) { if (isPlaying) - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.play();"); + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.play();") else - webView.runJavaScript("var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.pause();"); + webView.runJavaScript( + "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.pause();") } } target: Wallpaper } - } diff --git a/ScreenPlayWallpaper/WebsiteWallpaper.qml b/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml similarity index 100% rename from ScreenPlayWallpaper/WebsiteWallpaper.qml rename to ScreenPlayWallpaper/qml/WebsiteWallpaper.qml diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index b6fc599c..480fb191 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -55,7 +55,7 @@ BaseWindow::BaseWindow( if (projectFilePath == "test") { setType(ScreenPlay::InstalledType::InstalledType::QMLWallpaper); - setProjectSourceFileAbsolute({ "qrc:/Test.qml" }); + setProjectSourceFileAbsolute({ "qrc:/qml/Test.qml" }); setupLiveReloading(); return; } diff --git a/ScreenPlayWallpaper/src/winwindow.cpp b/ScreenPlayWallpaper/src/winwindow.cpp index 2a397fae..5937a7a9 100644 --- a/ScreenPlayWallpaper/src/winwindow.cpp +++ b/ScreenPlayWallpaper/src/winwindow.cpp @@ -483,7 +483,7 @@ void WinWindow::configureWindowGeometry() // we can set it here once :) m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); - m_window.setSource(QUrl("qrc:/Wallpaper.qml")); + m_window.setSource(QUrl("qrc:/qml/Wallpaper.qml")); m_window.hide(); } diff --git a/ScreenPlayWidget/SPWidgetResources.qrc b/ScreenPlayWidget/SPWidgetResources.qrc index d820a046..81163506 100644 --- a/ScreenPlayWidget/SPWidgetResources.qrc +++ b/ScreenPlayWidget/SPWidgetResources.qrc @@ -1,10 +1,10 @@ assets/image/noisy-texture-3.png - test.qml - Widget.qml assets/icons/baseline-close-24px.svg assets/icons/baseline-opacity-24px.svg assets/icons/baseline-settings-20px.svg + qml/Test.qml + qml/Widget.qml diff --git a/ScreenPlayWidget/test.qml b/ScreenPlayWidget/qml/Test.qml similarity index 100% rename from ScreenPlayWidget/test.qml rename to ScreenPlayWidget/qml/Test.qml diff --git a/ScreenPlayWidget/Widget.qml b/ScreenPlayWidget/qml/Widget.qml similarity index 100% rename from ScreenPlayWidget/Widget.qml rename to ScreenPlayWidget/qml/Widget.qml diff --git a/ScreenPlayWidget/src/widgetwindow.cpp b/ScreenPlayWidget/src/widgetwindow.cpp index de817609..886914f6 100644 --- a/ScreenPlayWidget/src/widgetwindow.cpp +++ b/ScreenPlayWidget/src/widgetwindow.cpp @@ -49,7 +49,7 @@ WidgetWindow::WidgetWindow( #endif if (projectPath == "test") { - setProjectSourceFileAbsolute({ "qrc:/test.qml" }); + setProjectSourceFileAbsolute({ "qrc:/qml/Test.qml" }); setType(ScreenPlay::InstalledType::InstalledType::QMLWidget); } else { setProjectPath(projectPath); @@ -71,7 +71,7 @@ WidgetWindow::WidgetWindow( m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); m_window.setResizeMode(QQuickView::ResizeMode::SizeViewToRootObject); - m_window.setSource(QUrl("qrc:/Widget.qml")); + m_window.setSource(QUrl("qrc:/qml/Widget.qml")); m_window.setPosition(m_position); m_window.show();