瀏覽代碼

fix default canvas index set

xuqiang 4 月之前
父節點
當前提交
e13482b983
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      src/mainwindow.cpp

+ 9 - 9
src/mainwindow.cpp

@@ -231,7 +231,7 @@ void MainWindow::onConfigureUpdate(const QString &filename)
 
     LOG_INFO("start reload monitor configure");
     canvasCount = projectMgr.canvasCount();
-    int index = -1;
+    int index = 0;
     for(int i = 0; i < canvasCount; i++)
     {
         LOG_DEBUG("----------------canvas {}----------------", i);
@@ -244,12 +244,12 @@ void MainWindow::onConfigureUpdate(const QString &filename)
     }
     LOG_INFO("reload monitor configure complete");
 
-    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");
-    }
+    m_pStackedWidget->setCurrentIndex(index);
+    LOG_INFO("update: default canvas index is {}", index);
+
+    QSettings settings("settings.ini", QSettings::IniFormat);
+    settings.setIniCodec("UTF-8");
+    settings.beginGroup("CANVAS");
+    settings.setValue("INDEX", index);
+    settings.endGroup();
 }