2020-07-18 20:21:47 +02:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQml 2.14
|
|
|
|
import ScreenPlayWallpaper 1.0
|
2020-09-13 19:51:20 +02:00
|
|
|
import ScreenPlay.Shader 1.0
|
|
|
|
import "ShaderWrapper" as ShaderWrapper
|
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
Rectangle {
|
2019-06-09 12:21:03 +02:00
|
|
|
id: root
|
2019-03-28 21:25:39 +01:00
|
|
|
anchors.fill: parent
|
|
|
|
color: {
|
2020-07-18 20:21:47 +02:00
|
|
|
if (Qt.platform.os !== "windows") {
|
2019-03-28 21:25:39 +01:00
|
|
|
return "black"
|
|
|
|
} else {
|
2020-07-18 20:21:47 +02:00
|
|
|
return Wallpaper.windowsDesktopProperties.color
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-11 19:48:07 +02:00
|
|
|
property bool canFadeByWallpaperFillMode: true
|
2019-03-28 21:25:39 +01:00
|
|
|
|
2020-03-09 18:06:50 +01:00
|
|
|
Component.onCompleted: {
|
2020-07-18 20:21:47 +02:00
|
|
|
init()
|
2020-03-09 18:06:50 +01:00
|
|
|
}
|
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
Connections {
|
2020-07-18 20:21:47 +02:00
|
|
|
target: Wallpaper
|
2019-11-23 17:22:24 +01:00
|
|
|
|
2020-03-25 21:29:01 +01:00
|
|
|
function onQmlExit() {
|
2020-07-18 20:21:47 +02:00
|
|
|
if (canFadeByWallpaperFillMode && Wallpaper.canFade) {
|
2019-11-23 17:22:24 +01:00
|
|
|
imgCover.state = "outExit"
|
|
|
|
} else {
|
2020-07-18 20:21:47 +02:00
|
|
|
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) {
|
2019-11-23 17:22:24 +01:00
|
|
|
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)
|
|
|
|
}
|
2020-07-18 20:21:47 +02:00
|
|
|
|
2020-08-11 20:18:34 +02:00
|
|
|
// Replace wallpaper with QML Scene
|
|
|
|
function onReloadQML(oldType) {
|
|
|
|
|
2020-03-09 18:06:50 +01:00
|
|
|
loader.sourceComponent = undefined
|
|
|
|
loader.source = ""
|
2020-11-07 14:02:27 +01:00
|
|
|
Wallpaper.clearComponentCache()
|
2020-08-11 20:18:34 +02:00
|
|
|
|
|
|
|
loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
if (oldType === Wallpaper.WallpaperType.Video)
|
2020-08-23 19:06:17 +02:00
|
|
|
return
|
2020-08-11 20:18:34 +02:00
|
|
|
|
|
|
|
imgCover.state = "in"
|
|
|
|
loader.source = "qrc:/WebView.qml"
|
2020-03-09 18:06:50 +01:00
|
|
|
}
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
|
2020-07-18 20:21:47 +02:00
|
|
|
function init() {
|
|
|
|
switch (Wallpaper.type) {
|
2019-03-28 21:25:39 +01:00
|
|
|
case Wallpaper.WallpaperType.Video:
|
2019-11-23 17:22:24 +01:00
|
|
|
loader.source = "qrc:/WebView.qml"
|
2019-03-28 21:25:39 +01:00
|
|
|
break
|
|
|
|
case Wallpaper.WallpaperType.Html:
|
2020-07-18 20:21:47 +02:00
|
|
|
loader.webViewUrl = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
2019-11-23 18:20:32 +01:00
|
|
|
loader.source = "qrc:/WebView.qml"
|
2020-08-11 20:18:34 +02:00
|
|
|
fadeIn()
|
2019-03-28 21:25:39 +01:00
|
|
|
break
|
|
|
|
case Wallpaper.WallpaperType.Qml:
|
2020-07-18 20:21:47 +02:00
|
|
|
loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
2019-11-23 17:22:24 +01:00
|
|
|
imgCover.state = "out"
|
2020-08-11 20:18:34 +02:00
|
|
|
fadeIn()
|
2019-03-28 21:25:39 +01:00
|
|
|
break
|
2020-12-28 17:26:56 +01:00
|
|
|
case Wallpaper.WallpaperType.Website:
|
|
|
|
loader.setSource("qrc:/WebsiteWallpaper.qml", {
|
|
|
|
"source": Qt.resolvedUrl(
|
|
|
|
Wallpaper.fullContentPath)
|
|
|
|
})
|
|
|
|
fadeIn()
|
|
|
|
break
|
|
|
|
case Wallpaper.WallpaperType.Gif:
|
|
|
|
loader.setSource("qrc:/GifWallpaper.qml", {
|
|
|
|
"source": Qt.resolvedUrl(
|
|
|
|
Wallpaper.fullContentPath)
|
|
|
|
})
|
|
|
|
fadeIn()
|
|
|
|
break
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fadeIn() {
|
2020-07-18 20:21:47 +02:00
|
|
|
Wallpaper.setVisible(true)
|
|
|
|
if (canFadeByWallpaperFillMode && Wallpaper.canFade) {
|
2019-11-23 17:22:24 +01:00
|
|
|
imgCover.state = "out"
|
2019-03-28 21:25:39 +01:00
|
|
|
} else {
|
|
|
|
imgCover.opacity = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-12 16:54:05 +02:00
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
anchors.fill: parent
|
2019-11-23 17:22:24 +01:00
|
|
|
property string webViewUrl
|
|
|
|
onStatusChanged: {
|
|
|
|
if (loader.status === Loader.Ready) {
|
2020-12-11 14:14:00 +01:00
|
|
|
if (Wallpaper.type === Wallpaper.WallpaperType.Html) {
|
2019-11-23 17:22:24 +01:00
|
|
|
loader.item.url = loader.webViewUrl
|
2020-07-18 20:21:47 +02:00
|
|
|
print(loader.item.url, " --- ", loader.webViewUrl)
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
ignoreUnknownSignals: true
|
|
|
|
target: loader.item
|
2020-03-25 21:29:01 +01:00
|
|
|
function onRequestFadeIn() {
|
|
|
|
fadeIn()
|
|
|
|
}
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
2019-06-12 16:54:05 +02:00
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgCover
|
2019-07-26 17:28:30 +02:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
2020-12-11 14:14:00 +01:00
|
|
|
topMargin: -3 // To fix the offset from setupWallpaperForOneScreen
|
2019-07-26 17:28:30 +02:00
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
2019-11-23 17:22:24 +01:00
|
|
|
state: "in"
|
2019-07-26 17:28:30 +02:00
|
|
|
|
2020-07-18 20:21:47 +02:00
|
|
|
sourceSize.width: Wallpaper.width
|
|
|
|
sourceSize.height: Wallpaper.height
|
|
|
|
source: {
|
|
|
|
if (Qt.platform.os === "windows") {
|
|
|
|
return Qt.resolvedUrl(
|
|
|
|
"file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath)
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2019-07-26 17:28:30 +02:00
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "in"
|
|
|
|
PropertyChanges {
|
|
|
|
target: imgCover
|
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "out"
|
|
|
|
PropertyChanges {
|
|
|
|
target: imgCover
|
|
|
|
opacity: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "outExit"
|
|
|
|
PropertyChanges {
|
|
|
|
target: imgCover
|
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
from: "out"
|
|
|
|
to: "in"
|
|
|
|
reversible: true
|
|
|
|
PropertyAnimation {
|
|
|
|
target: imgCover
|
|
|
|
duration: 600
|
|
|
|
property: "opacity"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
from: "out"
|
|
|
|
to: "outExit"
|
|
|
|
reversible: true
|
|
|
|
SequentialAnimation {
|
|
|
|
PropertyAnimation {
|
|
|
|
target: imgCover
|
|
|
|
duration: 600
|
|
|
|
property: "opacity"
|
|
|
|
}
|
|
|
|
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
|
|
|
Component.onCompleted: {
|
2019-07-26 17:28:30 +02:00
|
|
|
|
2020-08-23 19:06:17 +02:00
|
|
|
if (Qt.platform.os !== "windows") {
|
|
|
|
root.canFadeByWallpaperFillMode = false
|
2020-07-18 20:21:47 +02:00
|
|
|
return
|
2020-08-23 19:06:17 +02:00
|
|
|
}
|
2020-07-18 20:21:47 +02:00
|
|
|
|
|
|
|
switch (Wallpaper.windowsDesktopProperties.wallpaperStyle) {
|
2019-03-28 21:25:39 +01:00
|
|
|
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:
|
2020-08-23 19:06:17 +02:00
|
|
|
root.canFadeByWallpaperFillMode = false
|
2019-03-28 21:25:39 +01:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|