import QtQuick import QtQuick.Controls import QtQuick.Layouts import QtQuick.Dialogs import AntiClipSettings ApplicationWindow { id: window width: 1000 height: 640 visible: true title: qsTr("T009上位机工具") header: ToolBar { RowLayout { anchors.fill: parent ToolButton { text: "搜索设备" onClicked: { deviceList.currentIndex = -1 App.startSearchDevice() } } Label { text: `设备总数: ${deviceList.count}` } Label { Layout.alignment: Qt.AlignRight Layout.preferredWidth: 280 text: App.currentFirmware.length > 0 ? `当前设备版本号: ${App.currentFirmware}` : "" } } } ListView { id: deviceList anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: parent.left width: 420 clip: true model: App.devices delegate: Rectangle { width: deviceList.width height: 40 color: ListView.isCurrentItem ? "#aaddff" : (index % 2 == 0 ? "#ffffff" : "#eeeeee") Row { anchors.fill: parent spacing: 10 Text { anchors.verticalCenter: parent.verticalCenter text: deviceId } Item {} Text { anchors.verticalCenter: parent.verticalCenter text: ip } Rectangle { anchors.verticalCenter: parent.verticalCenter color: onlineStatus ? "green" : "black" width: 10 height: 10 radius: 5 } } MouseArea { anchors.fill: parent onClicked: { deviceList.currentIndex = index } onDoubleClicked: { networkPopup.open() } } } onCurrentIndexChanged: { // deviceVersion.text = App.devices.get(deviceList.currentIndex).softwareVersion; App.connectToDevice(deviceList.currentIndex) } ProgressBar { anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom visible: App.devices.isSearching from: 0 to: 100 value: App.devices.searchProgress height: 25 } } DeviceView { anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: deviceList.right anchors.right: parent.right enabled: App.currentDeviceConnected&&(deviceList.currentIndex >= 0) openDoorAreaWay: App.currentOpenDoorAreaWay openDoorAreaPoints: App.currentOpenDoorAreaPoints shieldedAreaEnabled: App.currentShieldedAreaEnabled shieldedAreaPoints: App.currentShieldedAreaPoints antiClipAreaEnabled: App.currentAntiClipAreaEnabled antiClipAreaPoints: App.currentAntiClipAreaPoints } NetworkSettingPopup { id: networkPopup visible: false width: 500 } OtaPopup { id: otaPopup } FolderDialog { id: folderDialog onAccepted: { App.collector.path = folderDialog.selectedFolder App.collector.start(App.devices.get(deviceList.currentIndex).ip) } } footer: RowLayout { width: parent.width Item {} Button { text: App.collector.enabled ? "停止采集" : "数据采集" onClicked: { if (App.collector.enabled) { App.collector.stop() } else { if (deviceList.currentIndex < 0) { showMessageDialog(2, "数据采集", "请先选择设备") return } else if(!App.currentDeviceConnected){ showMessageDialog(2, "数据采集", "设备已离线,请重新连接设备!") return } if (App.collector.path.length <= 0) { folderDialog.open() } else { App.collector.start(App.devices.get( deviceList.currentIndex).ip) } } } } Item {} Button { text: "升级" onClicked: { if (deviceList.currentIndex < 0) { showMessageDialog(2, "OTA升级", "请先选择设备!") return }else if(!App.currentDeviceConnected){ showMessageDialog(2, "OTA升级", "设备已离线,请重新连接设备!") return } otaPopup.open() } } Item {} spacing: (parent.width - (2 * 100)) / 3 } function showMessageDialog(type, title, message) { let component = Qt.createComponent("MessageDialog.qml") if (component.status === Component.Ready) { let dialog = component.createObject(window, { "type": type, "height": 200, "titleText": title, "text": message }) dialog.open() } } Connections { target: App function onNewMessage(type, title, message) { showMessageDialog(type, title, message) } } }