增加一些异常提示。

This commit is contained in:
luocai
2024-08-22 10:48:28 +08:00
parent 0c823a85b3
commit 7e28896159
10 changed files with 167 additions and 49 deletions

View File

@ -12,11 +12,15 @@ Column {
id: input
onTextChanged: {
valid = validateIp(text);
if(!valid){
hint.text="参数配置无效"
if(text.length<=0){
hint.text = "参数不能为空"
return
}
valid = validateIp(text)
if (!valid) {
hint.text = "参数配置无效"
} else {
hint.text=""
hint.text = ""
}
}
}
@ -28,7 +32,10 @@ Column {
function validateIp(ip) {
// Regular expression for validating IP address
var regex = /^(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])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$/;
return regex.test(ip);
var regex = /^(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])\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$/
return regex.test(ip)
}
function reset() {
hint.text = ""
}
}

View File

@ -95,7 +95,7 @@ ApplicationWindow {
anchors.bottom: parent.bottom
anchors.left: deviceList.right
anchors.right: parent.right
enabled: deviceList.currentIndex >= 0
enabled: App.currentDeviceConnected&&(deviceList.currentIndex >= 0)
openDoorAreaWay: App.currentOpenDoorAreaWay
openDoorAreaPoints: App.currentOpenDoorAreaPoints
shieldedAreaEnabled: App.currentShieldedAreaEnabled
@ -134,6 +134,9 @@ ApplicationWindow {
if (deviceList.currentIndex < 0) {
showMessageDialog(2, "数据采集", "请先选择设备")
return
} else if(!App.currentDeviceConnected){
showMessageDialog(2, "数据采集", "设备已离线,请重新连接设备!")
return
}
if (App.collector.path.length <= 0) {
folderDialog.open()
@ -149,7 +152,10 @@ ApplicationWindow {
text: "升级"
onClicked: {
if (deviceList.currentIndex < 0) {
showMessageDialog(2, "OTA升级", "请选择设备")
showMessageDialog(2, "OTA升级", "请选择设备!")
return
}else if(!App.currentDeviceConnected){
showMessageDialog(2, "OTA升级", "设备已离线,请重新连接设备!")
return
}
otaPopup.open()
@ -171,4 +177,10 @@ ApplicationWindow {
dialog.open()
}
}
Connections {
target: App
function onNewMessage(type, title, message) {
showMessageDialog(type, title, message)
}
}
}

View File

@ -102,7 +102,7 @@ Dialog {
} else if (type === MessageDialog.Type.Warning) {
image.source = "qrc:/qt/qml/AntiClipSettings/resources/warning.svg"
} else if(type === MessageDialog.Type.Failed){
// image.source = "qrc:/AntiClipSettings/resources/prompt_delete.svg"
image.source = "qrc:/qt/qml/AntiClipSettings/resources/prompt_delete.svg"
}
}
}

View File

@ -33,8 +33,7 @@ Popup {
RadioButton {
id: staticMode
text: "静态IP"
checked: true
// checked: !App.currentNetworkInfomation.dhcp
checked: !App.currentNetworkInfomation.dhcp
}
}
@ -106,7 +105,7 @@ Popup {
id: dnsInput
width: 350
height: inputHeight
text: App.currentNetworkInfomation.gateway
text: App.currentNetworkInfomation.dns
}
}
@ -125,7 +124,7 @@ Popup {
App.updateNetworkInfomation(dhcpMode.checked,
ipInput.text,
netmaskInput.text,
gatewayInput.text)
gatewayInput.text,dnsInput.text)
networkPopup.close()
} else {
showMessageDialog(2, "网络设置", "请输入合法参数地址!")
@ -139,4 +138,10 @@ Popup {
}
}
}
onVisibleChanged: {
ipInput.reset()
netmaskInput.reset()
gatewayInput.reset()
dnsInput.reset()
}
}

View File

@ -107,15 +107,19 @@ Popup {
Connections {
target: App
function onCurrentDeviceOtaProgressChanged (status, progress, message) {
if(progress<0)progress=0
otaFinished = !status || (progress>=100)
progressBar.value = progress
progressText.text = `${progress}%`
otaMessage.text = message
if(progress>=100){
otaMessage.text = "OTA升级完成"
otaMessage.color = "green"
}else {
otaMessage.text = message
}
}
}
onVisibleChanged: {
if(!visible){
otaMessage.color = "black"
}
}
}