2017-11-02 17:20:42 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import FlightGear 1.0 as FG
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
property bool showDecorations: true
|
2018-06-24 10:34:28 +00:00
|
|
|
property alias canvas: paintedDisplay.canvas
|
2017-11-04 10:47:14 +00:00
|
|
|
property bool showUi: true
|
2017-11-02 17:20:42 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2017-11-03 13:56:43 +00:00
|
|
|
if (canvas) {
|
|
|
|
width = canvas.size.width
|
|
|
|
height = canvas.size.height
|
2017-11-03 15:31:57 +00:00
|
|
|
x = canvas.origin.x
|
|
|
|
y = canvas.origin.y
|
2017-11-03 13:56:43 +00:00
|
|
|
}
|
2017-11-02 17:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function saveGeometry()
|
|
|
|
{
|
2017-11-03 15:31:57 +00:00
|
|
|
canvas.origin = Qt.point(x, y )
|
|
|
|
canvas.size = Qt.size(root.width, root.height);
|
2017-11-02 17:20:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-16 08:29:24 +00:00
|
|
|
Item {
|
|
|
|
id: clipShell
|
2017-11-02 17:20:42 +00:00
|
|
|
anchors.fill: parent
|
2017-11-16 08:29:24 +00:00
|
|
|
clip: true
|
|
|
|
|
2018-06-24 10:34:28 +00:00
|
|
|
// FG.CanvasDisplay {
|
|
|
|
// id: canvasDisplay
|
|
|
|
// anchors.fill: parent
|
|
|
|
|
|
|
|
// onCanvasChanged: {
|
|
|
|
// if (canvas) {
|
|
|
|
// root.width = canvas.size.width
|
|
|
|
// root.height = canvas.size.height
|
|
|
|
// root.x = canvas.origin.x
|
|
|
|
// root.y = canvas.origin.y
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
FG.PaintedCanvasDisplay {
|
|
|
|
id: paintedDisplay
|
2017-11-16 08:29:24 +00:00
|
|
|
anchors.fill: parent
|
2018-06-24 10:34:28 +00:00
|
|
|
// canvas: canvasDisplay.canvas
|
2017-11-02 17:20:42 +00:00
|
|
|
|
2017-11-16 08:29:24 +00:00
|
|
|
onCanvasChanged: {
|
|
|
|
if (canvas) {
|
|
|
|
root.width = canvas.size.width
|
|
|
|
root.height = canvas.size.height
|
|
|
|
root.x = canvas.origin.x
|
|
|
|
root.y = canvas.origin.y
|
|
|
|
}
|
2017-11-03 13:56:43 +00:00
|
|
|
}
|
2017-11-02 17:20:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
border.width: 1
|
|
|
|
border.color: "orange"
|
|
|
|
color: "transparent"
|
|
|
|
anchors.centerIn: parent
|
2017-11-03 13:56:43 +00:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2017-11-04 10:47:14 +00:00
|
|
|
visible: showUi
|
2017-11-02 17:20:42 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
drag.target: root
|
|
|
|
|
|
|
|
onReleased: {
|
|
|
|
root.saveGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
color: "orange"
|
|
|
|
opacity: 0.5
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
// resizing
|
|
|
|
|
|
|
|
onPositionChanged: {
|
|
|
|
var rootPos = mapToItem(root, mouse.x, mouse.y);
|
2017-11-03 15:31:57 +00:00
|
|
|
// var rootDiff = Qt.point(rootPos.x - root.x,
|
|
|
|
// rootPos.y - root.y);
|
2017-11-02 17:20:42 +00:00
|
|
|
|
2017-11-03 15:31:57 +00:00
|
|
|
root.width = rootPos.x;
|
|
|
|
root.height = rootPos.y;
|
2017-11-02 17:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onReleased: {
|
|
|
|
saveGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
color: "orange"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
text: "Canvas"
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
anchors.fill: parent
|
|
|
|
verticalAlignment: Text.AlignBottom
|
|
|
|
|
|
|
|
function statusAsString(status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case FG.CanvasConnection.NotConnected: return "Not connected";
|
|
|
|
case FG.CanvasConnection.Connecting: return "Connecting";
|
|
|
|
case FG.CanvasConnection.Connected: return "Connected";
|
2017-11-03 15:31:57 +00:00
|
|
|
case FG.CanvasConnection.Closed: return "Closed";
|
2017-11-02 17:20:42 +00:00
|
|
|
case FG.CanvasConnection.Reconnecting: return "Re-connecting";
|
|
|
|
case FG.CanvasConnection.Error: return "Error";
|
2017-11-08 14:24:12 +00:00
|
|
|
case FG.CanvasConnection.Snapshot: return "Snapshot";
|
2017-11-02 17:20:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
text: "WS: " + canvas.webSocketUrl + "\n"
|
|
|
|
+ "Root:" + canvas.rootPath + "\n"
|
|
|
|
+ "Status:" + statusAsString(canvas.status);
|
|
|
|
color: "white"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|