2021-09-10 12:45:15 +02:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtWebEngine
|
2022-05-05 13:02:54 +02:00
|
|
|
import ScreenPlayWidget
|
|
|
|
import ScreenPlay.Enums.InstalledType
|
2022-11-06 14:57:45 +01:00
|
|
|
import ScreenPlayUtil as Util
|
2018-03-08 22:03:05 +01:00
|
|
|
|
2018-10-26 19:28:40 +02:00
|
|
|
Item {
|
2022-11-05 14:38:59 +01:00
|
|
|
id: root
|
|
|
|
// We must set a default size not not
|
|
|
|
// trigger render errors.
|
|
|
|
width: 200
|
|
|
|
height: 100
|
|
|
|
state: "out"
|
|
|
|
opacity: 0
|
2018-10-26 19:28:40 +02:00
|
|
|
|
2020-01-10 15:26:25 +01:00
|
|
|
Connections {
|
2022-11-05 14:38:59 +01:00
|
|
|
target: Widget
|
2020-03-25 21:29:01 +01:00
|
|
|
function onQmlExit() {
|
2022-01-20 16:37:07 +01:00
|
|
|
if (Qt.platform.os === "windows")
|
2023-02-02 15:25:26 +01:00
|
|
|
Widget.setWindowBlur(0);
|
|
|
|
loader.source = "";
|
|
|
|
animFadeOut.start();
|
2020-01-10 15:26:53 +01:00
|
|
|
}
|
|
|
|
|
2020-07-18 20:48:24 +02:00
|
|
|
function onQmlSceneValueReceived(key, value) {
|
2023-02-02 15:25:26 +01:00
|
|
|
var obj2 = 'import QtQuick; Item {Component.onCompleted: loader.item.' + key + ' = ' + value + '; }';
|
|
|
|
var newObject = Qt.createQmlObject(obj2.toString(), root, "err");
|
|
|
|
newObject.destroy(10000);
|
2020-01-10 15:26:25 +01:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-05-14 13:11:12 +02:00
|
|
|
// Replace wallpaper with QML Scene
|
|
|
|
function onReloadQML(oldType) {
|
2023-02-02 15:25:26 +01:00
|
|
|
loader.sourceComponent = undefined;
|
|
|
|
loader.source = "";
|
|
|
|
Widget.clearComponentCache();
|
|
|
|
loader.source = Qt.resolvedUrl(Widget.projectSourceFileAbsolute);
|
2020-01-23 09:48:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 18:06:24 +02:00
|
|
|
OpacityAnimator {
|
|
|
|
id: animFadeOut
|
|
|
|
from: 1
|
|
|
|
to: 0
|
2022-11-05 14:38:59 +01:00
|
|
|
target: root
|
2019-06-13 18:06:24 +02:00
|
|
|
duration: 800
|
|
|
|
easing.type: Easing.InOutQuad
|
2020-01-10 15:26:25 +01:00
|
|
|
onFinished: Widget.destroyThis()
|
2019-06-13 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
2018-10-26 19:28:40 +02:00
|
|
|
Image {
|
2022-11-05 14:38:59 +01:00
|
|
|
id: bgNoise
|
|
|
|
source: "qrc:/qml/ScreenPlayWidget/assets/image/noisy-texture-3.png"
|
2018-10-26 19:28:40 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
fillMode: Image.Tile
|
2022-11-05 14:38:59 +01:00
|
|
|
opacity: 0
|
2018-10-26 19:28:40 +02:00
|
|
|
}
|
2020-01-10 15:26:25 +01:00
|
|
|
|
2019-03-27 18:38:36 +01:00
|
|
|
Loader {
|
|
|
|
id: loader
|
2022-11-05 14:38:59 +01:00
|
|
|
opacity: 0
|
2019-03-27 18:38:36 +01:00
|
|
|
anchors.fill: parent
|
|
|
|
asynchronous: true
|
2020-01-10 15:26:25 +01:00
|
|
|
Component.onCompleted: {
|
2021-05-14 12:50:22 +02:00
|
|
|
switch (Widget.type) {
|
|
|
|
case InstalledType.QMLWidget:
|
2023-02-02 15:25:26 +01:00
|
|
|
loader.source = Qt.resolvedUrl(Widget.projectSourceFileAbsolute);
|
|
|
|
break;
|
2021-05-14 12:50:22 +02:00
|
|
|
case InstalledType.HTMLWidget:
|
2023-02-02 15:25:26 +01:00
|
|
|
loader.sourceComponent = webViewComponent;
|
|
|
|
break;
|
2020-01-10 15:26:25 +01:00
|
|
|
}
|
2019-03-27 18:38:36 +01:00
|
|
|
}
|
2020-01-26 10:59:52 +01:00
|
|
|
onStatusChanged: {
|
2022-11-05 14:38:59 +01:00
|
|
|
if (loader.status == Loader.Ready && loader.source !== "") {
|
|
|
|
// Resize to loaded widget size
|
|
|
|
// Note: We must use implicit* here to not
|
|
|
|
// break the set values.
|
2023-02-02 15:25:26 +01:00
|
|
|
root.width = loader.item.implicitWidth;
|
|
|
|
root.height = loader.item.implicitHeight;
|
|
|
|
Widget.show();
|
|
|
|
root.state = "in";
|
2020-01-26 10:59:52 +01:00
|
|
|
}
|
2020-01-10 15:26:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: webViewComponent
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-01-10 15:26:25 +01:00
|
|
|
WebEngineView {
|
|
|
|
id: webView
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-01-10 15:26:25 +01:00
|
|
|
backgroundColor: "transparent"
|
|
|
|
anchors.fill: parent
|
|
|
|
onJavaScriptConsoleMessage: print(lineNumber, message)
|
|
|
|
Component.onCompleted: {
|
2023-02-02 15:25:26 +01:00
|
|
|
webView.url = Qt.resolvedUrl(Widget.sourcePath);
|
2019-03-27 18:38:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-26 19:28:40 +02:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-01-10 20:54:27 +01:00
|
|
|
property var clickPos
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2018-10-26 19:28:40 +02:00
|
|
|
anchors.fill: parent
|
2019-06-13 18:06:24 +02:00
|
|
|
hoverEnabled: true
|
2022-11-06 14:57:45 +01:00
|
|
|
onEntered: imgClose.state = "areaHover"
|
|
|
|
onExited: {
|
|
|
|
if (mouseAreaClose.containsMouse)
|
2023-02-02 15:25:26 +01:00
|
|
|
return;
|
|
|
|
imgClose.state = "";
|
2022-11-06 14:57:45 +01:00
|
|
|
}
|
|
|
|
|
2022-01-20 16:37:07 +01:00
|
|
|
onPressed: function (mouse) {
|
2020-01-10 20:54:27 +01:00
|
|
|
clickPos = {
|
|
|
|
"x": mouse.x,
|
|
|
|
"y": mouse.y
|
2023-02-02 15:25:26 +01:00
|
|
|
};
|
2018-10-26 19:28:40 +02:00
|
|
|
}
|
|
|
|
onPositionChanged: {
|
2021-05-16 19:37:55 +02:00
|
|
|
if (mouseArea.pressed)
|
2023-02-02 15:25:26 +01:00
|
|
|
Widget.setPos(Widget.cursorPos().x - clickPos.x, Widget.cursorPos().y - clickPos.y);
|
2018-11-24 14:28:02 +01:00
|
|
|
}
|
2018-03-21 18:56:58 +01:00
|
|
|
}
|
|
|
|
|
2019-06-13 18:06:24 +02:00
|
|
|
MouseArea {
|
|
|
|
id: mouseAreaClose
|
2022-11-06 14:57:45 +01:00
|
|
|
width: 16
|
2019-06-13 18:06:24 +02:00
|
|
|
height: width
|
2021-05-16 19:37:55 +02:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
2022-11-06 14:57:45 +01:00
|
|
|
onEntered: imgClose.state = "iconHover"
|
|
|
|
onExited: imgClose.state = ""
|
2021-05-16 19:37:55 +02:00
|
|
|
onClicked: {
|
2022-01-20 16:37:07 +01:00
|
|
|
if (Qt.platform.os === "windows")
|
2023-02-02 15:25:26 +01:00
|
|
|
Widget.setWindowBlur(0);
|
|
|
|
animFadeOut.start();
|
2021-05-16 19:37:55 +02:00
|
|
|
}
|
|
|
|
|
2019-06-13 18:06:24 +02:00
|
|
|
anchors {
|
2022-11-06 14:57:45 +01:00
|
|
|
margins: 5
|
2019-06-13 18:06:24 +02:00
|
|
|
top: parent.top
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
|
2022-11-06 14:57:45 +01:00
|
|
|
ColorImage {
|
2020-01-10 15:26:25 +01:00
|
|
|
id: imgClose
|
2022-11-05 14:38:59 +01:00
|
|
|
source: "qrc:/qml/ScreenPlayWidget/assets/icons/baseline-close-24px.svg"
|
2019-06-13 18:06:24 +02:00
|
|
|
anchors.centerIn: parent
|
2022-11-06 14:57:45 +01:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
sourceSize: Qt.size(width, height)
|
|
|
|
opacity: 0
|
|
|
|
color: "white"
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "areaHover"
|
|
|
|
PropertyChanges {
|
|
|
|
target: imgClose
|
|
|
|
opacity: .5
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "iconHover"
|
|
|
|
PropertyChanges {
|
|
|
|
target: imgClose
|
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
PropertyAnimation {
|
|
|
|
duration: 250
|
|
|
|
target: imgClose
|
|
|
|
property: "opacity"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2019-06-13 18:06:24 +02:00
|
|
|
}
|
|
|
|
}
|
2020-01-10 15:26:25 +01:00
|
|
|
|
2022-11-05 14:38:59 +01:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "in"
|
|
|
|
PropertyChanges {
|
|
|
|
target: root
|
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: bgNoise
|
|
|
|
opacity: 0.05
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: loader
|
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
from: "out"
|
|
|
|
to: "in"
|
|
|
|
|
|
|
|
PropertyAnimation {
|
|
|
|
targets: [root, bgNoise, loader]
|
|
|
|
duration: 250
|
|
|
|
property: "opacity"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2018-03-08 22:03:05 +01:00
|
|
|
}
|