KeyInput: Add input validation.
This commit is contained in:
parent
a021db0c76
commit
d7dcdbd652
|
@ -152,11 +152,11 @@ RibbonTabBar {
|
||||||
show_tooltip: false
|
show_tooltip: false
|
||||||
text: SerialPortManager.opened ? qsTr("关闭串口") : qsTr("打开串口")
|
text: SerialPortManager.opened ? qsTr("关闭串口") : qsTr("打开串口")
|
||||||
onClicked: !SerialPortManager.opened ? SerialPortManager.open(serial_port_combo.currentText,
|
onClicked: !SerialPortManager.opened ? SerialPortManager.open(serial_port_combo.currentText,
|
||||||
serial_baudrate_combo.currentText,
|
serial_baudrate_combo.currentText,
|
||||||
serial_databits_combo.currentText,
|
serial_databits_combo.currentText,
|
||||||
serial_parity_combo.currentText,
|
serial_parity_combo.currentText,
|
||||||
serial_stopbits_combo.currentText) :
|
serial_stopbits_combo.currentText) :
|
||||||
SerialPortManager.close()
|
SerialPortManager.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,12 +289,29 @@ RibbonTabBar {
|
||||||
text: qsTr("保存")
|
text: qsTr("保存")
|
||||||
show_tooltip: false
|
show_tooltip: false
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var keys = []
|
let key = key_manage_edit.text
|
||||||
keys = ZigBeeParser.pre_hmac_verify_key
|
let result = key_manage_layout.key_format_validate(key)
|
||||||
keys.push(ZigBeeParser.hmac_verify_key)
|
if (result.length === 32)
|
||||||
ZigBeeParser.hmac_verify_key = key_manage_edit.text
|
{
|
||||||
ZigBeeParser.pre_hmac_verify_key = keys
|
var keys = []
|
||||||
key_manage_edit.clear()
|
keys = ZigBeeParser.pre_hmac_verify_key
|
||||||
|
keys.push(ZigBeeParser.hmac_verify_key)
|
||||||
|
ZigBeeParser.hmac_verify_key = result
|
||||||
|
ZigBeeParser.pre_hmac_verify_key = keys
|
||||||
|
key_manage_edit.clear()
|
||||||
|
}
|
||||||
|
else if (result === 'le')
|
||||||
|
{
|
||||||
|
key_manage_edit.text = qsTr("字符长度错误,应为32!")
|
||||||
|
}
|
||||||
|
else if (result === 'ce')
|
||||||
|
{
|
||||||
|
key_manage_edit.text = qsTr("格式错误,应全大/小写!")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key_manage_edit.text = qsTr("格式错误,应为十六进制!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,6 +324,19 @@ RibbonTabBar {
|
||||||
show_popup("components/KeysList.qml")
|
show_popup("components/KeysList.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function key_format_validate(str) {
|
||||||
|
str = str.replace(/\s/g, "");
|
||||||
|
if (str.length !== 32) {
|
||||||
|
return "le";
|
||||||
|
}
|
||||||
|
if (str !== str.toUpperCase() && str !== str.toLowerCase()) {
|
||||||
|
return "ce";
|
||||||
|
}
|
||||||
|
if (/[^0-9A-Fa-f]/.test(str)) {
|
||||||
|
return "ae";
|
||||||
|
}
|
||||||
|
return str.toUpperCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RibbonTabGroup{
|
RibbonTabGroup{
|
||||||
|
|
Loading…
Reference in New Issue