|
|
@@ -7,6 +7,7 @@
|
|
|
#include "logger.h"
|
|
|
#include "utils.h"
|
|
|
#include "abstractwidget.h"
|
|
|
+#include <QSettings>
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent)
|
|
|
@@ -50,7 +51,18 @@ void MainWindow::init_ui()
|
|
|
m_pStackedWidget->insertWidget(i, pCanvas);
|
|
|
}
|
|
|
|
|
|
- m_pStackedWidget->setCurrentIndex(0);
|
|
|
+ int index = 0;
|
|
|
+ QSettings settings("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);
|
|
|
}
|
|
|
|
|
|
void MainWindow::onUpdateScreen(const QJsonObject &obj)
|
|
|
@@ -139,6 +151,12 @@ void MainWindow::onPageSwitdh(int state)
|
|
|
}
|
|
|
|
|
|
m_pStackedWidget->setCurrentIndex(nextIndex);
|
|
|
+
|
|
|
+ QSettings settings("settings.ini", QSettings::IniFormat);
|
|
|
+ settings.setIniCodec("UTF-8");
|
|
|
+ settings.beginGroup("CANVAS");
|
|
|
+ settings.setValue("INDEX", nextIndex);
|
|
|
+ settings.endGroup();
|
|
|
}
|
|
|
|
|
|
void MainWindow::onConfigureUpdate(const QString &filename)
|
|
|
@@ -195,14 +213,25 @@ void MainWindow::onConfigureUpdate(const QString &filename)
|
|
|
|
|
|
LOG_INFO("start reload monitor configure");
|
|
|
int canvasCount = projectMgr.canvasCount();
|
|
|
+ int index = -1;
|
|
|
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(0);
|
|
|
+ if(index > 0 && index < canvasCount) {
|
|
|
+ m_pStackedWidget->setCurrentIndex(index);
|
|
|
+ LOG_INFO("update: default canvas index is {}", index);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_pStackedWidget->setCurrentIndex(0);
|
|
|
+ LOG_INFO("update: not set default canvas index, set index 0");
|
|
|
+ }
|
|
|
}
|