|
@@ -45,7 +45,23 @@ void MainWindow::init_ui()
|
|
|
pMainLayout->setSpacing(0);
|
|
pMainLayout->setSpacing(0);
|
|
|
pMainLayout->setContentsMargins(0, 0, 0, 0);
|
|
pMainLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
+ reload();
|
|
|
|
|
+ setCurrentCanvas();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void MainWindow::reload()
|
|
|
|
|
+{
|
|
|
ProjectManager &projectMgr = AppContext::instance().projectManager();
|
|
ProjectManager &projectMgr = AppContext::instance().projectManager();
|
|
|
|
|
+ QString fileName = QString("%1/%2").arg(QDir::currentPath(), "conf/monitor.xml");
|
|
|
|
|
+ bool result = projectMgr.openProject(fileName);
|
|
|
|
|
+ if(result) {
|
|
|
|
|
+ LOG_INFO("open monitor config xml success: {}, canvas count: {}", fileName.toUtf8().data(), projectMgr.canvasCount());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ LOG_ERROR("open monitor config xml failed: {}", fileName.toUtf8().data());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LOG_INFO("start reload monitor configure");
|
|
|
int canvasCount = projectMgr.canvasCount();
|
|
int canvasCount = projectMgr.canvasCount();
|
|
|
for(int i = 0; i < canvasCount; i++)
|
|
for(int i = 0; i < canvasCount; i++)
|
|
|
{
|
|
{
|
|
@@ -54,24 +70,11 @@ void MainWindow::init_ui()
|
|
|
pCanvas->resize(1280, 720);
|
|
pCanvas->resize(1280, 720);
|
|
|
m_pStackedWidget->insertWidget(i, pCanvas);
|
|
m_pStackedWidget->insertWidget(i, pCanvas);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- int index = 0;
|
|
|
|
|
- QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
|
|
|
- settings.setIniCodec("UTF-8");
|
|
|
|
|
- settings.beginGroup("CANVAS");
|
|
|
|
|
- if(settings.contains("INDEX")) {
|
|
|
|
|
- index = settings.value("INDEX").toInt();
|
|
|
|
|
- LOG_INFO("find saved canvas index, set index {}", index);
|
|
|
|
|
- } else {
|
|
|
|
|
- LOG_INFO("not find saved canvas index, set index 0");
|
|
|
|
|
- }
|
|
|
|
|
- settings.endGroup();
|
|
|
|
|
- m_pStackedWidget->setCurrentIndex(index);
|
|
|
|
|
|
|
+ LOG_INFO("reload monitor configure complete");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void MainWindow::reloadCanvas()
|
|
|
|
|
|
|
+void MainWindow::clear()
|
|
|
{
|
|
{
|
|
|
- ProjectManager &projectMgr = AppContext::instance().projectManager();
|
|
|
|
|
LOG_INFO("begin release exist canvas");
|
|
LOG_INFO("begin release exist canvas");
|
|
|
{
|
|
{
|
|
|
QList<QWidget*> widgets;
|
|
QList<QWidget*> widgets;
|
|
@@ -86,42 +89,39 @@ void MainWindow::reloadCanvas()
|
|
|
delete w;
|
|
delete w;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ ProjectManager &projectMgr = AppContext::instance().projectManager();
|
|
|
|
|
+ projectMgr.closeProject();
|
|
|
LOG_INFO("release exist canvas complete, widget count: {}", m_pStackedWidget->count());
|
|
LOG_INFO("release exist canvas complete, widget count: {}", m_pStackedWidget->count());
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- QString fileName = QString("%1/%2").arg(QDir::currentPath(), "conf/monitor.xml");
|
|
|
|
|
- bool result = projectMgr.openProject(fileName);
|
|
|
|
|
- if(result)
|
|
|
|
|
- {
|
|
|
|
|
- LOG_INFO("open monitor config xml success: {}, canvas count: {}", fileName.toUtf8().data(), projectMgr.canvasCount());
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- LOG_ERROR("open monitor config xml failed: {}", fileName.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");
|
|
|
|
|
-
|
|
|
|
|
|
|
+void MainWindow::setCurrentCanvas(bool isNewComfigure)
|
|
|
|
|
+{
|
|
|
int index = 0;
|
|
int index = 0;
|
|
|
- QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
|
|
|
- settings.setIniCodec("UTF-8");
|
|
|
|
|
- settings.beginGroup("CANVAS");
|
|
|
|
|
- if(settings.contains("INDEX")) {
|
|
|
|
|
- index = settings.value("INDEX").toInt();
|
|
|
|
|
- LOG_INFO("find saved canvas index, set index {}", index);
|
|
|
|
|
|
|
+ if(isNewComfigure) {
|
|
|
|
|
+ int canvasCount = m_pStackedWidget->count();
|
|
|
|
|
+ for(int i = 0; i < canvasCount; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ QWidget *pWidget = m_pStackedWidget->widget(i);
|
|
|
|
|
+ Canvas *pCanvas = static_cast<Canvas *>(pWidget);
|
|
|
|
|
+ if(pCanvas->isDefault()) {
|
|
|
|
|
+ index = i;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- LOG_INFO("not find saved canvas index, set index 0");
|
|
|
|
|
|
|
+ QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
|
|
|
+ settings.setIniCodec("UTF-8");
|
|
|
|
|
+ settings.beginGroup("CANVAS");
|
|
|
|
|
+ if(settings.contains("INDEX")) {
|
|
|
|
|
+ index = settings.value("INDEX").toInt();
|
|
|
|
|
+ LOG_INFO("find saved canvas index, set index {}", index);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ LOG_INFO("not find saved canvas index, set index 0");
|
|
|
|
|
+ settings.setValue("INDEX", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ settings.endGroup();
|
|
|
}
|
|
}
|
|
|
- settings.endGroup();
|
|
|
|
|
|
|
+
|
|
|
m_pStackedWidget->setCurrentIndex(index);
|
|
m_pStackedWidget->setCurrentIndex(index);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -195,20 +195,15 @@ void MainWindow::onPageSwitdh(int state)
|
|
|
int currentIndex = m_pStackedWidget->currentIndex();
|
|
int currentIndex = m_pStackedWidget->currentIndex();
|
|
|
int nextIndex = currentIndex;
|
|
int nextIndex = currentIndex;
|
|
|
|
|
|
|
|
- if (state < 0)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (state < 0) {
|
|
|
// 上一页
|
|
// 上一页
|
|
|
nextIndex = (currentIndex - 1 + canvasCount) % canvasCount;
|
|
nextIndex = (currentIndex - 1 + canvasCount) % canvasCount;
|
|
|
LOG_INFO("page up: {}", nextIndex);
|
|
LOG_INFO("page up: {}", nextIndex);
|
|
|
- }
|
|
|
|
|
- else if (state > 0)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (state > 0) {
|
|
|
// 下一页
|
|
// 下一页
|
|
|
nextIndex = (currentIndex + 1) % canvasCount;
|
|
nextIndex = (currentIndex + 1) % canvasCount;
|
|
|
LOG_INFO("page down: {}", nextIndex);
|
|
LOG_INFO("page down: {}", nextIndex);
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
return; // state == 0 不翻页
|
|
return; // state == 0 不翻页
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -223,16 +218,11 @@ void MainWindow::onPageSwitdh(int state)
|
|
|
|
|
|
|
|
void MainWindow::onConfigureUpdate(const QString &filename)
|
|
void MainWindow::onConfigureUpdate(const QString &filename)
|
|
|
{
|
|
{
|
|
|
- int canvasCount;
|
|
|
|
|
- ProjectManager &projectMgr = AppContext::instance().projectManager();
|
|
|
|
|
- canvasCount = projectMgr.canvasCount();
|
|
|
|
|
- projectMgr.closeProject();
|
|
|
|
|
|
|
+ clear();
|
|
|
|
|
|
|
|
- // QString srcFileName = QString("%1/%2").arg(QDir::currentPath(), "update/monitor.xml");
|
|
|
|
|
QString srcFileName = filename;
|
|
QString srcFileName = filename;
|
|
|
QString dstFileName = QString("%1/%2").arg(QDir::currentPath(), "conf/monitor.xml");
|
|
QString dstFileName = QString("%1/%2").arg(QDir::currentPath(), "conf/monitor.xml");
|
|
|
bool ret;
|
|
bool ret;
|
|
|
- // bool result = projectMgr.openProject(fileName);
|
|
|
|
|
|
|
|
|
|
LOG_INFO("begin delete current monitor configure...");
|
|
LOG_INFO("begin delete current monitor configure...");
|
|
|
QFile dstFile = QFile(dstFileName);
|
|
QFile dstFile = QFile(dstFileName);
|
|
@@ -249,8 +239,7 @@ void MainWindow::onConfigureUpdate(const QString &filename)
|
|
|
|
|
|
|
|
LOG_INFO("begin copy new monitor configure...");
|
|
LOG_INFO("begin copy new monitor configure...");
|
|
|
QFile srcFile = QFile(srcFileName);
|
|
QFile srcFile = QFile(srcFileName);
|
|
|
- if(srcFile.exists())
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if(srcFile.exists()) {
|
|
|
ret = QFile::copy(srcFileName, dstFileName);
|
|
ret = QFile::copy(srcFileName, dstFileName);
|
|
|
if(ret) {
|
|
if(ret) {
|
|
|
LOG_INFO("update monitor configure successfully");
|
|
LOG_INFO("update monitor configure successfully");
|
|
@@ -258,66 +247,28 @@ void MainWindow::onConfigureUpdate(const QString &filename)
|
|
|
LOG_ERROR("update monitor configure failed");
|
|
LOG_ERROR("update monitor configure failed");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
LOG_ERROR("update monitor configure file not exist");
|
|
LOG_ERROR("update monitor configure file not exist");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- LOG_INFO("begin release exist canvas");
|
|
|
|
|
- {
|
|
|
|
|
- QList<QWidget*> widgets;
|
|
|
|
|
- for (int i = 0; i < m_pStackedWidget->count(); ++i) {
|
|
|
|
|
- widgets << m_pStackedWidget->widget(i);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- for (QWidget *w : widgets) {
|
|
|
|
|
- Canvas *pCanvas = static_cast<Canvas *>(w);
|
|
|
|
|
- pCanvas->clear();
|
|
|
|
|
- m_pStackedWidget->removeWidget(w);
|
|
|
|
|
- delete w;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- LOG_INFO("release exist canvas complete, widget count: {}", m_pStackedWidget->count());
|
|
|
|
|
|
|
+ reload();
|
|
|
|
|
|
|
|
- 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");
|
|
|
|
|
- canvasCount = projectMgr.canvasCount();
|
|
|
|
|
- int index = 0;
|
|
|
|
|
- for(int i = 0; i < canvasCount; i++)
|
|
|
|
|
- {
|
|
|
|
|
- LOG_DEBUG("----------------canvas {}----------------", i);
|
|
|
|
|
- Canvas *pCanvas = new Canvas(projectMgr.canvas(i), m_pStackedWidget);
|
|
|
|
|
- pCanvas->resize(1280, 720);
|
|
|
|
|
- if(pCanvas->isDefault()) {
|
|
|
|
|
- index = i;
|
|
|
|
|
- }
|
|
|
|
|
- m_pStackedWidget->insertWidget(i, pCanvas);
|
|
|
|
|
- }
|
|
|
|
|
- LOG_INFO("reload monitor configure complete");
|
|
|
|
|
-
|
|
|
|
|
- m_pStackedWidget->setCurrentIndex(index);
|
|
|
|
|
- LOG_INFO("update: default canvas index is {}", index);
|
|
|
|
|
|
|
+ setCurrentCanvas(true);
|
|
|
|
|
|
|
|
|
|
+ LOG_INFO("update: default canvas index is {}", m_pStackedWidget->currentIndex());
|
|
|
QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
|
settings.setIniCodec("UTF-8");
|
|
settings.setIniCodec("UTF-8");
|
|
|
settings.beginGroup("CANVAS");
|
|
settings.beginGroup("CANVAS");
|
|
|
- settings.setValue("INDEX", index);
|
|
|
|
|
|
|
+ settings.setValue("INDEX", m_pStackedWidget->currentIndex());
|
|
|
settings.endGroup();
|
|
settings.endGroup();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::onReloadCanvas()
|
|
void MainWindow::onReloadCanvas()
|
|
|
{
|
|
{
|
|
|
- reloadCanvas();
|
|
|
|
|
|
|
+ // reloadCanvas();
|
|
|
|
|
+ clear();
|
|
|
|
|
+ reload();
|
|
|
|
|
+ setCurrentCanvas();
|
|
|
}
|
|
}
|