SmartLockerTools/Analyser/qml/ExtendedOperations.qml

154 lines
5.0 KiB
QML
Raw Normal View History

2024-10-25 17:18:09 +08:00
import QtCore
2024-09-25 18:44:04 +08:00
import QtQuick
import QtQuick.Controls
2024-10-25 17:18:09 +08:00
import QtQuick.Dialogs
2024-09-25 18:44:04 +08:00
import QtQuick.Layouts
import Analyser
Item {
id: control
RowLayout {
anchors.fill: parent
enabled: App.connected
Column {
GroupBox {
title: "删除用户"
GridLayout {
columns: 2
Label {
text: qsTr("用户ID")
}
TextField {
id: deleteUserId
implicitWidth: 100
}
Button {
text: "删除"
onClicked: App.deleteUser(parseInt(deleteUserId.text))
}
Button {
text: "删除所有"
onClicked: App.deleteAll()
}
}
}
GroupBox {
title: "其它"
enabled: App.connected
GridLayout {
columns: 2
Button {
text: "复位"
onClicked: App.module.reset()
}
Button {
text: "状态查询"
onClicked: App.module.requestCurrentStatus()
}
Button {
text: "ID查询"
onClicked: App.module.requestUniqueId()
}
Button {
id: otaButton
text: "OTA升级"
onClicked: loader.active = true
}
Row {
Label {
text: qsTr("日志")
}
Switch {
id: debugMode
2024-10-25 17:18:09 +08:00
checked: App.module ? App.module.cdcDebugEnabled : false
2024-09-25 18:44:04 +08:00
onToggled: App.module.setDebugEnabled(debugMode.checked)
}
}
}
}
}
GroupBox {
2024-10-25 17:18:09 +08:00
id: imageBox
2024-09-25 18:44:04 +08:00
title: "图片注册"
visible: true
2024-10-25 17:18:09 +08:00
property bool imaging: (App.currentMessageId == ModuleCommunication.UploadImageInfo) || (App.currentMessageId == ModuleCommunication.UploadImageData)
2024-09-25 18:44:04 +08:00
GridLayout {
columns: 2
TextField {
id: imagePath
Layout.columnSpan: 2
implicitWidth: 200
placeholderText: "请选择图片"
onPressed: {
fileDialog.open()
}
}
Label {
text: qsTr("用户姓名")
}
TextField {
id: imageEnrollName
implicitWidth: 100
text: "测试下发"
}
2024-10-25 17:18:09 +08:00
Label {
text: qsTr("操作")
}
ComboBox {
id: imageMode
implicitWidth: 100
model: ["注册", "识别"]
}
2024-09-25 18:44:04 +08:00
Label {
text: qsTr("循环")
}
Switch {
2024-10-25 17:18:09 +08:00
checked: App.persistenceCommand == ModuleCommunication.UploadImageInfo
onToggled: App.persistenceCommand = checked ? ModuleCommunication.UploadImageInfo : ModuleCommunication.Idle
2024-09-25 18:44:04 +08:00
}
Button {
2024-10-25 17:18:09 +08:00
text: imageBox.imaging ? "取消" : "执行"
onClicked: {
if (imageBox.imaging) {
App.resetModule()
} else {
App.uploadImage(imagePath.text, imageEnrollName.text, imageMode.currentIndex)
}
}
2024-09-25 18:44:04 +08:00
}
}
}
}
2024-10-25 17:18:09 +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-09-25 18:44:04 +08:00
MouseArea {
id: otaMouseArea
width: otaButton.width
height: otaButton.height
enabled: !App.connected
onClicked: {
loader.active = true
}
}
onVisibleChanged: {
if (!visible)
return
Qt.callLater(() => {
otaMouseArea.x = otaButton.mapToItem(control, 0, 0).x
otaMouseArea.y = otaButton.mapToItem(control, 0, 0).y
})
}
}