|
|
@@ -28,24 +28,34 @@ ApplicationWindow {
|
|
|
item1.curPDF = obj.PDF
|
|
|
item1.curImage = obj.slide //automagically change_image
|
|
|
total_slides = obj.total_slides
|
|
|
- break;
|
|
|
-
|
|
|
+ break
|
|
|
case "preg":
|
|
|
- item1.addPreg(obj.text);
|
|
|
- break;
|
|
|
+ item1.addPreg(obj.text)
|
|
|
+ break
|
|
|
case "deletepreg":
|
|
|
- item1.pregs = [];
|
|
|
- break;
|
|
|
+ item1.pregs = []
|
|
|
+ break
|
|
|
case "draw":
|
|
|
- break;
|
|
|
+ break
|
|
|
default:
|
|
|
- console.log(JSON.stringify(obj));
|
|
|
+ console.log(JSON.stringify(obj))
|
|
|
}
|
|
|
}
|
|
|
function send_obj(obj) {
|
|
|
sendTextMessage(JSON.stringify(obj))
|
|
|
}
|
|
|
|
|
|
+ function set_preg() {
|
|
|
+ send_obj({
|
|
|
+ type: "initpreg"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function unset_preg() {
|
|
|
+ send_obj({
|
|
|
+ type: "stoppreg"
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
function prev_diapo() {
|
|
|
var curImage = Math.max(item1.curImage - 1, 1)
|
|
|
send_obj({
|
|
|
@@ -85,13 +95,13 @@ ApplicationWindow {
|
|
|
onStatusChanged: {
|
|
|
//FIXME implement
|
|
|
if (socket.status == WebSocket.Error) {
|
|
|
- text2.text=qsTr("ERROR En la conexion");
|
|
|
+ text2.text = qsTr("ERROR En la conexion")
|
|
|
console.log("Error: " + socket.errorString)
|
|
|
} else if (socket.status == WebSocket.Open) {
|
|
|
- text2.text=qsTr("Conectado");
|
|
|
+ text2.text = qsTr("Conectado")
|
|
|
} else if (socket.status == WebSocket.Closed) {
|
|
|
- text2.text=qsTr("Desconectado.. RC..");
|
|
|
- socket.active=true; //Reconnect
|
|
|
+ text2.text = qsTr("Desconectado.. RC..")
|
|
|
+ socket.active = true //Reconnect
|
|
|
}
|
|
|
}
|
|
|
active: true
|
|
|
@@ -114,23 +124,25 @@ ApplicationWindow {
|
|
|
|
|
|
onCurPDFChanged: {
|
|
|
canvas.change_image(curPDF, curImage)
|
|
|
- text1.text=qsTr("%1/%2 (%3 preg)").arg(curImage).arg(socket.total_slides).arg(pregs.length);
|
|
|
-
|
|
|
+ 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);
|
|
|
+ text1.text = qsTr("%1/%2 (%3 preg)").arg(curImage).arg(
|
|
|
+ socket.total_slides).arg(pregs.length)
|
|
|
}
|
|
|
|
|
|
onCurImageChanged: {
|
|
|
canvas.change_image(curPDF, curImage)
|
|
|
- text1.text=qsTr("%1/%2 (%3 preg)").arg(curImage).arg(socket.total_slides).arg(pregs.length);
|
|
|
+ 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;
|
|
|
+ function addPreg(p) {
|
|
|
+ if (pregs.indexOf(p) !== -1) {
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- pregs.push(p);
|
|
|
+ pregs.push(p)
|
|
|
}
|
|
|
|
|
|
Grid {
|
|
|
@@ -179,26 +191,32 @@ ApplicationWindow {
|
|
|
}
|
|
|
|
|
|
function start_path() {
|
|
|
- points_array.push({points:[],color:curColor})
|
|
|
+ points_array.push({
|
|
|
+ points: [],
|
|
|
+ color: curColor
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function finish_path() {
|
|
|
points_array[points_array.length - 1].points = Simplify.simplify(
|
|
|
- points_array[points_array.length - 1].points, 2.2)
|
|
|
+ points_array[points_array.length - 1].points,
|
|
|
+ 2.2)
|
|
|
requestPaint()
|
|
|
|
|
|
//normalized to 800x600
|
|
|
var ar = points_array[points_array.length - 1].points.map(
|
|
|
function (el) {
|
|
|
return {
|
|
|
- x: Math.round(el.x * 800 / canvas.width),
|
|
|
- y: Math.round(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) {
|
|
|
- socket.send_drawing(ar.splice(0,29));
|
|
|
+ socket.send_drawing(ar.splice(0, 29))
|
|
|
}
|
|
|
- socket.send_drawing(ar);
|
|
|
+ socket.send_drawing(ar)
|
|
|
}
|
|
|
|
|
|
function change_image(pdf, number) {
|
|
|
@@ -208,16 +226,16 @@ ApplicationWindow {
|
|
|
}
|
|
|
|
|
|
function add_point(p) {
|
|
|
- var pts = points_array[points_array.length - 1].points;
|
|
|
- pts.push(p);
|
|
|
- if (pts.length>60){ //FIXME
|
|
|
+ var pts = points_array[points_array.length - 1].points
|
|
|
+ pts.push(p)
|
|
|
+ if (pts.length > 60) {
|
|
|
+ //FIXME
|
|
|
finish_path()
|
|
|
start_path()
|
|
|
pts.push(p)
|
|
|
} else {
|
|
|
requestPaint()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
function paint_canvas() {
|
|
|
@@ -231,15 +249,13 @@ ApplicationWindow {
|
|
|
ctx.lineWidth = 4
|
|
|
ctx.strokeStyle = "#000000"
|
|
|
|
|
|
-
|
|
|
var i = 0, j = 0
|
|
|
for (j = 0; j < points_array.length; j++) {
|
|
|
- var points = points_array[j].points;
|
|
|
-
|
|
|
+ var points = points_array[j].points
|
|
|
|
|
|
- if (points.length===0)
|
|
|
- continue;
|
|
|
- ctx.strokeStyle= points_array[j].color;
|
|
|
+ if (points.length === 0)
|
|
|
+ continue
|
|
|
+ ctx.strokeStyle = points_array[j].color
|
|
|
ctx.beginPath()
|
|
|
ctx.moveTo(points[0].x, points[0].y)
|
|
|
for (i = 0; i < points.length - 1; i++) {
|
|
|
@@ -248,7 +264,6 @@ ApplicationWindow {
|
|
|
}
|
|
|
ctx.stroke()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -287,13 +302,14 @@ ApplicationWindow {
|
|
|
|
|
|
Column {
|
|
|
width: parent.width
|
|
|
- height: parent.height/2-60
|
|
|
+ height: parent.height / 2 - 60
|
|
|
Button {
|
|
|
width: parent.width
|
|
|
height: 70
|
|
|
id: button1
|
|
|
text: qsTr("Anterior")
|
|
|
- enabled: socket.status == WebSocket.Open && (item1.curImage>1)
|
|
|
+ enabled: socket.status == WebSocket.Open
|
|
|
+ && (item1.curImage > 1)
|
|
|
onClicked: socket.prev_diapo()
|
|
|
}
|
|
|
|
|
|
@@ -302,7 +318,8 @@ ApplicationWindow {
|
|
|
width: parent.width
|
|
|
id: button2
|
|
|
text: qsTr("Siguiente")
|
|
|
- enabled: socket.status == WebSocket.Open && (item1.curImage < socket.total_slides)
|
|
|
+ enabled: socket.status == WebSocket.Open
|
|
|
+ && (item1.curImage < socket.total_slides)
|
|
|
onClicked: socket.next_diapo()
|
|
|
}
|
|
|
|
|
|
@@ -314,13 +331,12 @@ ApplicationWindow {
|
|
|
enabled: socket.status == WebSocket.Open
|
|
|
onClicked: socket.clear_path()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
Column {
|
|
|
id: column1
|
|
|
width: parent.width
|
|
|
- height: parent.height/2-60
|
|
|
+ height: parent.height / 2 - 60
|
|
|
|
|
|
Button {
|
|
|
width: parent.width
|
|
|
@@ -330,10 +346,10 @@ ApplicationWindow {
|
|
|
checked: true
|
|
|
checkable: true
|
|
|
onClicked: {
|
|
|
- color2.checked=false
|
|
|
- color3.checked=false
|
|
|
- checked=true
|
|
|
- canvas.curColor="#ff0000"
|
|
|
+ color2.checked = false
|
|
|
+ color3.checked = false
|
|
|
+ checked = true
|
|
|
+ canvas.curColor = "#ff0000"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -344,10 +360,10 @@ ApplicationWindow {
|
|
|
text: qsTr("Verde")
|
|
|
checkable: true
|
|
|
onClicked: {
|
|
|
- color1.checked=false
|
|
|
- color3.checked=false
|
|
|
- checked=true
|
|
|
- canvas.curColor="#00ff00"
|
|
|
+ color1.checked = false
|
|
|
+ color3.checked = false
|
|
|
+ checked = true
|
|
|
+ canvas.curColor = "#00ff00"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -358,20 +374,37 @@ ApplicationWindow {
|
|
|
text: qsTr("Azul")
|
|
|
checkable: true
|
|
|
onClicked: {
|
|
|
- color1.checked=false
|
|
|
- color2.checked=false
|
|
|
- checked=true
|
|
|
- canvas.curColor="#0000ff"
|
|
|
+ color1.checked = false
|
|
|
+ color2.checked = false
|
|
|
+ checked = true
|
|
|
+ canvas.curColor = "#0000ff"
|
|
|
}
|
|
|
}
|
|
|
+ Row {
|
|
|
+ id: row1
|
|
|
+ width: parent.width
|
|
|
+ height: 70
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
+ Button {
|
|
|
+ height: 70
|
|
|
+ width: parent.width / 2
|
|
|
+ id: preg
|
|
|
+ text: qsTr("Preg")
|
|
|
+ onClicked: {
|
|
|
+ socket.set_preg()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- Column {
|
|
|
- id: column2
|
|
|
- width: parent.width
|
|
|
- height: 40
|
|
|
+ Button {
|
|
|
+ height: 70
|
|
|
+ width: parent.width / 2
|
|
|
+ id: nopreg
|
|
|
+ text: qsTr("No Preg")
|
|
|
+ onClicked: {
|
|
|
+ socket.unset_preg()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Text {
|
|
|
id: text2
|
|
|
text: qsTr("WS")
|
|
|
@@ -380,10 +413,7 @@ ApplicationWindow {
|
|
|
id: text1
|
|
|
text: qsTr("test123")
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|