David 10 лет назад
Родитель
Сommit
7d830260bc
3 измененных файлов с 38 добавлено и 7 удалено
  1. 2 2
      CanvasController.pro.user
  2. 4 2
      MainForm.ui.qml
  3. 32 3
      main.qml

+ 2 - 2
CanvasController.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.0.3, 2016-08-10T23:27:57. -->
+<!-- Written by QtCreator 4.0.3, 2016-08-11T09:37:37. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -8,7 +8,7 @@
  </data>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
-  <value type="int">2</value>
+  <value type="int">0</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.EditorSettings</variable>

+ 4 - 2
MainForm.ui.qml

@@ -1,12 +1,12 @@
 import QtQuick 2.5
 import QtQuick.Controls 1.4
 import QtQuick.Layouts 1.2
-import QtWebSockets 1.0
 
 Item {
     id: item1
     width: 640
     height: 480
+    property alias gridLayout1: gridLayout1
     property alias button4: button4
     property alias mouseArea1: mouseArea1
     property alias button2: button2
@@ -31,8 +31,9 @@ Item {
             id: columnLayout1
             width: 100
             height: 100
+            Layout.columnSpan: 3
             Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-            Layout.maximumWidth: 200
+            Layout.maximumWidth: 5000
 
             Button {
                 id: button2
@@ -58,6 +59,7 @@ Item {
             Button {
                 id: button3
                 text: qsTr("Break")
+                Layout.rowSpan: 11
                 Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
                 Layout.fillWidth: true
             }

+ 32 - 3
main.qml

@@ -1,5 +1,7 @@
 import QtQuick 2.5
 import QtQuick.Controls 1.4
+import QtWebSockets 1.0
+
 import "./simplify.js" as Simplify
 
 ApplicationWindow {
@@ -9,9 +11,30 @@ ApplicationWindow {
     title: qsTr("Hello World")
 
 
+    WebSocket {
+        id: socket
+        url: "wss://ws.especificosba.com.ar"
+        onTextMessageReceived: {
+           console.log("\nReceived message: " + message);
+        }
+        onStatusChanged: if (socket.status == WebSocket.Error) {
+                             console.log("Error: " + socket.errorString)
+                         } else if (socket.status == WebSocket.Open) {
+                             socket.sendTextMessage("Hello World")
+                         } else if (socket.status == WebSocket.Closed) {
+                             console.log("\nSocket closed");
+                         }
+        active: false
+    }
+
     MainForm {
-        property int curImage:1;
+        property int curImage:1
         anchors.fill: parent
+        button1.enabled: socket.active
+        button2.enabled: socket.active
+        button3.enabled: socket.active
+        button4.enabled: socket.active
+
         button1.onClicked: {
             curImage=Math.min(curImage+1,5);
         }
@@ -27,20 +50,25 @@ ApplicationWindow {
         }
 
         mouseArea1.onPressed: {
+            if (!socket.active)
+                return;
             canvas.start_path();
         }
 
         mouseArea1.onPositionChanged: {
+            if (!socket.active)
+                return;
             canvas.add_point({x:mouse.x,y:mouse.y});
-            //canvas.paint_canvas();
         }
         mouseArea1.onReleased: {
+            if (!socket.active)
+                return;
             canvas.finish_path();
         }
 
         Canvas {
             id: canvas
-            width: 320
+            width: parent.width
             height: 250
             antialiasing: true
 
@@ -103,6 +131,7 @@ ApplicationWindow {
             }
 
         }
+
     }