From 322f0d7908adf927f0106ede34ed3524d92881f1 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 19 Feb 2021 17:21:17 +0100 Subject: [PATCH] Fix set replace wallpaper from type video to gif Fix some wallpaper flickering (most of) --- ScreenPlayWallpaper/Wallpaper.qml | 11 ++++++----- ScreenPlayWallpaper/WebView.qml | 11 +++-------- ScreenPlayWallpaper/index.html | 2 +- ScreenPlayWallpaper/src/basewindow.cpp | 4 ++++ ScreenPlayWallpaper/src/basewindow.h | 1 + 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ScreenPlayWallpaper/Wallpaper.qml b/ScreenPlayWallpaper/Wallpaper.qml index 0337ffe4..51fa3d04 100644 --- a/ScreenPlayWallpaper/Wallpaper.qml +++ b/ScreenPlayWallpaper/Wallpaper.qml @@ -36,7 +36,6 @@ Rectangle { function onQmlSceneValueReceived(key, value) { var obj2 = 'import QtQuick 2.0; Item {Component.onCompleted: loader.item.' + key + ' = ' + value + '; }' - print(key, value) var newObject = Qt.createQmlObject(obj2.toString(), root, "err") newObject.destroy(10000) } @@ -51,6 +50,11 @@ Rectangle { loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath) } + // Replace wallpaper with GIF + function onReloadGIF(oldType) { + init() + } + // This function only gets called here (the same function // is inside the WebView.qml) when the previous Wallpaper type // was not a video @@ -78,7 +82,6 @@ Rectangle { break case InstalledType.QMLWallpaper: loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath) - print(loader.source) break case InstalledType.WebsiteWallpaper: loader.setSource("qrc:/WebsiteWallpaper.qml", { @@ -108,7 +111,6 @@ Rectangle { Loader { id: loader anchors.fill: parent - onStatusChanged: print(status) Connections { ignoreUnknownSignals: true target: loader.item @@ -127,8 +129,7 @@ Rectangle { right: parent.right } state: "in" - onStateChanged: print(state) - + onStatusChanged: print(status,source) sourceSize.width: Wallpaper.width sourceSize.height: Wallpaper.height source: { diff --git a/ScreenPlayWallpaper/WebView.qml b/ScreenPlayWallpaper/WebView.qml index bc341ea1..c3cd2645 100644 --- a/ScreenPlayWallpaper/WebView.qml +++ b/ScreenPlayWallpaper/WebView.qml @@ -39,27 +39,22 @@ Item { id: webView anchors.fill: parent url: "qrc:/index.html" + backgroundColor: "transparent" onJavaScriptConsoleMessage: print(lineNumber, message) onLoadProgressChanged: { if ((loadProgress === 100)) { if (Wallpaper.type === InstalledType.VideoWallpaper) { webView.runJavaScript(root.getSetVideoCommand(), function (result) { - fadeInTimer.start() + requestFadeIn() }) } else { - fadeInTimer.start() + requestFadeIn() } } } } - Timer { - id: fadeInTimer - interval: 500 - onTriggered: 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 ") diff --git a/ScreenPlayWallpaper/index.html b/ScreenPlayWallpaper/index.html index 717a664d..46e8f644 100644 --- a/ScreenPlayWallpaper/index.html +++ b/ScreenPlayWallpaper/index.html @@ -13,7 +13,7 @@ margin: 0px; padding: 0px; overflow: hidden; - background:black; + background: transparent; } #errorMsg{ position: fixed; diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index ca34e133..242c7077 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -168,6 +168,7 @@ void BaseWindow::replaceWallpaper( setCheckWallpaperVisible(checkWallpaperVisible); setVolume(volume); setFillMode(fillMode); + if (auto typeOpt = ScreenPlayUtil::getInstalledTypeFromString(type)) { setType(typeOpt.value()); } @@ -183,6 +184,9 @@ void BaseWindow::replaceWallpaper( if (m_type == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) emit reloadVideo(oldType); + + if (m_type == ScreenPlay::InstalledType::InstalledType::GifWallpaper) + emit reloadGIF(oldType); } // Used for loading shader diff --git a/ScreenPlayWallpaper/src/basewindow.h b/ScreenPlayWallpaper/src/basewindow.h index d1abb8d5..57edd8fb 100644 --- a/ScreenPlayWallpaper/src/basewindow.h +++ b/ScreenPlayWallpaper/src/basewindow.h @@ -174,6 +174,7 @@ signals: void qmlExit(); void reloadQML(const ScreenPlay::InstalledType::InstalledType oldType); void reloadVideo(const ScreenPlay::InstalledType::InstalledType oldType); + void reloadGIF(const ScreenPlay::InstalledType::InstalledType oldType); void loopsChanged(bool loops); void volumeChanged(float volume);