2019-03-28 21:25:39 +01:00
|
|
|
import QtQuick 2.12
|
2019-06-10 16:27:17 +02:00
|
|
|
import ScreenPlay.Wallpaper 1.0
|
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: {
|
2019-03-30 12:56:34 +01:00
|
|
|
if (desktopProperties.color === null) {
|
2019-03-28 21:25:39 +01:00
|
|
|
return "black"
|
|
|
|
} else {
|
|
|
|
return desktopProperties.color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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: {
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-23 17:22:24 +01:00
|
|
|
Connections {
|
|
|
|
target: window
|
|
|
|
|
2020-03-25 21:29:01 +01:00
|
|
|
function onQmlExit() {
|
2019-11-23 17:22:24 +01:00
|
|
|
if (canFadeByWallpaperFillMode && window.canFade) {
|
|
|
|
imgCover.state = "outExit"
|
|
|
|
} else {
|
|
|
|
window.terminate()
|
|
|
|
}
|
|
|
|
}
|
2019-03-30 12:56:34 +01:00
|
|
|
|
2020-03-25 21:29:01 +01: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-03-25 21:29:01 +01:00
|
|
|
function onReloadQML(){
|
2020-03-09 18:06:50 +01:00
|
|
|
loader.sourceComponent = undefined
|
|
|
|
loader.source = ""
|
|
|
|
window.clearComponentCache()
|
|
|
|
root.init()
|
|
|
|
}
|
2019-11-23 17:22:24 +01:00
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
|
2020-03-09 18:06:50 +01:00
|
|
|
function init(){
|
2019-03-28 21:25:39 +01:00
|
|
|
switch (window.type) {
|
|
|
|
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:
|
2019-11-23 17:22:24 +01:00
|
|
|
loader.webViewUrl = Qt.resolvedUrl(window.fullContentPath)
|
2019-11-23 18:20:32 +01:00
|
|
|
loader.source = "qrc:/WebView.qml"
|
2019-03-28 21:25:39 +01:00
|
|
|
break
|
|
|
|
case Wallpaper.WallpaperType.Qml:
|
|
|
|
loader.source = Qt.resolvedUrl(window.fullContentPath)
|
2019-11-23 17:22:24 +01:00
|
|
|
imgCover.state = "out"
|
2019-03-28 21:25:39 +01:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fadeIn() {
|
|
|
|
window.setVisible(true)
|
2019-08-11 19:48:07 +02:00
|
|
|
if (canFadeByWallpaperFillMode && window.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) {
|
2019-11-23 18:20:32 +01:00
|
|
|
if (window.type === Wallpaper.WallpaperType.Html
|
|
|
|
|| window.type === Wallpaper.WallpaperType.ThreeJSScene) {
|
2019-11-23 17:22:24 +01:00
|
|
|
loader.item.url = loader.webViewUrl
|
2019-11-23 18:20:32 +01: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
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
2019-11-23 17:22:24 +01:00
|
|
|
state: "in"
|
2019-07-26 17:28:30 +02:00
|
|
|
|
2019-10-21 18:14:11 +02:00
|
|
|
sourceSize.width: window.width
|
|
|
|
sourceSize.height: window.height
|
2019-03-28 21:25:39 +01:00
|
|
|
source: Qt.resolvedUrl("file:///" + desktopProperties.wallpaperPath)
|
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 {
|
|
|
|
script: window.terminate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
Component.onCompleted: {
|
2019-07-26 17:28:30 +02:00
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
switch (desktopProperties.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:
|
2019-08-11 19:48:07 +02:00
|
|
|
canFadeByWallpaperFillMode = false
|
2019-03-28 21:25:39 +01:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|