|
@@ -20,6 +20,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
|
|
|
SerialPort &serialPort = AppContext::instance().serialPort();
|
|
SerialPort &serialPort = AppContext::instance().serialPort();
|
|
|
connect(&serialPort, &SerialPort::pageSwitch, this, &MainWindow::onPageSwitdh);
|
|
connect(&serialPort, &SerialPort::pageSwitch, this, &MainWindow::onPageSwitdh);
|
|
|
|
|
+
|
|
|
|
|
+ FileServer &fileServer = AppContext::instance().fileserver();
|
|
|
|
|
+ connect(&fileServer, &FileServer::monitorConfigureUpdate, this, &MainWindow::onConfigureUpdate);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
MainWindow::~MainWindow()
|
|
@@ -137,3 +140,69 @@ void MainWindow::onPageSwitdh(int state)
|
|
|
|
|
|
|
|
m_pStackedWidget->setCurrentIndex(nextIndex);
|
|
m_pStackedWidget->setCurrentIndex(nextIndex);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+void MainWindow::onConfigureUpdate(const QString &filename)
|
|
|
|
|
+{
|
|
|
|
|
+ ProjectManager &projectMgr = AppContext::instance().projectManager();
|
|
|
|
|
+ projectMgr.closeProject();
|
|
|
|
|
+
|
|
|
|
|
+ QString srcFileName = QString("%1/%2").arg(QDir::currentPath(), "update/monitor.xml");
|
|
|
|
|
+ QString dstFileName = QString("%1/%2").arg(QDir::currentPath(), "conf/monitor.xml");
|
|
|
|
|
+ bool ret;
|
|
|
|
|
+ // bool result = projectMgr.openProject(fileName);
|
|
|
|
|
+
|
|
|
|
|
+ LOG_INFO("begin delete current monitor configure...");
|
|
|
|
|
+ QFile dstFile = QFile(dstFileName);
|
|
|
|
|
+ if(dstFile.exists())
|
|
|
|
|
+ {
|
|
|
|
|
+ ret = dstFile.remove();
|
|
|
|
|
+ if(ret) {
|
|
|
|
|
+ LOG_INFO("remove current monitor configure successfully");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ LOG_ERROR("remove current monitor configure failed");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LOG_INFO("begin copy new monitor configure...");
|
|
|
|
|
+ QFile srcFile = QFile(srcFileName);
|
|
|
|
|
+ if(srcFile.exists())
|
|
|
|
|
+ {
|
|
|
|
|
+ ret = QFile::copy(srcFileName, dstFileName);
|
|
|
|
|
+ if(ret) {
|
|
|
|
|
+ LOG_INFO("update monitor configure successfully");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ LOG_ERROR("update monitor configure failed");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_ERROR("update monitor configure file not exist");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ bool result = projectMgr.openProject(dstFileName);
|
|
|
|
|
+ if(result)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_INFO("open monitor config xml success: {}, canvas count: {}", dstFileName.toUtf8().data(), projectMgr.canvasCount());
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_ERROR("open monitor config xml failed: {}", dstFileName.toUtf8().data());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LOG_INFO("start reload monitor configure");
|
|
|
|
|
+ int canvasCount = projectMgr.canvasCount();
|
|
|
|
|
+ for(int i = 0; i < canvasCount; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_DEBUG("----------------canvas {}----------------", i);
|
|
|
|
|
+ Canvas *pCanvas = new Canvas(projectMgr.canvas(i), m_pStackedWidget);
|
|
|
|
|
+ pCanvas->resize(1280, 720);
|
|
|
|
|
+ m_pStackedWidget->insertWidget(i, pCanvas);
|
|
|
|
|
+ }
|
|
|
|
|
+ LOG_INFO("reload monitor configure complete");
|
|
|
|
|
+
|
|
|
|
|
+ m_pStackedWidget->setCurrentIndex(0);
|
|
|
|
|
+}
|