2024-08-24 22:35:35 +08:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import AntiClipSettings 1.0
|
2024-08-16 16:24:15 +08:00
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: root
|
|
|
|
parent: Overlay.overlay
|
|
|
|
anchors.centerIn: Overlay.overlay
|
2024-08-21 16:03:49 +08:00
|
|
|
modal: true
|
2024-08-22 12:28:11 +08:00
|
|
|
closePolicy: Popup.CloseOnEscap | Popup.NoAutoClose
|
2024-08-27 11:14:36 +08:00
|
|
|
property int inputHeight: 56
|
2024-08-21 16:03:49 +08:00
|
|
|
background: Rectangle {
|
|
|
|
radius: 8
|
|
|
|
}
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
anchors.centerIn: parent
|
2024-08-26 14:55:15 +08:00
|
|
|
Label {
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
text: "有线网络设置"
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Row {
|
2024-08-16 16:24:15 +08:00
|
|
|
spacing: 10
|
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Label {
|
|
|
|
text: "模式"
|
|
|
|
width: 100
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2024-08-16 16:24:15 +08:00
|
|
|
}
|
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
RadioButton {
|
|
|
|
id: dhcpMode
|
|
|
|
text: "DHCP"
|
|
|
|
checked: App.currentNetworkInfomation.dhcp
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
RadioButton {
|
|
|
|
id: staticMode
|
|
|
|
text: "静态IP"
|
2024-08-22 10:48:28 +08:00
|
|
|
checked: !App.currentNetworkInfomation.dhcp
|
2024-08-21 16:03:49 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Row {
|
|
|
|
spacing: 5
|
|
|
|
visible: staticMode.checked
|
2024-08-22 12:28:11 +08:00
|
|
|
Row {
|
2024-08-21 16:03:49 +08:00
|
|
|
width: 100
|
2024-08-22 12:28:11 +08:00
|
|
|
anchors.verticalCenterOffset: -10
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
Label {
|
|
|
|
text: "设备IP"
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
color: "red"
|
|
|
|
text: "*"
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
}
|
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
IpTextField {
|
|
|
|
id: ipInput
|
|
|
|
height: inputHeight
|
|
|
|
width: 350
|
|
|
|
text: App.currentNetworkInfomation.ip
|
2024-08-26 14:55:15 +08:00
|
|
|
regularExpression: /^(22[0-3]|2[01][0-9]|1[0-9]{2}|[1-9][0-9]?|1[0-9]{2})\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$/;
|
2024-08-21 16:03:49 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Row {
|
|
|
|
spacing: 5
|
|
|
|
visible: staticMode.checked
|
2024-08-22 12:28:11 +08:00
|
|
|
Row {
|
2024-08-21 16:03:49 +08:00
|
|
|
width: 100
|
2024-08-22 12:28:11 +08:00
|
|
|
anchors.verticalCenterOffset: -10
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
Label {
|
|
|
|
text: "子网掩码"
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
color: "red"
|
|
|
|
text: "*"
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
}
|
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
IpTextField {
|
|
|
|
id: netmaskInput
|
|
|
|
width: 350
|
|
|
|
height: inputHeight
|
|
|
|
text: App.currentNetworkInfomation.netmask
|
|
|
|
}
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Row {
|
|
|
|
spacing: 5
|
|
|
|
visible: staticMode.checked
|
|
|
|
Label {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: "设备网关"
|
|
|
|
anchors.verticalCenterOffset: -10
|
|
|
|
width: 100
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
IpTextField {
|
|
|
|
id: gatewayInput
|
|
|
|
width: 350
|
|
|
|
height: inputHeight
|
|
|
|
text: App.currentNetworkInfomation.gateway
|
2024-08-26 14:55:15 +08:00
|
|
|
regularExpression: /^(22[0-3]|2[01][0-9]|1[0-9]{2}|[1-9][0-9]?|1[0-9]{2})\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$/;
|
2024-08-22 12:28:11 +08:00
|
|
|
canEmpty: true
|
2024-08-21 16:03:49 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Row {
|
|
|
|
spacing: 5
|
2024-08-22 12:28:11 +08:00
|
|
|
visible: false // staticMode.checked 暂时不用设置
|
2024-08-21 16:03:49 +08:00
|
|
|
Label {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: "DNS服务器"
|
|
|
|
anchors.verticalCenterOffset: -10
|
|
|
|
width: 100
|
2024-08-16 16:24:15 +08:00
|
|
|
}
|
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
IpTextField {
|
|
|
|
id: dnsInput
|
|
|
|
width: 350
|
|
|
|
height: inputHeight
|
2024-08-22 10:48:28 +08:00
|
|
|
text: App.currentNetworkInfomation.dns
|
2024-08-22 12:28:11 +08:00
|
|
|
canEmpty: true
|
2024-08-21 16:03:49 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Row {
|
|
|
|
Layout.rightMargin: 20
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: "保存"
|
|
|
|
onClicked: {
|
2024-08-22 12:28:11 +08:00
|
|
|
ipInput.validate()
|
|
|
|
netmaskInput.validate()
|
|
|
|
gatewayInput.validate()
|
|
|
|
dnsInput.validate()
|
2024-08-21 16:03:49 +08:00
|
|
|
if (dhcpMode.checked || (staticMode.checked && ipInput.valid
|
|
|
|
&& netmaskInput.valid
|
|
|
|
&& gatewayInput.valid
|
|
|
|
&& dnsInput.valid)) {
|
|
|
|
App.updateNetworkInfomation(dhcpMode.checked,
|
|
|
|
ipInput.text,
|
|
|
|
netmaskInput.text,
|
2024-08-22 12:28:11 +08:00
|
|
|
gatewayInput.text,
|
|
|
|
dnsInput.text)
|
2024-08-16 16:24:15 +08:00
|
|
|
networkPopup.close()
|
|
|
|
}
|
|
|
|
}
|
2024-08-21 16:03:49 +08:00
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
|
2024-08-21 16:03:49 +08:00
|
|
|
Button {
|
|
|
|
text: "取消"
|
|
|
|
onClicked: root.close()
|
2024-08-16 16:24:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-08-22 10:48:28 +08:00
|
|
|
onVisibleChanged: {
|
2024-08-22 12:28:11 +08:00
|
|
|
if (visible) {
|
|
|
|
ipInput.reset()
|
|
|
|
netmaskInput.reset()
|
|
|
|
gatewayInput.reset()
|
|
|
|
dnsInput.reset()
|
|
|
|
|
|
|
|
dhcpMode.checked = App.currentNetworkInfomation.dhcp
|
|
|
|
staticMode.checked = !App.currentNetworkInfomation.dhcp
|
|
|
|
ipInput.text = App.currentNetworkInfomation.ip
|
|
|
|
netmaskInput.text = App.currentNetworkInfomation.netmask
|
|
|
|
gatewayInput.text = App.currentNetworkInfomation.gateway
|
|
|
|
dnsInput.text = App.currentNetworkInfomation.dns
|
|
|
|
}
|
2024-08-22 10:48:28 +08:00
|
|
|
}
|
2024-08-16 16:24:15 +08:00
|
|
|
}
|