2020-07-18 20:21:47 +02:00
|
|
|
import QtQml 2.14
|
2021-04-18 17:23:21 +02:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
2020-07-18 20:21:47 +02:00
|
|
|
import ScreenPlayWallpaper 1.0
|
2021-01-31 16:21:32 +01:00
|
|
|
import ScreenPlay.Enums.InstalledType 1.0
|
2020-09-13 19:51:20 +02:00
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
Rectangle {
|
2019-06-09 12:21:03 +02:00
|
|
|
id: root
|
2021-05-16 19:37:55 +02:00
|
|
|
|
|
|
|
property bool canFadeByWallpaperFillMode: true
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
switch (Wallpaper.type) {
|
|
|
|
case InstalledType.VideoWallpaper:
|
2021-08-14 13:38:24 +02:00
|
|
|
loader.source = "qrc:/qml/WebView.qml";
|
2021-05-16 19:37:55 +02:00
|
|
|
break;
|
|
|
|
case InstalledType.HTMLWallpaper:
|
2021-08-14 13:38:24 +02:00
|
|
|
loader.setSource("qrc:/qml/WebView.qml", {
|
2021-05-16 19:37:55 +02:00
|
|
|
"url": Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute)
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case InstalledType.QMLWallpaper:
|
|
|
|
loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute);
|
|
|
|
fadeIn();
|
|
|
|
break;
|
|
|
|
case InstalledType.WebsiteWallpaper:
|
2021-08-14 13:38:24 +02:00
|
|
|
loader.setSource("qrc:/qml/WebsiteWallpaper.qml", {
|
2021-05-16 19:37:55 +02:00
|
|
|
"url": Wallpaper.projectSourceFileAbsolute
|
|
|
|
});
|
|
|
|
fadeIn();
|
|
|
|
break;
|
|
|
|
case InstalledType.GifWallpaper:
|
2021-08-14 13:38:24 +02:00
|
|
|
loader.setSource("qrc:/qml/GifWallpaper.qml", {
|
2021-05-16 19:37:55 +02:00
|
|
|
"source": Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute)
|
|
|
|
});
|
|
|
|
fadeIn();
|
|
|
|
break;
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
function fadeIn() {
|
|
|
|
Wallpaper.setVisible(true);
|
|
|
|
if (canFadeByWallpaperFillMode && Wallpaper.canFade)
|
|
|
|
imgCover.state = "hideDefaultBackgroundImage";
|
|
|
|
else
|
|
|
|
imgCover.opacity = 0;
|
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
color: {
|
|
|
|
if (Qt.platform.os !== "windows")
|
|
|
|
return "black";
|
|
|
|
else
|
|
|
|
return Wallpaper.windowsDesktopProperties.color;
|
|
|
|
}
|
2020-03-09 18:06:50 +01:00
|
|
|
Component.onCompleted: {
|
2021-05-16 19:37:55 +02:00
|
|
|
init();
|
2020-03-09 18:06:50 +01:00
|
|
|
}
|
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
Connections {
|
2020-03-25 21:29:01 +01:00
|
|
|
function onQmlExit() {
|
2021-05-16 19:37:55 +02:00
|
|
|
if (canFadeByWallpaperFillMode && Wallpaper.canFade)
|
|
|
|
imgCover.state = "exit";
|
|
|
|
else
|
|
|
|
Wallpaper.terminate();
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
2019-03-30 12:56:34 +01:00
|
|
|
|
2020-07-18 20:21:47 +02:00
|
|
|
function onQmlSceneValueReceived(key, value) {
|
2021-05-16 19:37:55 +02:00
|
|
|
var obj2 = 'import QtQuick 2.0; Item {Component.onCompleted: loader.item.' + key + ' = ' + value + '; }';
|
|
|
|
var newObject = Qt.createQmlObject(obj2.toString(), root, "err");
|
|
|
|
newObject.destroy(10000);
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
2020-07-18 20:21:47 +02:00
|
|
|
|
2020-08-11 20:18:34 +02:00
|
|
|
// Replace wallpaper with QML Scene
|
|
|
|
function onReloadQML(oldType) {
|
2021-05-16 19:37:55 +02:00
|
|
|
loader.sourceComponent = undefined;
|
|
|
|
loader.source = "";
|
|
|
|
Wallpaper.clearComponentCache();
|
|
|
|
loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute);
|
2020-08-11 20:18:34 +02:00
|
|
|
}
|
|
|
|
|
2021-02-19 17:21:17 +01:00
|
|
|
// Replace wallpaper with GIF
|
|
|
|
function onReloadGIF(oldType) {
|
2021-05-16 19:37:55 +02:00
|
|
|
init();
|
2021-02-19 17:21:17 +01:00
|
|
|
}
|
|
|
|
|
2020-08-11 20:18:34 +02:00
|
|
|
// This function only gets called here (the same function
|
|
|
|
// is inside the WebView.qml) when the previous Wallpaper type
|
|
|
|
// was not a video
|
|
|
|
function onReloadVideo(oldType) {
|
|
|
|
// We need to check if the old type
|
|
|
|
// was also Video not get called twice
|
2021-01-31 16:21:32 +01:00
|
|
|
if (oldType === InstalledType.VideoWallpaper)
|
2021-05-16 19:37:55 +02:00
|
|
|
return ;
|
2020-08-11 20:18:34 +02:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
imgCover.state = "showDefaultBackgroundImage";
|
2021-08-14 13:38:24 +02:00
|
|
|
loader.source = "qrc:/qml/WebView.qml";
|
2020-03-09 18:06:50 +01:00
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
target: Wallpaper
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
|
|
|
|
2019-06-12 16:54:05 +02:00
|
|
|
Loader {
|
|
|
|
id: loader
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-06-12 16:54:05 +02:00
|
|
|
anchors.fill: parent
|
2021-02-28 12:46:56 +01:00
|
|
|
// QML Engine deadlocks in 5.15.2 when a loader cannot load
|
|
|
|
// an item. QApplication::quit(); waits for the destruction forever.
|
|
|
|
asynchronous: true
|
|
|
|
onStatusChanged: {
|
|
|
|
if (loader.status === Loader.Error) {
|
2021-05-16 19:37:55 +02:00
|
|
|
loader.source = "";
|
|
|
|
Wallpaper.terminate();
|
2021-02-28 12:46:56 +01:00
|
|
|
}
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
Connections {
|
2020-03-25 21:29:01 +01:00
|
|
|
function onRequestFadeIn() {
|
2021-05-16 19:37:55 +02:00
|
|
|
fadeIn();
|
2020-03-25 21:29:01 +01:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
|
|
|
ignoreUnknownSignals: true
|
|
|
|
target: loader.item
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-06-12 16:54:05 +02:00
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgCover
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-21 18:13:47 +02:00
|
|
|
state: "showDefaultBackgroundImage"
|
2020-07-18 20:21:47 +02:00
|
|
|
sourceSize.width: Wallpaper.width
|
|
|
|
sourceSize.height: Wallpaper.height
|
|
|
|
source: {
|
2021-05-16 19:37:55 +02:00
|
|
|
if (Qt.platform.os === "windows")
|
|
|
|
return Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath);
|
2021-05-21 12:02:16 +02:00
|
|
|
else
|
|
|
|
return ""
|
2021-05-16 19:37:55 +02:00
|
|
|
}
|
2021-05-18 17:26:02 +02:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (Qt.platform.os !== "windows") {
|
|
|
|
root.canFadeByWallpaperFillMode = false;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
switch (Wallpaper.windowsDesktopProperties.wallpaperStyle) {
|
|
|
|
case 10:
|
|
|
|
imgCover.fillMode = Image.PreserveAspectCrop;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
imgCover.fillMode = Image.PreserveAspectFit;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
if (desktopProperties.isTiled) {
|
|
|
|
// Tiled
|
|
|
|
imgCover.fillMode = Image.Tile;
|
|
|
|
} else {
|
|
|
|
// Center
|
|
|
|
imgCover.fillMode = Image.PreserveAspectFit;
|
|
|
|
imgCover.anchors.centerIn = parent;
|
|
|
|
imgCover.width = sourceSize.width;
|
|
|
|
imgCover.height = sourceSize.height;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 22:
|
|
|
|
root.canFadeByWallpaperFillMode = false;
|
|
|
|
break;
|
2020-07-18 20:21:47 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-26 17:28:30 +02:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
topMargin: -3 // To fix the offset from setupWallpaperForOneScreen
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
states: [
|
|
|
|
State {
|
2021-04-21 18:13:47 +02:00
|
|
|
name: "showDefaultBackgroundImage"
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
PropertyChanges {
|
|
|
|
target: imgCover
|
|
|
|
opacity: 1
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
},
|
|
|
|
State {
|
2021-04-21 18:13:47 +02:00
|
|
|
name: "hideDefaultBackgroundImage"
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
PropertyChanges {
|
|
|
|
target: imgCover
|
|
|
|
opacity: 0
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
},
|
|
|
|
State {
|
2021-04-21 18:13:47 +02:00
|
|
|
name: "exit"
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
PropertyChanges {
|
|
|
|
target: imgCover
|
|
|
|
opacity: 1
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
2021-04-21 18:13:47 +02:00
|
|
|
from: "showDefaultBackgroundImage"
|
|
|
|
to: "hideDefaultBackgroundImage"
|
2019-11-23 17:22:24 +01:00
|
|
|
reversible: true
|
2021-04-21 18:13:47 +02:00
|
|
|
|
|
|
|
SequentialAnimation {
|
|
|
|
PauseAnimation {
|
|
|
|
duration: 100
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-21 18:13:47 +02:00
|
|
|
PropertyAnimation {
|
|
|
|
target: imgCover
|
|
|
|
duration: 600
|
|
|
|
property: "opacity"
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
},
|
|
|
|
Transition {
|
2021-04-21 18:13:47 +02:00
|
|
|
from: "hideDefaultBackgroundImage"
|
|
|
|
to: "exit"
|
2019-11-23 17:22:24 +01:00
|
|
|
reversible: true
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
SequentialAnimation {
|
|
|
|
PropertyAnimation {
|
|
|
|
target: imgCover
|
|
|
|
duration: 600
|
|
|
|
property: "opacity"
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
ScriptAction {
|
2020-07-18 20:21:47 +02:00
|
|
|
script: Wallpaper.terminate()
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
]
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
2021-04-18 17:23:21 +02:00
|
|
|
|
|
|
|
Pane {
|
|
|
|
id: debug
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
visible: Wallpaper.debugMode
|
|
|
|
enabled: Wallpaper.debugMode
|
2021-05-16 19:37:55 +02:00
|
|
|
width: parent.width * 0.3
|
|
|
|
height: parent.height * 0.3
|
2021-04-18 17:23:21 +02:00
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
Column {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 20
|
|
|
|
spacing: 10
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
Text {
|
|
|
|
text: "appID " + Wallpaper.appID
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
Text {
|
2021-05-14 12:50:22 +02:00
|
|
|
text: "projectPath " + Wallpaper.projectPath
|
2021-04-18 17:23:21 +02:00
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
Text {
|
2021-05-14 12:50:22 +02:00
|
|
|
text: "projectSourceFileAbsolute " + Wallpaper.projectSourceFileAbsolute
|
2021-04-18 17:23:21 +02:00
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
Text {
|
|
|
|
text: "fillMode " + Wallpaper.fillMode
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
Text {
|
|
|
|
text: "sdk.type " + Wallpaper.sdk.type
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
Text {
|
|
|
|
text: "sdk.isConnected " + Wallpaper.sdk.isConnected
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
Text {
|
|
|
|
text: "sdk.appID " + Wallpaper.sdk.appID
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-21 18:13:47 +02:00
|
|
|
Text {
|
|
|
|
text: "canFadeByWallpaperFillMode " + canFadeByWallpaperFillMode
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-21 18:13:47 +02:00
|
|
|
Text {
|
|
|
|
text: "Wallpaper.canFade " + Wallpaper.canFade
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-21 18:13:47 +02:00
|
|
|
Text {
|
2021-05-18 17:26:02 +02:00
|
|
|
text: {
|
|
|
|
if (Qt.platform.os === "windows")
|
|
|
|
return "imgCover.source " + Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath)
|
|
|
|
else
|
|
|
|
return ""
|
|
|
|
}
|
2021-04-21 18:13:47 +02:00
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-21 18:13:47 +02:00
|
|
|
Text {
|
|
|
|
text: "imgCover.status " + imgCover.status
|
|
|
|
font.pointSize: 14
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
opacity: 0.5
|
2021-04-18 17:23:21 +02:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|