From b2cab52f89ce7eb1333d3fb93bd6a8b905dd667e Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Mon, 30 Aug 2021 22:56:38 +0800 Subject: [PATCH] =?UTF-8?q?udp=E6=A8=A1=E5=BC=8F=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protoDebuger/NetSelect.qml | 24 +++++++++++++----------- protoDebuger/sharedata.cpp | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/protoDebuger/NetSelect.qml b/protoDebuger/NetSelect.qml index 9e093e3..b2503dc 100644 --- a/protoDebuger/NetSelect.qml +++ b/protoDebuger/NetSelect.qml @@ -3,21 +3,18 @@ import QtQuick.Controls 2.14 import QtQuick.Layouts 1.0 import QtQml 2.3 - - Item { objectName: "NetSelect" width: 800 height: 600 visible: true - - ColorAnimation { from: "white" to: "black" duration: 200 } + Rectangle{ color: "#aeaeae" anchors.rightMargin: 0 @@ -109,7 +106,6 @@ Item { "tcp" ] } - RadioButton { id: radioSelectWebsocket Layout.leftMargin: 20 @@ -145,7 +141,6 @@ Item { wrapMode: Text.NoWrap font.pointSize: 20 } - TextEdit { id: hostEdit Layout.leftMargin: 20 @@ -175,29 +170,36 @@ Item { onClicked: { if(button_network.text == "打开网络"){ + console.log(proto_combox.currentText) let type_network = -1 - if(proto_combox.currentText == "udp" ){ + if(proto_combox.currentText === "udp" ){ type_network = 0 + button_network.text = "关闭连接" + } - if(proto_combox.currentText == "tcp" && (conn_type.currentText == "server")){ + if(proto_combox.currentText === "tcp" && (conn_type.currentText === "server")){ type_network = 1 + button_network.text = "正在连接" } - if(proto_combox.currentText == "tcp" && (conn_type.currentText == "client")){ + if(proto_combox.currentText === "tcp" && (conn_type.currentText === "client")){ type_network = 3 + button_network.text = "正在连接" } + console.log(hostEdit.text, port.text, radioSelectWebsocket.checked, type_network) + let ret = DataWrap.openNetwork(hostEdit.text, Number(port.text), radioSelectWebsocket.checked, type_network) - button_network.text = "正在连接" - }else (button_network.text == "关闭连接") + }else if ((button_network.text === "关闭连接") && (proto_combox.currentText !== "udp")) { + console.log("dfdfads") DataWrap.closeNetwork(); button_network.text = "打开网络" } diff --git a/protoDebuger/sharedata.cpp b/protoDebuger/sharedata.cpp index 2346bfd..6247e3a 100644 --- a/protoDebuger/sharedata.cpp +++ b/protoDebuger/sharedata.cpp @@ -101,6 +101,7 @@ int QmlShareData::openNetwork(QString ip, unsigned int port, bool is_ws,int type (type == NetworkController::TYPE_UDP_SERVER)){ m_network_ = new NetworkController((NetworkController::NetworkType)type,ip,port); connect(m_network_,SIGNAL(on_data_recv()),this,SLOT(on_network_data_recv())); + emit(sendToQml(11)); return 0; }