|
@@ -18,7 +18,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
Network &network = AppContext::instance().network();
|
|
Network &network = AppContext::instance().network();
|
|
|
connect(&network, &Network::updateScreen, this, &MainWindow::onUpdateScreen);
|
|
connect(&network, &Network::updateScreen, this, &MainWindow::onUpdateScreen);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ SerialPort &serialPort = AppContext::instance().serialPort();
|
|
|
|
|
+ connect(&serialPort, &SerialPort::pageSwitch, this, &MainWindow::onPageSwitdh);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
MainWindow::~MainWindow()
|
|
@@ -96,3 +97,33 @@ void MainWindow::onUpdateScreen(const QJsonObject &obj)
|
|
|
qint64 duration = timer.elapsed(); // 获取经过的毫秒数
|
|
qint64 duration = timer.elapsed(); // 获取经过的毫秒数
|
|
|
LOG_DEBUG("update screen duration: {}ms", duration);
|
|
LOG_DEBUG("update screen duration: {}ms", duration);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+void MainWindow::onPageSwitdh(int state)
|
|
|
|
|
+{
|
|
|
|
|
+ ProjectManager &projectMgr = AppContext::instance().projectManager();
|
|
|
|
|
+ int canvasCount = projectMgr.canvasCount();
|
|
|
|
|
+ if (canvasCount <= 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ int currentIndex = m_pStackedWidget->currentIndex();
|
|
|
|
|
+ int nextIndex = currentIndex;
|
|
|
|
|
+
|
|
|
|
|
+ if (state < 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 上一页
|
|
|
|
|
+ nextIndex = (currentIndex - 1 + canvasCount) % canvasCount;
|
|
|
|
|
+ LOG_INFO("page up: {}", nextIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (state > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 下一页
|
|
|
|
|
+ nextIndex = (currentIndex + 1) % canvasCount;
|
|
|
|
|
+ LOG_INFO("page down: {}", nextIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ return; // state == 0 不翻页
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ m_pStackedWidget->setCurrentIndex(nextIndex);
|
|
|
|
|
+}
|