2021-04-10 14:22:41 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.0
|
2021-05-01 15:41:40 +00:00
|
|
|
import QtQml 2.3
|
2021-04-10 14:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: element
|
2021-05-01 15:41:40 +00:00
|
|
|
|
2021-04-24 17:21:31 +00:00
|
|
|
width: 800
|
|
|
|
height: 600
|
2021-04-10 14:22:41 +00:00
|
|
|
visible: true
|
|
|
|
|
|
|
|
ColorAnimation {
|
|
|
|
from: "white"
|
|
|
|
to: "black"
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
Rectangle{
|
|
|
|
color: "#aeaeae"
|
2021-04-24 17:21:31 +00:00
|
|
|
anchors.rightMargin: 0
|
|
|
|
anchors.bottomMargin: 0
|
|
|
|
anchors.topMargin: 0
|
|
|
|
anchors.fill: parent
|
2021-04-10 14:22:41 +00:00
|
|
|
scale: 1
|
|
|
|
transformOrigin: Item.Center
|
2021-04-24 17:21:31 +00:00
|
|
|
Column {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 6
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2021-05-01 15:41:40 +00:00
|
|
|
RowLayout {
|
2021-04-24 17:21:31 +00:00
|
|
|
spacing: 5
|
2021-05-02 18:02:25 +00:00
|
|
|
Row{
|
2021-05-03 15:07:13 +00:00
|
|
|
Layout.topMargin: 20
|
2021-04-24 17:21:31 +00:00
|
|
|
Layout.leftMargin: 20
|
2021-05-02 18:02:25 +00:00
|
|
|
Label {
|
|
|
|
id: label6
|
|
|
|
Layout.leftMargin: 20
|
|
|
|
text: qsTr("打开端口: ")
|
|
|
|
Layout.preferredHeight: 40
|
|
|
|
renderType: Text.QtRendering
|
|
|
|
Layout.preferredWidth: 125
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
font.pointSize: 20
|
|
|
|
}
|
2021-07-19 15:52:38 +00:00
|
|
|
|
|
|
|
|
2021-05-02 18:02:25 +00:00
|
|
|
TextEdit {
|
|
|
|
id: port
|
|
|
|
Layout.leftMargin: 20
|
2021-07-19 15:52:38 +00:00
|
|
|
Layout.topMargin: 20
|
|
|
|
width: 233
|
2021-05-02 18:02:25 +00:00
|
|
|
height: 40
|
|
|
|
text: qsTr("9001")
|
2021-07-19 15:52:38 +00:00
|
|
|
font.italic: false
|
|
|
|
font.bold: true
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
Layout.preferredHeight: 33
|
|
|
|
Layout.preferredWidth: 233
|
2021-05-02 18:02:25 +00:00
|
|
|
selectionColor: "#f0f0f1"
|
|
|
|
cursorVisible: true
|
2021-07-19 15:52:38 +00:00
|
|
|
font.pixelSize: 20
|
2021-07-22 16:18:38 +00:00
|
|
|
color: "white"
|
2021-07-19 15:52:38 +00:00
|
|
|
textMargin: 4
|
2021-05-02 18:02:25 +00:00
|
|
|
}
|
|
|
|
RadioButton {
|
|
|
|
id: isServer
|
|
|
|
Layout.leftMargin: 20
|
|
|
|
width: 138
|
|
|
|
height: 41
|
|
|
|
text: qsTr("服务端")
|
|
|
|
checked: true
|
2021-04-29 14:26:45 +00:00
|
|
|
|
2021-05-02 18:02:25 +00:00
|
|
|
onClicked:{
|
|
|
|
if(isServer.checked == true){
|
|
|
|
isServer.checked = false
|
|
|
|
isServer.checkable = false
|
|
|
|
}else{
|
|
|
|
isServer.checked = true
|
|
|
|
isServer.checkable = true
|
|
|
|
}
|
2021-04-29 14:26:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-24 17:21:31 +00:00
|
|
|
}
|
|
|
|
RowLayout{
|
|
|
|
spacing: 5
|
2021-05-02 18:02:25 +00:00
|
|
|
Row{
|
2021-05-03 15:07:13 +00:00
|
|
|
Layout.topMargin: 20
|
2021-04-24 17:21:31 +00:00
|
|
|
Layout.leftMargin: 20
|
2021-05-02 18:02:25 +00:00
|
|
|
Label {
|
|
|
|
id: label7
|
|
|
|
Layout.leftMargin: 20
|
|
|
|
Layout.topMargin: 20
|
2021-06-30 16:50:13 +00:00
|
|
|
text: "协议选择:"
|
2021-05-02 18:02:25 +00:00
|
|
|
Layout.preferredHeight: 40
|
|
|
|
renderType: Text.QtRendering
|
|
|
|
Layout.preferredWidth: 125
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
font.pointSize: 20
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: proto_combox
|
|
|
|
Layout.leftMargin: 20
|
|
|
|
Layout.topMargin: 20
|
|
|
|
width: 143
|
|
|
|
height: 40
|
2021-04-10 14:22:41 +00:00
|
|
|
|
2021-05-02 18:02:25 +00:00
|
|
|
model:[
|
|
|
|
"udp",
|
|
|
|
"tcp"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
RadioButton {
|
|
|
|
id: radioSelectWebsocket
|
|
|
|
Layout.leftMargin: 20
|
|
|
|
Layout.topMargin: 20
|
|
|
|
width: 138
|
|
|
|
height: 41
|
|
|
|
text: qsTr("websocket")
|
|
|
|
checkable: true
|
|
|
|
checked: true
|
|
|
|
onClicked:{
|
|
|
|
if(radioSelectWebsocket.checked == true){
|
|
|
|
radioSelectWebsocket.checked = false
|
|
|
|
radioSelectWebsocket.checkable = false
|
|
|
|
}else{
|
|
|
|
radioSelectWebsocket.checked = true
|
|
|
|
radioSelectWebsocket.checkable = true
|
|
|
|
}
|
2021-05-01 15:41:40 +00:00
|
|
|
}
|
2021-04-24 17:21:31 +00:00
|
|
|
}
|
2021-04-10 14:22:41 +00:00
|
|
|
}
|
2021-04-24 17:21:31 +00:00
|
|
|
}
|
2021-05-01 15:41:40 +00:00
|
|
|
|
2021-04-24 17:21:31 +00:00
|
|
|
RowLayout{
|
|
|
|
spacing: 5
|
2021-04-11 03:28:04 +00:00
|
|
|
|
2021-04-24 17:21:31 +00:00
|
|
|
Label {
|
|
|
|
id: label8
|
|
|
|
Layout.leftMargin: 20
|
|
|
|
Layout.topMargin: 20
|
2021-04-29 14:26:45 +00:00
|
|
|
text: qsTr("地址: ")
|
2021-04-24 17:21:31 +00:00
|
|
|
Layout.preferredHeight: 40
|
|
|
|
renderType: Text.QtRendering
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
font.pointSize: 20
|
|
|
|
}
|
2021-07-19 15:52:38 +00:00
|
|
|
|
2021-04-24 17:21:31 +00:00
|
|
|
TextEdit {
|
|
|
|
id: hostEdit
|
|
|
|
Layout.leftMargin: 20
|
|
|
|
Layout.topMargin: 20
|
|
|
|
width: 233
|
|
|
|
height: 40
|
|
|
|
text: qsTr("127.0.0.1")
|
|
|
|
font.italic: false
|
|
|
|
font.bold: true
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
Layout.preferredHeight: 33
|
|
|
|
Layout.preferredWidth: 233
|
|
|
|
selectionColor: "#f0f0f1"
|
|
|
|
cursorVisible: true
|
|
|
|
font.pixelSize: 20
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RowLayout{
|
|
|
|
spacing: 5
|
|
|
|
Button {
|
2021-05-03 05:50:07 +00:00
|
|
|
id: button_network
|
2021-04-24 17:21:31 +00:00
|
|
|
Layout.leftMargin: 20
|
|
|
|
Layout.topMargin: 20
|
|
|
|
width: 128
|
|
|
|
height: 52
|
2021-05-03 05:50:07 +00:00
|
|
|
text: qsTr("打开网络")
|
2021-04-11 03:28:04 +00:00
|
|
|
|
2021-04-29 14:26:45 +00:00
|
|
|
onClicked: {
|
2021-05-03 05:50:07 +00:00
|
|
|
if(button_network.text == "打开网络"){
|
|
|
|
let type_network = -1
|
|
|
|
if(proto_combox.currentText == "udp" && isServer.checked){
|
|
|
|
type_network = 0
|
|
|
|
}
|
|
|
|
if(proto_combox.currentText == "udp" && !isServer.checked){
|
|
|
|
type_network = 2
|
|
|
|
}
|
|
|
|
if(proto_combox.currentText == "tcp" && isServer.checked){
|
|
|
|
type_network = 1
|
|
|
|
}
|
|
|
|
if(proto_combox.currentText == "tcp" && !isServer.checked){
|
|
|
|
type_network = 3
|
|
|
|
}
|
|
|
|
console.log(hostEdit.text,
|
|
|
|
port.text,
|
|
|
|
radioSelectWebsocket.checked,
|
|
|
|
type_network)
|
|
|
|
let ret = DataWrap.openNetwork(hostEdit.text,
|
|
|
|
Number(port.text),
|
|
|
|
radioSelectWebsocket.checked,
|
|
|
|
type_network)
|
|
|
|
if(ret != 0){
|
|
|
|
tip.fail("网络连接失败")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
tip.success("网络连接成功")
|
|
|
|
button_network.text = "关闭网络"
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
DataWrap.closeNetwork();
|
|
|
|
button_network.text = "打开网络"
|
2021-05-01 15:41:40 +00:00
|
|
|
}
|
2021-04-29 14:26:45 +00:00
|
|
|
}
|
2021-04-24 17:21:31 +00:00
|
|
|
}
|
2021-04-10 14:22:41 +00:00
|
|
|
}
|
2021-05-01 15:41:40 +00:00
|
|
|
ToolTip {
|
|
|
|
id: tip
|
|
|
|
text: qsTr("")
|
|
|
|
visible: false
|
2021-05-02 18:02:25 +00:00
|
|
|
font.pixelSize: 25
|
|
|
|
width: 220
|
|
|
|
|
2021-05-01 15:41:40 +00:00
|
|
|
contentItem: Text {
|
2021-05-02 18:02:25 +00:00
|
|
|
id : tip_item
|
2021-05-01 15:41:40 +00:00
|
|
|
text: tip.text
|
|
|
|
font: tip.font
|
|
|
|
color: "#21be2b"
|
|
|
|
}
|
2021-04-24 17:21:31 +00:00
|
|
|
|
2021-05-01 15:41:40 +00:00
|
|
|
background: Rectangle {
|
2021-05-02 18:02:25 +00:00
|
|
|
id: tip_background
|
2021-05-01 15:41:40 +00:00
|
|
|
border.color: "#21be2b"
|
2021-05-02 18:02:25 +00:00
|
|
|
width: 220
|
|
|
|
height: 40
|
|
|
|
}
|
|
|
|
function success(str){
|
|
|
|
tip_item.color = "#21be2b"
|
|
|
|
tip.text = str
|
|
|
|
tip.visible = true
|
|
|
|
}
|
|
|
|
function fail(str){
|
|
|
|
tip_item.color = "#ff0000"
|
|
|
|
tip.text = str
|
|
|
|
tip.visible = true
|
2021-05-01 15:41:40 +00:00
|
|
|
}
|
|
|
|
delay: 100
|
|
|
|
timeout: 1000
|
|
|
|
}
|
2021-04-10 14:22:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|