2024-08-07 11:45:13 +08:00
|
|
|
import QtCore
|
2024-06-13 15:41:40 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
2024-08-07 11:45:13 +08:00
|
|
|
import QtQuick.Dialogs
|
2024-06-13 15:41:40 +08:00
|
|
|
import QtQuick.Layouts
|
|
|
|
import Analyser
|
|
|
|
|
2024-08-08 17:05:32 +08:00
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
ConnectionItem {}
|
2024-06-13 15:41:40 +08:00
|
|
|
|
2024-08-08 17:05:32 +08:00
|
|
|
GroupBox {
|
|
|
|
id: commandBox
|
|
|
|
title: "命令"
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
enabled: App.connected
|
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
GroupBox {
|
|
|
|
title: "注册用户"
|
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
Text {
|
|
|
|
text: qsTr("用户姓名")
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: enrollName
|
|
|
|
implicitWidth: 100
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text: qsTr("超时时间")
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: enrollTimeout
|
|
|
|
implicitWidth: 100
|
|
|
|
text: "10"
|
|
|
|
}
|
2024-07-15 17:47:19 +08:00
|
|
|
|
2024-08-08 17:05:32 +08:00
|
|
|
Text {
|
|
|
|
text: qsTr("持久化")
|
|
|
|
}
|
|
|
|
Switch {
|
|
|
|
id: persistence
|
|
|
|
checked: true
|
|
|
|
}
|
2024-07-15 17:47:19 +08:00
|
|
|
|
2024-08-08 17:05:32 +08:00
|
|
|
Text {
|
|
|
|
text: qsTr("保存图片")
|
|
|
|
}
|
|
|
|
Switch {
|
|
|
|
id: extendedMode
|
|
|
|
}
|
2024-07-15 17:47:19 +08:00
|
|
|
|
2024-08-08 17:05:32 +08:00
|
|
|
Button {
|
|
|
|
property bool enrolling: App.module ? (App.module.currentMessageId === 0x1d) || (App.module.currentMessageId === 0x1e) : false
|
|
|
|
text: enrolling ? "取消" : "注册"
|
|
|
|
onClicked: {
|
|
|
|
if (enrolling) {
|
|
|
|
App.module.reset()
|
|
|
|
} else if (extendedMode.checked) {
|
|
|
|
App.enrollExtended(
|
|
|
|
enrollName.text,
|
|
|
|
persistence.checked,
|
|
|
|
parseInt(enrollTimeout.text))
|
|
|
|
} else {
|
|
|
|
App.enroll(enrollName.text,
|
|
|
|
persistence.checked,
|
|
|
|
parseInt(enrollTimeout.text))
|
|
|
|
}
|
2024-07-15 17:47:19 +08:00
|
|
|
}
|
|
|
|
}
|
2024-06-13 15:41:40 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-08 17:05:32 +08:00
|
|
|
GroupBox {
|
|
|
|
title: "识别用户"
|
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
Text {
|
|
|
|
text: qsTr("超时时间(s)")
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: verifyTimeout
|
|
|
|
implicitWidth: 80
|
|
|
|
text: "10"
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text: qsTr("持续识别")
|
|
|
|
}
|
|
|
|
Switch {
|
|
|
|
checked: App.persistenceMode
|
|
|
|
onToggled: App.persistenceMode = !App.persistenceMode
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text: qsTr("保存图片")
|
|
|
|
}
|
|
|
|
Switch {
|
|
|
|
id: extendedVerifyMode
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text: qsTr("识别间隔(s)")
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: verifyIntetval
|
|
|
|
implicitWidth: 80
|
|
|
|
text: App.persistenceVerifyInterval
|
|
|
|
}
|
|
|
|
Item {}
|
|
|
|
Button {
|
|
|
|
text: App.isVerifying ? "停止" : "识别"
|
|
|
|
onClicked: {
|
|
|
|
if (App.isVerifying) {
|
|
|
|
App.module.reset()
|
|
|
|
} else {
|
|
|
|
App.persistenceVerifyInterval = parseInt(
|
|
|
|
verifyIntetval.text)
|
|
|
|
App.verify(extendedVerifyMode.checked,
|
|
|
|
parseInt(verifyTimeout.text))
|
|
|
|
}
|
2024-06-13 15:41:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-08-08 17:05:32 +08:00
|
|
|
GroupBox {
|
|
|
|
title: "删除用户"
|
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
Text {
|
|
|
|
text: qsTr("用户ID")
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: deleteUserId
|
|
|
|
implicitWidth: 100
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "删除"
|
|
|
|
onClicked: App.deleteUser(parseInt(
|
|
|
|
deleteUserId.text))
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "删除所有"
|
|
|
|
onClicked: App.deleteAll()
|
|
|
|
}
|
2024-06-13 15:41:40 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-08 17:05:32 +08:00
|
|
|
GroupBox {
|
|
|
|
title: "图片注册"
|
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
TextField {
|
|
|
|
id: imagePath
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
implicitWidth: 180
|
|
|
|
placeholderText: "请选择图片"
|
|
|
|
onPressed: {
|
|
|
|
fileDialog.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "注册"
|
|
|
|
onClicked: App.uploadImage(imagePath.text, 0)
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "识别"
|
|
|
|
onClicked: App.uploadImage(imagePath.text, 1)
|
2024-08-07 11:45:13 +08:00
|
|
|
}
|
2024-06-19 16:02:58 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-08 17:05:32 +08:00
|
|
|
Button {
|
|
|
|
text: "复位"
|
|
|
|
onClicked: App.module.reset()
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "状态查询"
|
|
|
|
onClicked: App.module.requestCurrentStatus()
|
2024-07-31 16:08:38 +08:00
|
|
|
}
|
2024-08-08 17:05:32 +08:00
|
|
|
Button {
|
|
|
|
text: "ID查询"
|
|
|
|
onClicked: App.module.requestUniqueId()
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
id: otaButton
|
|
|
|
text: "OTA升级"
|
|
|
|
onClicked: loader.active = true
|
|
|
|
}
|
|
|
|
Row {
|
|
|
|
Text {
|
|
|
|
text: qsTr("日志")
|
|
|
|
}
|
|
|
|
Switch {
|
|
|
|
id: debugMode
|
|
|
|
onToggled: App.module.setDebugEnabled(debugMode.checked)
|
|
|
|
}
|
2024-07-31 16:08:38 +08:00
|
|
|
}
|
|
|
|
}
|
2024-06-13 15:41:40 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-07 11:45:13 +08:00
|
|
|
FileDialog {
|
|
|
|
id: fileDialog
|
|
|
|
nameFilters: ["图片 (*.jpg *.yuv)"]
|
|
|
|
currentFolder: StandardPaths.standardLocations(
|
|
|
|
StandardPaths.DesktopLocation)[0]
|
|
|
|
onAccepted: {
|
|
|
|
var fileUrl = fileDialog.selectedFile.toString()
|
|
|
|
var localFilePath = fileUrl.startsWith(
|
|
|
|
"file:///") ? fileUrl.substring(8) : fileUrl
|
|
|
|
imagePath.text = localFilePath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 17:05:32 +08:00
|
|
|
MouseArea {
|
|
|
|
width: otaButton.width
|
|
|
|
height: otaButton.height
|
|
|
|
enabled: !commandBox.enabled
|
|
|
|
onClicked: {
|
|
|
|
loader.active = true
|
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
x = Qt.binding(() => otaButton.mapToItem(root, 0, 0).x)
|
|
|
|
y = Qt.binding(() => otaButton.mapToItem(root, 0, 0).y)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-05 17:42:27 +08:00
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
source: "OtaPage.qml"
|
|
|
|
active: false
|
|
|
|
onLoaded: {
|
|
|
|
if (loader.item && loader.item.open) {
|
2024-08-07 11:45:13 +08:00
|
|
|
loader.item.open()
|
|
|
|
loader.item.onClose = () => {
|
|
|
|
loader.active = false
|
2024-08-05 17:42:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-06-13 15:41:40 +08:00
|
|
|
}
|