|
|
@@ -7,17 +7,20 @@ import "./simplify.js" as Simplify
|
|
|
ApplicationWindow {
|
|
|
id: aw
|
|
|
visible: true
|
|
|
- width: 1280
|
|
|
- height: 720
|
|
|
+ width: 960
|
|
|
+ height: 540
|
|
|
color: "#fffffe"
|
|
|
- property alias label1: label1
|
|
|
+ property alias text1: text1
|
|
|
+ property alias text2: text2
|
|
|
+
|
|
|
+ property alias column2: column2
|
|
|
|
|
|
WebSocket {
|
|
|
property int total_slides: 5
|
|
|
+
|
|
|
id: socket
|
|
|
url: "wss://wscasa.especificosba.com.ar"
|
|
|
onTextMessageReceived: {
|
|
|
- // console.log("\nReceived message: " + message)
|
|
|
var obj = JSON.parse(message)
|
|
|
switch (obj.type) {
|
|
|
case "diapo":
|
|
|
@@ -25,6 +28,18 @@ ApplicationWindow {
|
|
|
item1.curPDF = obj.PDF
|
|
|
item1.curImage = obj.slide //automagically change_image
|
|
|
total_slides = obj.total_slides
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "preg":
|
|
|
+ item1.addPreg(obj.text);
|
|
|
+ break;
|
|
|
+ case "deletepreg":
|
|
|
+ item1.pregs = [];
|
|
|
+ break;
|
|
|
+ case "draw":
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ console.log(JSON.stringify(obj));
|
|
|
}
|
|
|
}
|
|
|
function send_obj(obj) {
|
|
|
@@ -70,12 +85,13 @@ ApplicationWindow {
|
|
|
onStatusChanged: {
|
|
|
//FIXME implement
|
|
|
if (socket.status == WebSocket.Error) {
|
|
|
+ text2.text=qsTr("ERROR En la conexion");
|
|
|
console.log("Error: " + socket.errorString)
|
|
|
} else if (socket.status == WebSocket.Open) {
|
|
|
-
|
|
|
- /*?*/
|
|
|
+ text2.text=qsTr("Conectado");
|
|
|
} else if (socket.status == WebSocket.Closed) {
|
|
|
- console.log("\nSocket closed")
|
|
|
+ text2.text=qsTr("Desconectado.. RC..");
|
|
|
+ socket.active=true; //Reconnect
|
|
|
}
|
|
|
}
|
|
|
active: true
|
|
|
@@ -91,20 +107,33 @@ ApplicationWindow {
|
|
|
property alias button3: button3
|
|
|
property alias button1: button1
|
|
|
property int curImage: 1
|
|
|
+ property variant pregs: []
|
|
|
+
|
|
|
property string curPDF: "EBA"
|
|
|
anchors.fill: parent
|
|
|
|
|
|
onCurPDFChanged: {
|
|
|
canvas.change_image(curPDF, curImage)
|
|
|
+ text1.text=qsTr("%1/%2 (%3 preg)").arg(curImage).arg(socket.total_slides).arg(pregs.length);
|
|
|
+
|
|
|
+ }
|
|
|
+ onPregsChanged: {
|
|
|
+ text1.text=qsTr("%1/%2 (%3 preg)").arg(curImage).arg(socket.total_slides).arg(pregs.length);
|
|
|
}
|
|
|
|
|
|
onCurImageChanged: {
|
|
|
canvas.change_image(curPDF, curImage)
|
|
|
- label1.text=curImage+"/"+socket.total_slides
|
|
|
+ text1.text=qsTr("%1/%2 (%3 preg)").arg(curImage).arg(socket.total_slides).arg(pregs.length);
|
|
|
}
|
|
|
+ function addPreg(p){
|
|
|
+ if(pregs.indexOf(p) !== -1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- Grid {
|
|
|
+ pregs.push(p);
|
|
|
+ }
|
|
|
|
|
|
+ Grid {
|
|
|
id: grid1
|
|
|
width: parent.width
|
|
|
height: parent.height
|
|
|
@@ -162,8 +191,8 @@ ApplicationWindow {
|
|
|
var ar = points_array[points_array.length - 1].points.map(
|
|
|
function (el) {
|
|
|
return {
|
|
|
- x: el.x * 800 / canvas.width,
|
|
|
- y: el.y * 600 / canvas.height
|
|
|
+ x: Math.round(el.x * 800 / canvas.width),
|
|
|
+ y: Math.round(el.y * 600 / canvas.height)
|
|
|
}
|
|
|
})
|
|
|
while (ar.length > 30) {
|
|
|
@@ -179,11 +208,12 @@ ApplicationWindow {
|
|
|
}
|
|
|
|
|
|
function add_point(p) {
|
|
|
- points_array[points_array.length - 1].points.push(p);
|
|
|
- if (points_array[points_array.length - 1].length/ 3 > 40){ //FIXME
|
|
|
+ var pts = points_array[points_array.length - 1].points;
|
|
|
+ pts.push(p);
|
|
|
+ if (pts.length>60){ //FIXME
|
|
|
finish_path()
|
|
|
start_path()
|
|
|
- points_array[points_array.length - 1].points.push(p)
|
|
|
+ pts.push(p)
|
|
|
} else {
|
|
|
requestPaint()
|
|
|
}
|
|
|
@@ -205,6 +235,10 @@ ApplicationWindow {
|
|
|
var i = 0, j = 0
|
|
|
for (j = 0; j < points_array.length; j++) {
|
|
|
var points = points_array[j].points;
|
|
|
+
|
|
|
+
|
|
|
+ if (points.length===0)
|
|
|
+ continue;
|
|
|
ctx.strokeStyle= points_array[j].color;
|
|
|
ctx.beginPath()
|
|
|
ctx.moveTo(points[0].x, points[0].y)
|
|
|
@@ -225,12 +259,12 @@ ApplicationWindow {
|
|
|
width: canvas.width
|
|
|
height: canvas.height
|
|
|
onPressed: {
|
|
|
- if (!socket.active)
|
|
|
+ if (socket.status !== WebSocket.Open)
|
|
|
return
|
|
|
canvas.start_path()
|
|
|
}
|
|
|
onPositionChanged: {
|
|
|
- if (!socket.active)
|
|
|
+ if (socket.status !== WebSocket.Open)
|
|
|
return
|
|
|
|
|
|
canvas.add_point({
|
|
|
@@ -239,7 +273,7 @@ ApplicationWindow {
|
|
|
})
|
|
|
}
|
|
|
onReleased: {
|
|
|
- if (!socket.active)
|
|
|
+ if (socket.status !== WebSocket.Open)
|
|
|
return
|
|
|
canvas.finish_path()
|
|
|
}
|
|
|
@@ -253,13 +287,13 @@ ApplicationWindow {
|
|
|
|
|
|
Column {
|
|
|
width: parent.width
|
|
|
- height: parent.height/2-20
|
|
|
+ height: parent.height/2-60
|
|
|
Button {
|
|
|
width: parent.width
|
|
|
height: 70
|
|
|
id: button1
|
|
|
text: qsTr("Anterior")
|
|
|
- enabled: socket.active
|
|
|
+ enabled: socket.status == WebSocket.Open && (item1.curImage>1)
|
|
|
onClicked: socket.prev_diapo()
|
|
|
}
|
|
|
|
|
|
@@ -268,7 +302,7 @@ ApplicationWindow {
|
|
|
width: parent.width
|
|
|
id: button2
|
|
|
text: qsTr("Siguiente")
|
|
|
- enabled: socket.active && (item1.curImage < socket.total_slides)
|
|
|
+ enabled: socket.status == WebSocket.Open && (item1.curImage < socket.total_slides)
|
|
|
onClicked: socket.next_diapo()
|
|
|
}
|
|
|
|
|
|
@@ -277,21 +311,16 @@ ApplicationWindow {
|
|
|
width: parent.width
|
|
|
id: button3
|
|
|
text: qsTr("Limpiar")
|
|
|
- enabled: socket.active && (item1.curImage>1)
|
|
|
+ enabled: socket.status == WebSocket.Open
|
|
|
onClicked: socket.clear_path()
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- Label {
|
|
|
- id: label1
|
|
|
- width: parent.width
|
|
|
- height: 30
|
|
|
- }
|
|
|
|
|
|
Column {
|
|
|
id: column1
|
|
|
width: parent.width
|
|
|
- height: parent.height/2-20
|
|
|
+ height: parent.height/2-60
|
|
|
|
|
|
Button {
|
|
|
width: parent.width
|
|
|
@@ -339,6 +368,21 @@ ApplicationWindow {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ Column {
|
|
|
+ id: column2
|
|
|
+ width: parent.width
|
|
|
+ height: 40
|
|
|
+ Text {
|
|
|
+ id: text2
|
|
|
+ text: qsTr("WS")
|
|
|
+ }
|
|
|
+ Text {
|
|
|
+ id: text1
|
|
|
+ text: qsTr("test123")
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|