udp模式功能实现
parent
916c23a1ec
commit
b2cab52f89
|
@ -3,21 +3,18 @@ import QtQuick.Controls 2.14
|
||||||
import QtQuick.Layouts 1.0
|
import QtQuick.Layouts 1.0
|
||||||
import QtQml 2.3
|
import QtQml 2.3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
objectName: "NetSelect"
|
objectName: "NetSelect"
|
||||||
width: 800
|
width: 800
|
||||||
height: 600
|
height: 600
|
||||||
visible: true
|
visible: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ColorAnimation {
|
ColorAnimation {
|
||||||
from: "white"
|
from: "white"
|
||||||
to: "black"
|
to: "black"
|
||||||
duration: 200
|
duration: 200
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
color: "#aeaeae"
|
color: "#aeaeae"
|
||||||
anchors.rightMargin: 0
|
anchors.rightMargin: 0
|
||||||
|
@ -109,7 +106,6 @@ Item {
|
||||||
"tcp"
|
"tcp"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioButton {
|
RadioButton {
|
||||||
id: radioSelectWebsocket
|
id: radioSelectWebsocket
|
||||||
Layout.leftMargin: 20
|
Layout.leftMargin: 20
|
||||||
|
@ -145,7 +141,6 @@ Item {
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
font.pointSize: 20
|
font.pointSize: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEdit {
|
TextEdit {
|
||||||
id: hostEdit
|
id: hostEdit
|
||||||
Layout.leftMargin: 20
|
Layout.leftMargin: 20
|
||||||
|
@ -175,29 +170,36 @@ Item {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(button_network.text == "打开网络"){
|
if(button_network.text == "打开网络"){
|
||||||
|
console.log(proto_combox.currentText)
|
||||||
let type_network = -1
|
let type_network = -1
|
||||||
if(proto_combox.currentText == "udp" ){
|
if(proto_combox.currentText === "udp" ){
|
||||||
type_network = 0
|
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
|
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
|
type_network = 3
|
||||||
|
button_network.text = "正在连接"
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(hostEdit.text,
|
console.log(hostEdit.text,
|
||||||
port.text,
|
port.text,
|
||||||
radioSelectWebsocket.checked,
|
radioSelectWebsocket.checked,
|
||||||
type_network)
|
type_network)
|
||||||
|
|
||||||
let ret = DataWrap.openNetwork(hostEdit.text,
|
let ret = DataWrap.openNetwork(hostEdit.text,
|
||||||
Number(port.text),
|
Number(port.text),
|
||||||
radioSelectWebsocket.checked,
|
radioSelectWebsocket.checked,
|
||||||
type_network)
|
type_network)
|
||||||
|
|
||||||
button_network.text = "正在连接"
|
|
||||||
|
|
||||||
}else (button_network.text == "关闭连接")
|
}else if ((button_network.text === "关闭连接") && (proto_combox.currentText !== "udp"))
|
||||||
{
|
{
|
||||||
|
console.log("dfdfads")
|
||||||
DataWrap.closeNetwork();
|
DataWrap.closeNetwork();
|
||||||
button_network.text = "打开网络"
|
button_network.text = "打开网络"
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,7 @@ int QmlShareData::openNetwork(QString ip, unsigned int port, bool is_ws,int type
|
||||||
(type == NetworkController::TYPE_UDP_SERVER)){
|
(type == NetworkController::TYPE_UDP_SERVER)){
|
||||||
m_network_ = new NetworkController((NetworkController::NetworkType)type,ip,port);
|
m_network_ = new NetworkController((NetworkController::NetworkType)type,ip,port);
|
||||||
connect(m_network_,SIGNAL(on_data_recv()),this,SLOT(on_network_data_recv()));
|
connect(m_network_,SIGNAL(on_data_recv()),this,SLOT(on_network_data_recv()));
|
||||||
|
emit(sendToQml(11));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue