解决部分BUG。

This commit is contained in:
luocai 2024-08-26 14:55:15 +08:00
parent 66c187ed1c
commit f4c6a048f5
10 changed files with 80 additions and 29 deletions

View File

@ -17,7 +17,7 @@ Application::Application(int &argc, char **argv)
font.setPointSize(16); font.setPointSize(16);
m_app->setFont(font); m_app->setFont(font);
m_app->setApplicationName(APPLICATION_NAME); m_app->setApplicationName(APPLICATION_NAME);
m_app->setApplicationVersion(QString("v%1_%2 build: %3 %4").arg(APP_VERSION, GIT_COMMIT_ID, __DATE__, __TIME__)); m_app->setApplicationVersion(QString("v%1").arg(APP_VERSION));
m_player->open(); m_player->open();
} }
@ -145,8 +145,12 @@ void Application::updateNetworkInfomation(bool dhcp, const QString &ip, const QS
const QString &dns) { const QString &dns) {
if (!m_device.expired()) { if (!m_device.expired()) {
auto device = m_device.lock(); auto device = m_device.lock();
device->updateNetworkInfomation(dhcp, ip, netmask, gateway, dns); if (device->isConnected()) {
emit newMessage(1, "网络设置", "设置成功,请等待设备重新上线!"); device->updateNetworkInfomation(dhcp, ip, netmask, gateway, dns);
emit newMessage(1, "网络设置", "设置成功,请等待设备重新上线!");
} else {
emit newMessage(2, "网络设置", "设备已离线!");
}
} }
} }

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(AntiClipSettings VERSION 0.1 LANGUAGES C CXX) project(AntiClipSettings VERSION 1.1 LANGUAGES C CXX)
set(APPLICATION_NAME "T009") set(APPLICATION_NAME "T009上位机工具")
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -9,6 +9,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(Projects_ROOT E:/Projects) set(Projects_ROOT E:/Projects)
set(Libraries_ROOT ${Projects_ROOT}/Libraries) set(Libraries_ROOT ${Projects_ROOT}/Libraries)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick Network QuickControls2)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick Network QuickControls2)
if (Qt6_FOUND) if (Qt6_FOUND)
qt_standard_project_setup(REQUIRES 6.5) qt_standard_project_setup(REQUIRES 6.5)
set(BOOST_ROOT ${Libraries_ROOT}/boost_1_86_0_msvc2022_64bit) set(BOOST_ROOT ${Libraries_ROOT}/boost_1_86_0_msvc2022_64bit)
@ -29,8 +32,6 @@ set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib) set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib)
find_package(Boost REQUIRED COMPONENTS json) find_package(Boost REQUIRED COMPONENTS json)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick Network QuickControls2)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick Network QuickControls2)
execute_process( execute_process(
COMMAND D:/msys64/usr/bin/git rev-parse --short HEAD COMMAND D:/msys64/usr/bin/git rev-parse --short HEAD

View File

@ -37,7 +37,7 @@ void DataCollection::setPath(const QString &path) {
if (m_path != p) { if (m_path != p) {
m_path = p; m_path = p;
emit pathChanged(); emit pathChanged();
LOG(info) << "set data path: " << m_path.toStdWString(); LOG(info) << "set data path: " << m_path.toStdString();
} }
} }

View File

@ -600,6 +600,7 @@ void DeviceConnection::onDisconnected() {
m_otaProgress = -1; m_otaProgress = -1;
emit otaProgressChanged(false, m_otaProgress, "网络断开,设备升级失败!"); emit otaProgressChanged(false, m_otaProgress, "网络断开,设备升级失败!");
} }
m_h264Socket->close();
} }
} }

View File

@ -99,6 +99,14 @@ std::shared_ptr<DeviceConnection> DeviceListModel::device(int index) {
return ret; return ret;
} }
bool DeviceListModel::deviceConnected(int index) {
bool ret = false;
if (index >= 0 && index < m_devices.size()) {
ret = m_devices.at(index)->isConnected();
}
return ret;
}
void DeviceListModel::startSearchDevice() { void DeviceListModel::startSearchDevice() {
if (m_timerId >= 0) { if (m_timerId >= 0) {
LOG(error) << "app is searching device."; LOG(error) << "app is searching device.";

View File

@ -31,6 +31,7 @@ public:
QHash<int, QByteArray> roleNames() const final; QHash<int, QByteArray> roleNames() const final;
Q_INVOKABLE QVariantMap get(int index) const; Q_INVOKABLE QVariantMap get(int index) const;
std::shared_ptr<DeviceConnection> device(int index); std::shared_ptr<DeviceConnection> device(int index);
Q_INVOKABLE bool deviceConnected(int index);
void startSearchDevice(); void startSearchDevice();
bool isSearching() const; bool isSearching() const;
float searchProgress() const; float searchProgress() const;

View File

@ -7,7 +7,7 @@ Item {
id: root id: root
property alias enabled: shieldedRow.enabled property alias enabled: shieldedRow.enabled
property int dargWidth: 12 property int dargWidth: 12
property color openDoorAreaColor: "green" property color openDoorAreaColor: "#0FF40D" // 绿
property var openDoorAreaPoints: [] property var openDoorAreaPoints: []
property int openDoorAreaWay: 0 property int openDoorAreaWay: 0
property color shieldedAreaColor: "yellow" property color shieldedAreaColor: "yellow"

View File

@ -7,6 +7,7 @@ Column {
property alias text: input.text property alias text: input.text
property bool valid: false property bool valid: false
property bool canEmpty: false property bool canEmpty: false
property var regularExpression : /^(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])$/
TextField { TextField {
height: 36 height: 36
width: 350 width: 350
@ -30,8 +31,7 @@ Column {
root.valid = root.canEmpty root.valid = root.canEmpty
return root.valid return root.valid
} }
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])$/ root.valid = root.regularExpression.test(input.text)
root.valid = regex.test(input.text)
if (!root.valid) { if (!root.valid) {
hint.text = "参数配置无效" hint.text = "参数配置无效"
} else { } else {

View File

@ -1,22 +1,20 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtQuick.Dialogs
import AntiClipSettings 1.0 import AntiClipSettings 1.0
import Qt.labs.platform 1.1 as Labs
ApplicationWindow { ApplicationWindow {
id: window id: window
width: 1000 width: 1000
height: 640 height: 640
visible: true visible: true
title: qsTr("T009上位机工具") title: qsTr(Qt.application.name + " " + Qt.application.version)
header: ToolBar { header: ToolBar {
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
ToolButton { Button {
Material.background: Material.Blue
text: "搜索设备" text: "搜索设备"
onClicked: { onClicked: {
deviceList.currentIndex = -1 deviceList.currentIndex = -1
@ -42,6 +40,12 @@ ApplicationWindow {
width: 420 width: 420
clip: true clip: true
model: App.devices model: App.devices
Label {
id: emptyHint
visible: false
anchors.centerIn: parent
text: qsTr("未搜索到设备")
}
delegate: Rectangle { delegate: Rectangle {
width: deviceList.width width: deviceList.width
height: 40 height: 40
@ -72,7 +76,11 @@ ApplicationWindow {
deviceList.currentIndex = index deviceList.currentIndex = index
} }
onDoubleClicked: { onDoubleClicked: {
networkPopup.open() if(App.devices.deviceConnected(index)){
networkPopup.open()
} else {
showMessageDialog(2, "网络设置", "设备已离线!")
}
} }
} }
} }
@ -97,7 +105,7 @@ ApplicationWindow {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: deviceList.right anchors.left: deviceList.right
anchors.right: parent.right anchors.right: parent.right
enabled: App.currentDeviceConnected&&(deviceList.currentIndex >= 0) enabled: App.currentDeviceConnected && (deviceList.currentIndex >= 0)
openDoorAreaWay: App.currentOpenDoorAreaWay openDoorAreaWay: App.currentOpenDoorAreaWay
openDoorAreaPoints: App.currentOpenDoorAreaPoints openDoorAreaPoints: App.currentOpenDoorAreaPoints
shieldedAreaEnabled: App.currentShieldedAreaEnabled shieldedAreaEnabled: App.currentShieldedAreaEnabled
@ -116,14 +124,6 @@ ApplicationWindow {
id: otaPopup id: otaPopup
} }
Labs.FolderDialog {
id: folderDialog
onAccepted: {
App.collector.path = folderDialog.selectedFolder
App.collector.start(App.devices.get(deviceList.currentIndex).ip)
}
}
footer: RowLayout { footer: RowLayout {
width: parent.width width: parent.width
Item {} Item {}
@ -136,12 +136,15 @@ ApplicationWindow {
if (deviceList.currentIndex < 0) { if (deviceList.currentIndex < 0) {
showMessageDialog(2, "数据采集", "请先选择设备") showMessageDialog(2, "数据采集", "请先选择设备")
return return
} else if(!App.currentDeviceConnected){ } else if (!App.currentDeviceConnected) {
showMessageDialog(2, "数据采集", "设备已离线,请重新连接设备!") showMessageDialog(2, "数据采集", "设备已离线,请重新连接设备!")
return return
} }
if (App.collector.path.length <= 0) { if (App.collector.path.length <= 0) {
folderDialog.open() showFolderDialog((folder)=>{
App.collector.path = folder
App.collector.start(App.devices.get(deviceList.currentIndex).ip)
})
} else { } else {
App.collector.start(App.devices.get( App.collector.start(App.devices.get(
deviceList.currentIndex).ip) deviceList.currentIndex).ip)
@ -156,7 +159,7 @@ ApplicationWindow {
if (deviceList.currentIndex < 0) { if (deviceList.currentIndex < 0) {
showMessageDialog(2, "OTA升级", "请先选择设备!") showMessageDialog(2, "OTA升级", "请先选择设备!")
return return
}else if(!App.currentDeviceConnected){ } else if (!App.currentDeviceConnected) {
showMessageDialog(2, "OTA升级", "设备已离线,请重新连接设备!") showMessageDialog(2, "OTA升级", "设备已离线,请重新连接设备!")
return return
} }
@ -179,10 +182,37 @@ ApplicationWindow {
dialog.open() dialog.open()
} }
} }
function showFolderDialog(onSelected){
var dialog = Qt.createQmlObject("import QtQuick.Dialogs; FolderDialog {}",window,"myDynamicSnippet");
if (dialog) {
dialog.visible = true;
dialog.accepted.connect(function() {
onSelected(dialog.selectedFolder)
dialog.destroy();
});
dialog.rejected.connect(function() {
dialog.destroy();
});
} else {
console.error("Failed to create FolderDialog object");
}
}
Connections { Connections {
target: App target: App
function onNewMessage(type, title, message) { function onNewMessage(type, title, message) {
showMessageDialog(type, title, message) showMessageDialog(type, title, message)
} }
} }
Connections {
target: App.devices
function onIsSearchingChanged() {
if (App.devices.isSearching) {
emptyHint.visible = false
} else if (!App.devices.isSearching && (App.devices.rowCount() <= 0)) {
emptyHint.visible = true
}
}
}
} }

View File

@ -15,6 +15,10 @@ Popup {
} }
contentItem: ColumnLayout { contentItem: ColumnLayout {
anchors.centerIn: parent anchors.centerIn: parent
Label {
Layout.alignment: Qt.AlignCenter
text: "有线网络设置"
}
Row { Row {
spacing: 10 spacing: 10
@ -59,6 +63,7 @@ Popup {
height: inputHeight height: inputHeight
width: 350 width: 350
text: App.currentNetworkInfomation.ip text: App.currentNetworkInfomation.ip
regularExpression: /^(22[0-3]|2[01][0-9]|1[0-9]{2}|[1-9][0-9]?|1[0-9]{2})\.(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])$/;
} }
} }
@ -101,6 +106,7 @@ Popup {
width: 350 width: 350
height: inputHeight height: inputHeight
text: App.currentNetworkInfomation.gateway text: App.currentNetworkInfomation.gateway
regularExpression: /^(22[0-3]|2[01][0-9]|1[0-9]{2}|[1-9][0-9]?|1[0-9]{2})\.(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])$/;
canEmpty: true canEmpty: true
} }
} }