2019-02-15 12:07:29 +01:00
|
|
|
import QtQuick 2.12
|
2018-04-18 18:39:25 +02:00
|
|
|
import QtQuick.Controls 2.3
|
2020-01-10 15:26:25 +01:00
|
|
|
import QtWebEngine 1.8
|
|
|
|
import ScreenPlayWidget 1.0
|
2018-03-08 22:03:05 +01:00
|
|
|
|
2018-10-26 19:28:40 +02:00
|
|
|
Item {
|
2018-03-08 22:03:05 +01:00
|
|
|
id: mainWindow
|
2018-10-26 19:28:40 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2020-01-10 15:26:25 +01:00
|
|
|
Connections {
|
|
|
|
target: Widget
|
|
|
|
|
2020-03-25 21:29:01 +01:00
|
|
|
function onQmlExit() {
|
2020-01-10 15:26:53 +01:00
|
|
|
Widget.setWindowBlur(0)
|
|
|
|
animFadeOut.start()
|
|
|
|
}
|
|
|
|
|
2020-03-25 21:29:01 +01:00
|
|
|
function onQmlSceneValueReceived(key,value) {
|
2020-01-10 15:26:25 +01:00
|
|
|
var obj2 = 'import QtQuick 2.14; Item {Component.onCompleted: loader.item.'
|
|
|
|
+ key + ' = ' + value + '; }'
|
|
|
|
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
|
|
|
|
newObject.destroy(10000)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-23 09:48:48 +01:00
|
|
|
Action {
|
|
|
|
shortcut: "F5"
|
2020-01-26 10:59:52 +01:00
|
|
|
onTriggered: {
|
2020-01-23 09:48:48 +01:00
|
|
|
loader.sourceComponent = undefined
|
|
|
|
loader.source = ""
|
|
|
|
Widget.clearComponentCache()
|
|
|
|
if (Widget.type === "qmlWidget") {
|
|
|
|
loader.source = Qt.resolvedUrl(Widget.sourcePath)
|
|
|
|
} else if (Widget.type === "htmlWidget") {
|
|
|
|
loader.sourceComponent = webViewComponent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 18:06:24 +02:00
|
|
|
OpacityAnimator {
|
|
|
|
id: animFadeOut
|
|
|
|
from: 1
|
|
|
|
to: 0
|
|
|
|
target: parent
|
|
|
|
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
|
|
|
Rectangle {
|
2018-11-24 14:28:02 +01:00
|
|
|
id: bgColor
|
2018-10-26 19:28:40 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
color: "white"
|
|
|
|
opacity: .15
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: bg
|
|
|
|
source: "qrc:/assets/image/noisy-texture-3.png"
|
|
|
|
anchors.fill: parent
|
|
|
|
opacity: .05
|
|
|
|
fillMode: Image.Tile
|
|
|
|
}
|
2020-01-10 15:26:25 +01:00
|
|
|
|
2019-03-27 18:38:36 +01:00
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
anchors.fill: parent
|
|
|
|
asynchronous: true
|
2020-01-10 15:26:25 +01:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (Widget.type === "qmlWidget") {
|
|
|
|
loader.source = Qt.resolvedUrl(Widget.sourcePath)
|
|
|
|
} else if (Widget.type === "htmlWidget") {
|
|
|
|
loader.sourceComponent = webViewComponent
|
|
|
|
}
|
2019-03-27 18:38:36 +01:00
|
|
|
}
|
2020-01-26 10:59:52 +01:00
|
|
|
onStatusChanged: {
|
|
|
|
if (loader.status == Loader.Ready) {
|
|
|
|
if(loader.item.widgetBackground !== undefined){
|
|
|
|
bgColor.color = loader.item.widgetBackground
|
|
|
|
}
|
|
|
|
if(loader.item.widgetBackgroundOpacity !== undefined){
|
|
|
|
bgColor.opacity = loader.item.widgetBackgroundOpacity
|
|
|
|
}
|
|
|
|
if(loader.item.widgetWidth !== undefined &&
|
|
|
|
loader.item.widgetHeight !== undefined){
|
|
|
|
Widget.setWidgetSize(loader.item.widgetWidth,
|
|
|
|
loader.item.widgetHeight)
|
|
|
|
}
|
2019-03-27 18:38:36 +01:00
|
|
|
|
2020-01-26 10:59:52 +01:00
|
|
|
}
|
2020-01-10 15:26:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: webViewComponent
|
|
|
|
WebEngineView {
|
|
|
|
id: webView
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
anchors.fill: parent
|
|
|
|
onJavaScriptConsoleMessage: print(lineNumber, message)
|
|
|
|
Component.onCompleted: {
|
|
|
|
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
|
2020-01-10 20:54:27 +01:00
|
|
|
property var clickPos
|
2018-10-26 19:28:40 +02:00
|
|
|
anchors.fill: parent
|
2019-06-13 18:06:24 +02:00
|
|
|
hoverEnabled: true
|
2018-10-26 19:28:40 +02:00
|
|
|
onPressed: {
|
2020-01-10 20:54:27 +01:00
|
|
|
clickPos = {
|
|
|
|
"x": mouse.x,
|
|
|
|
"y": mouse.y
|
|
|
|
}
|
2018-10-26 19:28:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onPositionChanged: {
|
2020-01-10 20:54:27 +01:00
|
|
|
if (mouseArea.pressed) {
|
|
|
|
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
|
|
|
|
width: 20
|
|
|
|
height: width
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2020-01-10 15:26:25 +01:00
|
|
|
Widget.setWindowBlur(0)
|
2019-06-13 18:06:24 +02:00
|
|
|
animFadeOut.start()
|
|
|
|
}
|
2020-01-10 15:26:25 +01:00
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: imgClose.opacity = 1
|
|
|
|
onExited: imgClose.opacity = .15
|
2019-06-13 18:06:24 +02:00
|
|
|
|
|
|
|
Image {
|
2020-01-10 15:26:25 +01:00
|
|
|
id: imgClose
|
2019-06-13 18:06:24 +02:00
|
|
|
source: "qrc:/assets/icons/baseline-close-24px.svg"
|
|
|
|
anchors.centerIn: parent
|
2020-01-10 15:26:25 +01:00
|
|
|
opacity: .15
|
|
|
|
OpacityAnimator {
|
|
|
|
target: parent
|
|
|
|
duration: 300
|
|
|
|
}
|
2019-06-13 18:06:24 +02:00
|
|
|
}
|
|
|
|
}
|
2020-01-10 15:26:25 +01:00
|
|
|
|
2019-06-13 18:06:24 +02:00
|
|
|
MouseArea {
|
|
|
|
id: mouseAreaResize
|
|
|
|
width: 20
|
|
|
|
height: width
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
cursorShape: Qt.SizeFDiagCursor
|
|
|
|
property point clickPosition
|
2018-03-23 14:49:52 +01:00
|
|
|
|
2019-06-13 18:06:24 +02:00
|
|
|
onPressed: {
|
|
|
|
clickPosition = Qt.point(mouseX, mouseY)
|
|
|
|
}
|
|
|
|
|
|
|
|
onPositionChanged: {
|
|
|
|
if (mouseAreaResize.pressed) {
|
2020-01-10 15:26:25 +01:00
|
|
|
Widget.setWidgetSize(clickPosition.x + mouseX,
|
2019-06-13 18:06:24 +02:00
|
|
|
clickPosition.y + mouseY)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-08 22:03:05 +01:00
|
|
|
}
|