2019-03-28 21:25:39 +01:00
|
|
|
import QtQuick 2.12
|
2019-03-30 12:56:34 +01:00
|
|
|
import QtWebEngine 1.8
|
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
|
|
|
|
|
|
|
Component.onCompleted: {
|
2019-03-30 12:56:34 +01:00
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
WebEngine.settings.allowRunningInsecureContent = true
|
|
|
|
WebEngine.settings.accelerated2dCanvasEnabled = true
|
|
|
|
WebEngine.settings.javascriptCanOpenWindows = false
|
|
|
|
WebEngine.settings.printElementBackgrounds = false
|
|
|
|
WebEngine.settings.showScrollBars = false
|
|
|
|
WebEngine.settings.playbackRequiresUserGesture = false
|
|
|
|
|
|
|
|
switch (window.type) {
|
|
|
|
case Wallpaper.WallpaperType.Video:
|
|
|
|
webView.url = Qt.resolvedUrl(window.getApplicationPath(
|
|
|
|
) + "/index.html")
|
2019-03-30 12:56:34 +01:00
|
|
|
webView.enabled = true
|
2019-03-28 21:25:39 +01:00
|
|
|
|
|
|
|
break
|
|
|
|
case Wallpaper.WallpaperType.Html:
|
|
|
|
webView.enabled = true
|
|
|
|
webView.url = Qt.resolvedUrl(window.fullContentPath)
|
|
|
|
break
|
|
|
|
case Wallpaper.WallpaperType.ThreeJSScene:
|
|
|
|
webView.enabled = true
|
|
|
|
break
|
|
|
|
case Wallpaper.WallpaperType.Qml:
|
2019-06-12 16:54:05 +02:00
|
|
|
loader.enabled = true
|
2019-03-28 21:25:39 +01:00
|
|
|
loader.source = Qt.resolvedUrl(window.fullContentPath)
|
2019-06-12 16:54:05 +02:00
|
|
|
fadeIn()
|
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-03-28 21:25:39 +01:00
|
|
|
animFadeIn.start()
|
|
|
|
} else {
|
|
|
|
imgCover.opacity = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-12 12:12:31 +02:00
|
|
|
Timer {
|
2019-07-26 17:28:30 +02:00
|
|
|
id: fadeInTimer
|
2019-06-12 12:12:31 +02:00
|
|
|
interval: 50
|
|
|
|
onTriggered: fadeIn()
|
|
|
|
}
|
|
|
|
|
|
|
|
OpacityAnimator {
|
|
|
|
id: animFadeIn
|
|
|
|
target: imgCover
|
|
|
|
from: 1
|
|
|
|
to: 0
|
2019-06-12 12:23:51 +02:00
|
|
|
duration: 800
|
2019-06-12 12:12:31 +02:00
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
|
2019-06-12 12:23:51 +02:00
|
|
|
OpacityAnimator {
|
|
|
|
id: animFadeOut
|
|
|
|
target: imgCover
|
|
|
|
from: 0
|
|
|
|
to: 1
|
|
|
|
duration: 800
|
|
|
|
easing.type: Easing.InOutQuad
|
2019-07-26 17:28:30 +02:00
|
|
|
onFinished: window.terminate()
|
2019-06-12 12:23:51 +02:00
|
|
|
}
|
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
WebEngineView {
|
|
|
|
id: webView
|
2019-06-12 16:54:05 +02:00
|
|
|
enabled: false
|
2019-03-28 21:25:39 +01:00
|
|
|
anchors.fill: parent
|
|
|
|
onLoadProgressChanged: {
|
|
|
|
if (loadProgress === 100) {
|
|
|
|
|
|
|
|
var src = ""
|
|
|
|
src += "var videoPlayer = document.getElementById('videoPlayer');"
|
|
|
|
src += "var videoSource = document.getElementById('videoSource');"
|
2019-03-30 12:56:34 +01:00
|
|
|
src += "videoSource.src = '" + window.fullContentPath + "';"
|
2019-03-28 21:25:39 +01:00
|
|
|
src += "videoPlayer.load();"
|
|
|
|
src += "videoPlayer.volume = " + window.volume + ";"
|
2019-09-01 12:00:04 +02:00
|
|
|
src += "videoPlayer.setAttribute('style', 'object-fit :" + window.fillMode + ";');"
|
2019-03-28 21:25:39 +01:00
|
|
|
src += "videoPlayer.play();"
|
|
|
|
|
2019-03-30 12:56:34 +01:00
|
|
|
webView.runJavaScript(src, function (result) {
|
2019-06-12 12:12:31 +02:00
|
|
|
fadeInTimer.start()
|
2019-03-28 21:25:39 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-03-30 12:56:34 +01:00
|
|
|
|
|
|
|
onJavaScriptConsoleMessage: print(lineNumber, message)
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
|
|
|
|
2019-06-12 16:54:05 +02:00
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
anchors.fill: parent
|
|
|
|
enabled: false
|
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgCover
|
2019-07-26 17:28:30 +02:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
topMargin: {
|
|
|
|
if(desktopProperties.windowsVersion >= 1903){
|
2019-08-05 19:22:10 +02:00
|
|
|
|
|
|
|
var ratio = root.width / root.height
|
|
|
|
ratio = Math.round(ratio * 100) / 100
|
|
|
|
|
|
|
|
// 4:3
|
|
|
|
if (ratio === 1,3) {
|
|
|
|
|
|
|
|
}
|
|
|
|
// 16:10
|
|
|
|
if (ratio === 1,6) {
|
|
|
|
|
|
|
|
}
|
|
|
|
// 16:9
|
|
|
|
if (ratio === 1,77) {
|
|
|
|
return -(root.height / 9)
|
|
|
|
}
|
|
|
|
// 21:9
|
|
|
|
if (ratio === 2,37) {
|
|
|
|
return -((root.height / 9) / 3)
|
|
|
|
}
|
|
|
|
// 32:9
|
|
|
|
if (ratio === 3,55) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-26 17:28:30 +02:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSize.width: root.width
|
2019-03-28 21:25:39 +01:00
|
|
|
source: Qt.resolvedUrl("file:///" + desktopProperties.wallpaperPath)
|
2019-07-26 17:28:30 +02:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: window
|
|
|
|
|
2019-08-02 13:11:31 +02:00
|
|
|
onMutedChanged:{
|
|
|
|
if(muted){
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;")
|
|
|
|
} else {
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + window.volume + ";")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
onQmlExit: {
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;")
|
2019-08-11 19:48:07 +02:00
|
|
|
|
|
|
|
if (canFadeByWallpaperFillMode && window.canFade) {
|
|
|
|
animFadeOut.start()
|
|
|
|
} else {
|
|
|
|
window.terminate()
|
|
|
|
}
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onQmlSceneValueReceived: {
|
2019-06-09 12:21:03 +02:00
|
|
|
var obj2 = 'import QtQuick 2.0; Item {Component.onCompleted: loader.item.'
|
2019-03-28 21:25:39 +01:00
|
|
|
+ key + ' = ' + value + '; }'
|
2019-06-09 12:21:03 +02:00
|
|
|
print(key, value)
|
2019-03-28 21:25:39 +01:00
|
|
|
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
|
|
|
|
newObject.destroy(10000)
|
|
|
|
}
|
|
|
|
|
2019-09-01 12:00:04 +02:00
|
|
|
|
|
|
|
onFillModeChanged:{
|
|
|
|
if (webView.loadProgress === 100) {
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.setAttribute('style', 'object-fit :" + window.fillMode + ";');")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
onLoopsChanged: {
|
|
|
|
if (webView.loadProgress === 100) {
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.loop = " + loops + ";")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onVolumeChanged: {
|
|
|
|
if (webView.loadProgress === 100) {
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + volume + ";")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-10 16:38:44 +02:00
|
|
|
onCurrentTimeChanged: {
|
2019-03-28 21:25:39 +01:00
|
|
|
if (webView.loadProgress === 100) {
|
|
|
|
webView.runJavaScript(
|
2019-08-10 16:38:44 +02:00
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.currentTime = " + currentTime + " * videoPlayer.duration;")
|
2019-03-28 21:25:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-01 12:00:04 +02:00
|
|
|
onPlaybackRateChanged: {
|
|
|
|
if (webView.loadProgress === 100) {
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.playbackRate = " + playbackRate + ";")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 21:25:39 +01:00
|
|
|
onIsPlayingChanged: {
|
|
|
|
if (webView.loadProgress === 100) {
|
2019-08-02 13:11:31 +02:00
|
|
|
if (isPlaying) {
|
2019-03-28 21:25:39 +01:00
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.play();")
|
|
|
|
} else {
|
|
|
|
webView.runJavaScript(
|
|
|
|
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.pause();")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|