From d94627703fbad093d848212d6adbe7b98c9b515e Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 4 Aug 2024 22:15:51 +0800 Subject: [PATCH] update --- CMakeLists.txt | 1 - src/app/main.cpp | 10 +- src/app/syncbox16ch/syncbox16ch.ui | 258 +++++++-- src/zqui/appmgr/appmgr.cpp | 0 src/zqui/appmgr/appmgr.hpp | 54 -- src/zqui/mainpage/mainwindow.cpp | 157 ----- src/zqui/mainpage/mainwindow.h | 73 --- src/zqui/mainpage/mainwindow.ui | 1091 ----------------------------------- src/zqui/zqui.cpp | 79 --- src/zqui/zqui.hpp | 86 --- src/zqui/zqui/appnavibar.cpp | 20 + src/zqui/zqui/appnavibar.h | 25 + src/zqui/zqui/appnavibar.ui | 155 +++++ src/zqui/zqui/mainwindow.cpp | 154 +++++ src/zqui/zqui/mainwindow.h | 73 +++ src/zqui/zqui/mainwindow.ui | 1106 ++++++++++++++++++++++++++++++++++++ src/zqui/zqui/zqui.cpp | 110 ++++ src/zqui/zqui/zqui.hpp | 91 +++ 18 files changed, 1956 insertions(+), 1587 deletions(-) delete mode 100644 src/zqui/appmgr/appmgr.cpp delete mode 100644 src/zqui/appmgr/appmgr.hpp delete mode 100644 src/zqui/mainpage/mainwindow.cpp delete mode 100644 src/zqui/mainpage/mainwindow.h delete mode 100644 src/zqui/mainpage/mainwindow.ui delete mode 100644 src/zqui/zqui.cpp delete mode 100644 src/zqui/zqui.hpp create mode 100644 src/zqui/zqui/appnavibar.cpp create mode 100644 src/zqui/zqui/appnavibar.h create mode 100644 src/zqui/zqui/appnavibar.ui create mode 100644 src/zqui/zqui/mainwindow.cpp create mode 100644 src/zqui/zqui/mainwindow.h create mode 100644 src/zqui/zqui/mainwindow.ui create mode 100644 src/zqui/zqui/zqui.cpp create mode 100644 src/zqui/zqui/zqui.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 041ad98..40aadf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,6 @@ set(PROJECT_SOURCES app.rc ) - add_executable(zfpga_pc WIN32 ${PROJECT_SOURCES} ) diff --git a/src/app/main.cpp b/src/app/main.cpp index 412044a..c8f2bb6 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -18,9 +18,8 @@ #include #include -#include "zqui/appmgr/appmgr.hpp" -#include "zqui/mainpage/mainwindow.h" -#include "zqui/zqui.hpp" +#include "zqui/zqui/mainwindow.h" +#include "zqui/zqui/zqui.hpp" // #include "app/syncbox16ch/syncbox16ch.h" // @@ -37,10 +36,11 @@ int main(int argc, char* argv[]) { WSAStartup(MAKEWORD(2, 2), &wsaData); QApplication a(argc, argv); - AppMgr::ins()->regAppBuilder([](QWidget* p) { return new SyncBox16CH(p); }); + + ZQUI::ins()->regAppBuilder([](QWidget* p) { return new SyncBox16CH(p); }); ZQUI::ins()->initialize(); - DOINUI([]() { ZQUI::ins()->mainW()->setVersionInfo(1, "APP_VERSION", "1.0.0"); }); + // DOINUI([]() { ZQUI::ins()->mainW()->setVersionInfo(1, "APP_VERSION", "1.0.0"); }); return a.exec(); } diff --git a/src/app/syncbox16ch/syncbox16ch.ui b/src/app/syncbox16ch/syncbox16ch.ui index 3b4f075..f4bce80 100644 --- a/src/app/syncbox16ch/syncbox16ch.ui +++ b/src/app/syncbox16ch/syncbox16ch.ui @@ -6,52 +6,228 @@ 0 0 - 400 - 300 + 439 + 323 Form - - - - 80 - 50 - 111 - 41 - - - - PushButton - - - - - - 240 - 120 - 91 - 51 - - - - ... - - - - - - 40 - 170 - 121 - 71 - - - - PushButton - - + + + + + + 1 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 输出模式 + + + + + + + + 1 + 0 + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 输出波形类型 + + + + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 频率(HZ) + + + + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 脉冲宽度(us) + + + + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 脉冲数量 + + + + + + + + 0 + 25 + + + + + + + + Qt::Vertical + + + + 20 + 91 + + + + + + + + + 0 + 50 + + + + 发送 + + + + 20 + 20 + + + + + diff --git a/src/zqui/appmgr/appmgr.cpp b/src/zqui/appmgr/appmgr.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/zqui/appmgr/appmgr.hpp b/src/zqui/appmgr/appmgr.hpp deleted file mode 100644 index dc2b35a..0000000 --- a/src/zqui/appmgr/appmgr.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef std::function appbuilder_fn_t; - -class AppMgr { - public: - appbuilder_fn_t appBuilder; - - public: - static AppMgr *ins() { - static AppMgr instance; - return &instance; - } - - void regAppBuilder(appbuilder_fn_t builder) { appBuilder = builder; } - QWidget *buildApp(QWidget *parent) { - if (appBuilder) return appBuilder(parent); - return nullptr; - } -}; diff --git a/src/zqui/mainpage/mainwindow.cpp b/src/zqui/mainpage/mainwindow.cpp deleted file mode 100644 index 0d8e594..0000000 --- a/src/zqui/mainpage/mainwindow.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include "mainwindow.h" - -#include -#include -#include -#include -#include - -#include "./ui_mainwindow.h" -#include "zqui/base/QFunction.hpp" -#include "zqui/channelmgr/channelmgr.hpp" -// -#include "zqui/appmgr/appmgr.hpp" -#include "zqui/zqui.hpp" -// #include "app/syncbox16ch.h" - -using namespace iflytop; -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { - ui->setupUi(this); - - buildUI(); - ui->serialPortCB->installEventFilter(this); - startTimer(1000); - - ui->version_label_po1->hide(); - ui->version_pos1->hide(); - ui->version_label_po2->hide(); - ui->version_pos2->hide(); - ui->version_label_po3->hide(); - ui->version_pos3->hide(); - - QWidget *app = AppMgr::ins()->buildApp(ui->app_content); - if (app) app->show(); -} - -void MainWindow::buildUI() { - QTSerialChannel *serialch = &ChannelMgr::ins()->serialCh; - - /** - * @brief 指令串口UI - */ - { fillinSerialPort(); } - - ui->serialBaudrateCB->addItem("115200"); - ui->serialBaudrateCB->addItem("500000"); - ui->serialBaudrateCB->addItem("2000000"); - ui->serialBaudrateCB->setCurrentIndex(0); - - connect(ui->serialOpenKey, &QPushButton::clicked, this, [=](bool check) { - // 打开串口 - if (ui->serialOpenKey->text() == "打开") { - serialch->setPortName(ui->serialPortCB->currentText().toStdString()); - serialch->setBaudRate(ui->serialBaudrateCB->currentText().toInt()); - serialch->setDataBits(QSerialPort::Data8); - serialch->setParity(QSerialPort::NoParity); - serialch->setFlowControl(QSerialPort::NoFlowControl); - serialch->setStopBits(QSerialPort::OneStop); - - /** - * @brief 串口打开时,初始化相应参数 - */ - - if (!serialch->open()) { - QMessageBox::about(NULL, "提示", "串口无法打开,串口不存在或已被占??"); - return; - } - ui->serialOpenKey->setText("关闭"); - // 下拉菜单控件使能 - ui->serialBaudrateCB->setEnabled(false); - ui->serialPortCB->setEnabled(false); - } else { - serialch->close(); - ui->serialOpenKey->setText("打开"); - ui->serialBaudrateCB->setEnabled(true); - ui->serialPortCB->setEnabled(true); - } - }); -} - -void MainWindow::on_serialPortCB_customContextMenuRequested(const QPoint &pos) {} - -void MainWindow::setVersionInfo(int pos, QString versionName, QString version) { - - if (pos == 1) { - ui->version_label_po1->setText(versionName); - ui->version_pos1->setText(version); - ui->version_label_po1->show(); - ui->version_pos1->show(); - } else if (pos == 2) { - ui->version_label_po2->setText(versionName); - ui->version_pos2->setText(version); - ui->version_label_po2->show(); - ui->version_pos2->show(); - } else if (pos == 3) { - ui->version_label_po3->setText(versionName); - ui->version_pos3->setText(version); - ui->version_label_po3->show(); - ui->version_pos3->show(); - } -} - -void MainWindow::fillinSerialPort() { - // int curIndex = ui->serialPortCB->currentIndex(); - ui->serialPortCB->clear(); - const auto infos = QSerialPortInfo::availablePorts(); - for (const QSerialPortInfo &info : infos) { - if (info.isBusy()) continue; - ui->serialPortCB->addItem(info.portName()); - } -} -#if 1 -bool MainWindow::eventFilter(QObject *watched, QEvent *event) { - if (event->type() == QEvent::MouseButtonPress) { - if (watched == ui->serialPortCB) { - fillinSerialPort(); - } - } - return QMainWindow::eventFilter(watched, event); -} -#endif - -void MainWindow::timerEvent(QTimerEvent *event) { - // if (ui->serialOpenKey->text() == "打开") { - // fillinSerialPort(); - // } -} - -void MainWindow::iShow(QString content) { - QString info; - info.append(content); - ui->CmdBrowser->append(info); -} -void MainWindow::iClear() { ui->CmdBrowser->clear(); } - -void MainWindow::reportShow(QString content) { - QString info; - info.append(content); - ui->ReportBrowser->append(info); -} -void MainWindow::reportClear() { ui->ReportBrowser->clear(); } - -void MainWindow::binaryShow(QString content) { - QString info; - info.append(content); - ui->BinaryBrowser->append(info); -} -void MainWindow::binaryClear() { ui->BinaryBrowser->clear(); } - -void MainWindow::setConnectedStatus(bool connect) { - if (connect) { - ui->DeviceConnectStateTB->setText("已连接"); - ui->DeviceConnectStateTB->setStyleSheet("color: green"); - } else { - ui->DeviceConnectStateTB->setText("未连接"); - ui->DeviceConnectStateTB->setStyleSheet("color: red"); - } -} diff --git a/src/zqui/mainpage/mainwindow.h b/src/zqui/mainpage/mainwindow.h deleted file mode 100644 index 7c251f2..0000000 --- a/src/zqui/mainpage/mainwindow.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// - -QT_BEGIN_NAMESPACE -namespace Ui { -class MainWindow; -} -QT_END_NAMESPACE - -class MainWindow : public QMainWindow { - Q_OBJECT - - public: - Ui::MainWindow *ui; - - MainWindow(QWidget *parent = nullptr); - ~MainWindow() {}; - - public: - void iShow(QString content); - void iClear(); - - void reportShow(QString content); - void reportClear(); - - void binaryShow(QString content); - void binaryClear(); - void setConnectedStatus(bool connect); - - void setVersionInfo(int pos,QString versionName, QString version); - - private slots: - void on_serialPortCB_customContextMenuRequested(const QPoint &pos); - bool eventFilter(QObject *watched, QEvent *event); - - private: - void buildUI(); - - void fillinSerialPort(); - - private: - void timerEvent(QTimerEvent *event) override; -}; -#endif // MAINWINDOW_H diff --git a/src/zqui/mainpage/mainwindow.ui b/src/zqui/mainpage/mainwindow.ui deleted file mode 100644 index 9ff98d0..0000000 --- a/src/zqui/mainpage/mainwindow.ui +++ /dev/null @@ -1,1091 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 753 - 545 - - - - - 0 - 8 - - - - ZFPGA - - - /* -Aqua Style Sheet for QT Applications -Author: Jaime A. Quiroga P. -Company: GTRONICK -Last updated: 22/01/2019, 07:55. -Available at: https://github.com/GTRONICK/QSS/blob/master/Aqua.qss -*/ -QMainWindow { - background-color:#ececec; -} -QTextEdit { - border-width: 1px; - border-style: solid; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QPlainTextEdit { - border-width: 1px; - border-style: solid; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QToolButton { - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QToolButton:hover{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QToolButton:pressed{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(142,142,142); -} -QPushButton{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QPushButton::default{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QPushButton:hover{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QPushButton:pressed{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(142,142,142); -} -QPushButton:disabled{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: #808086; - padding: 2px; - background-color: rgb(142,142,142); -} -QLineEdit { - border-width: 1px; border-radius: 4px; - border-style: solid; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QLabel { - color: #000000; -} -QLCDNumber { - color: rgb(0, 113, 255, 255); -} -QProgressBar { - text-align: center; - color: rgb(240, 240, 240); - border-width: 1px; - border-radius: 10px; - border-color: rgb(230, 230, 230); - border-style: solid; - background-color:rgb(207,207,207); -} -QProgressBar::chunk { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); - border-radius: 10px; -} -QMenuBar { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); -} -QMenuBar::item { - color: #000000; - spacing: 3px; - padding: 1px 4px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); -} - -QMenuBar::item:selected { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #FFFFFF; -} -QMenu::item:selected { - border-style: solid; - border-top-color: transparent; - border-right-color: transparent; - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - border-bottom-color: transparent; - border-left-width: 2px; - color: #000000; - padding-left:15px; - padding-top:4px; - padding-bottom:4px; - padding-right:7px; -} -QMenu::item { - border-style: solid; - border-top-color: transparent; - border-right-color: transparent; - border-left-color: transparent; - border-bottom-color: transparent; - border-bottom-width: 1px; - color: #000000; - padding-left:17px; - padding-top:4px; - padding-bottom:4px; - padding-right:7px; -} -QTabWidget { - color:rgb(0,0,0); - background-color:#000000; -} -QTabWidget::pane { - border-color: rgb(223,223,223); - background-color:rgb(226,226,226); - border-style: solid; - border-width: 2px; - border-radius: 6px; -} -QTabBar::tab:first { - border-style: solid; - border-left-width:1px; - border-right-width:0px; - border-top-width:1px; - border-bottom-width:1px; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; - color: #000000; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); -} -QTabBar::tab:last { - border-style: solid; - border-width:1px; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-right-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - color: #000000; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); -} -QTabBar::tab { - border-style: solid; - border-top-width:1px; - border-bottom-width:1px; - border-left-width:1px; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - color: #000000; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); -} -QTabBar::tab:selected, QTabBar::tab:last:selected, QTabBar::tab:hover { - border-style: solid; - border-left-width:1px; - border-right-color: transparent; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - color: #FFFFFF; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} - -QTabBar::tab:selected, QTabBar::tab:first:selected, QTabBar::tab:hover { - border-style: solid; - border-left-width:1px; - border-bottom-width:1px; - border-top-width:1px; - border-right-color: transparent; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - color: #FFFFFF; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} - -QCheckBox { - color: #000000; - padding: 2px; -} -QCheckBox:disabled { - color: #808086; - padding: 2px; -} - -QCheckBox:hover { - border-radius:4px; - border-style:solid; - padding-left: 1px; - padding-right: 1px; - padding-bottom: 1px; - padding-top: 1px; - border-width:1px; - border-color: transparent; -} -QCheckBox::indicator:checked { - - height: 10px; - width: 10px; - border-style:solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #000000; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QCheckBox::indicator:unchecked { - - height: 10px; - width: 10px; - border-style:solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #000000; -} -QRadioButton { - color: 000000; - padding: 1px; -} -QRadioButton::indicator:checked { - height: 10px; - width: 10px; - border-style:solid; - border-radius:5px; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #a9b7c6; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QRadioButton::indicator:!checked { - height: 10px; - width: 10px; - border-style:solid; - border-radius:5px; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #a9b7c6; - background-color: transparent; -} -QStatusBar { - color:#027f7f; -} -QSpinBox { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QDoubleSpinBox { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QTimeEdit { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QDateTimeEdit { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QDateEdit { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} - -QToolBox { - color: #a9b7c6; - background-color:#000000; -} -QToolBox::tab { - color: #a9b7c6; - background-color:#000000; -} -QToolBox::tab:selected { - color: #FFFFFF; - background-color:#000000; -} -QScrollArea { - color: #FFFFFF; - background-color:#000000; -} -QSlider::groove:horizontal { - height: 5px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QSlider::groove:vertical { - width: 5px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QSlider::handle:horizontal { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - width: 12px; - margin: -5px 0; - border-radius: 7px; -} -QSlider::handle:vertical { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - height: 12px; - margin: 0 -5px; - border-radius: 7px; -} -QSlider::add-page:horizontal { - background: rgb(181,181,181); -} -QSlider::add-page:vertical { - background: rgb(181,181,181); -} -QSlider::sub-page:horizontal { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QSlider::sub-page:vertical { - background-color: qlineargradient(spread:pad, y1:0.5, x1:1, y2:0.5, x2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QScrollBar:horizontal { - max-height: 20px; - border: 1px transparent grey; - margin: 0px 20px 0px 20px; -} -QScrollBar:vertical { - max-width: 20px; - border: 1px transparent grey; - margin: 20px 0px 20px 0px; -} -QScrollBar::handle:horizontal { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - border-radius: 7px; - min-width: 25px; -} -QScrollBar::handle:horizontal:hover { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(147, 200, 200); - border-radius: 7px; - min-width: 25px; -} -QScrollBar::handle:vertical { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - border-radius: 7px; - min-height: 25px; -} -QScrollBar::handle:vertical:hover { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(147, 200, 200); - border-radius: 7px; - min-height: 25px; -} -QScrollBar::add-line:horizontal { - border: 2px transparent grey; - border-top-right-radius: 7px; - border-bottom-right-radius: 7px; - background: rgba(34, 142, 255, 255); - width: 20px; - subcontrol-position: right; - subcontrol-origin: margin; -} -QScrollBar::add-line:horizontal:pressed { - border: 2px transparent grey; - border-top-right-radius: 7px; - border-bottom-right-radius: 7px; - background: rgb(181,181,181); - width: 20px; - subcontrol-position: right; - subcontrol-origin: margin; -} -QScrollBar::add-line:vertical { - border: 2px transparent grey; - border-bottom-left-radius: 7px; - border-bottom-right-radius: 7px; - background: rgba(34, 142, 255, 255); - height: 20px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} -QScrollBar::add-line:vertical:pressed { - border: 2px transparent grey; - border-bottom-left-radius: 7px; - border-bottom-right-radius: 7px; - background: rgb(181,181,181); - height: 20px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} -QScrollBar::sub-line:horizontal { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-bottom-left-radius: 7px; - background: rgba(34, 142, 255, 255); - width: 20px; - subcontrol-position: left; - subcontrol-origin: margin; -} -QScrollBar::sub-line:horizontal:pressed { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-bottom-left-radius: 7px; - background: rgb(181,181,181); - width: 20px; - subcontrol-position: left; - subcontrol-origin: margin; -} -QScrollBar::sub-line:vertical { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-top-right-radius: 7px; - background: rgba(34, 142, 255, 255); - height: 20px; - subcontrol-position: top; - subcontrol-origin: margin; -} -QScrollBar::sub-line:vertical:pressed { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-top-right-radius: 7px; - background: rgb(181,181,181); - height: 20px; - subcontrol-position: top; - subcontrol-origin: margin; -} -QScrollBar::left-arrow:horizontal { - border: 1px transparent grey; - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::right-arrow:horizontal { - border: 1px transparent grey; - border-top-right-radius: 3px; - border-bottom-right-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::up-arrow:vertical { - border: 1px transparent grey; - border-top-left-radius: 3px; - border-top-right-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::down-arrow:vertical { - border: 1px transparent grey; - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { - background: none; -} -QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { - background: none; -} -QGroupBox { - border-color: rgb(156, 156, 156); - border-width: 1px; - border-style: solid; - border-radius:8px; - padding: 10px 0px 0px 0px; - -} - -QGroupBox:title { - subcontrol-origin: margin; - left: 7px; - padding: 0px 0px 0px 0px; -} - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 5 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 200 - 0 - - - - - 200 - 16777215 - - - - - 0 - - - 0 - - - - - - 16777215 - 16777215 - - - - 端口 - - - - - - 波特率 - - - - - - - 串口号 - - - - - - - 打开 - - - - - - - - - - QComboBox::AdjustToContents - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - false - - - 状态 - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - 设备连接状态 - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - 2 - - - - - - - - - - 软件信息 - - - - - - - 1 - 0 - - - - - 0 - 25 - - - - - - - - - 1 - 0 - - - - - - - - - - - - 1 - 0 - - - - - 0 - 25 - - - - - - - - - 1 - 0 - - - - - - - - - - - - 1 - 0 - - - - - 0 - 25 - - - - - - - - - 1 - 0 - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - <a href="www.iflytop.com">www.iflytop.com - - - true - - - - - - - - - - - 4 - 0 - - - - - DengXian - 9 - - - - - - - - 0 - - - QLayout::SetNoConstraint - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 4 - - - - - - - - - 0 - 2 - - - - QTabWidget::North - - - QTabWidget::Rounded - - - 0 - - - Qt::ElideLeft - - - false - - - false - - - - 指令交互 - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - 上报数据流 - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - 二进制流 - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - content - sidebar - - - - - - - true - - - 专业模式 - - - 专业模式 - - - - - - diff --git a/src/zqui/zqui.cpp b/src/zqui/zqui.cpp deleted file mode 100644 index c0e98df..0000000 --- a/src/zqui/zqui.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "zqui.hpp" - -#include "zqui/mainpage/mainwindow.h" - -using namespace std; -#define TAG "ZQUI" - -/*********************************************************************************************************************** - * PreviewShow * - ***********************************************************************************************************************/ - -ZQUI *ZQUI::ins() { - static ZQUI instance; - return &instance; -} - -void ZQUI::iShow(const char *fmt, ...) { - va_list args; - va_start(args, fmt); - char buf[1024] = {0}; - vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - QString text(buf); - pmainW->iShow(text); -} -void ZQUI::iRawShow(const char *fmt, ...) { - va_list args; - va_start(args, fmt); - char buf[1024] = {0}; - vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - QString text(buf); - pmainW->iShow(text); -} -void ZQUI::iClear() { pmainW->iClear(); } - -void ZQUI::reportShow(const char *fmt, ...) { - va_list args; - va_start(args, fmt); - char buf[1024] = {0}; - vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - QString text(buf); - pmainW->reportShow(text); -} -void ZQUI::reportClear() { pmainW->reportClear(); } - -void ZQUI::binaryShow(const char *fmt, ...) { - va_list args; - va_start(args, fmt); - char buf[1024] = {0}; - vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - QString text(buf); - pmainW->binaryShow(text); -} -void ZQUI::binaryClear() { pmainW->binaryClear(); } - -void ZQUI::initialize() { - qRegisterMetaType("int32_t"); - qRegisterMetaType("uint32_t"); - qRegisterMetaType("float"); - qRegisterMetaType>("function"); - qRegisterMetaType("QFunction"); - connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); - - pmainW = new MainWindow(); - pmainW->show(); -} -void ZQUI::doinui(function dowhat) { - emit doinui_signal(QFunction([dowhat]() { - if (dowhat) dowhat(); - })); -} -void ZQUI::doinui_slot(QFunction func) { - if (func.get()) func.get()(); -} - -void ZQUI::setDeviceConnectedStatus(bool connect) { pmainW->setConnectedStatus(connect); } diff --git a/src/zqui/zqui.hpp b/src/zqui/zqui.hpp deleted file mode 100644 index 1e9a559..0000000 --- a/src/zqui/zqui.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "base/QFunction.hpp" -#include "mainpage/mainwindow.h" - -class ZQUI : public QObject { - Q_OBJECT - public: - typedef std::function display_fn_t; - typedef std::function display_clear_fn_t; - MainWindow *pmainW = nullptr; - ; - - public: - static ZQUI *ins(); - - void initialize(); - - void doinui(std::function dowhat); - - void iShow(const char *fmt, ...); - void iRawShow(const char *fmt, ...); - void iClear(); - - void reportShow(const char *fmt, ...); - void reportClear(); - - void binaryShow(const char *fmt, ...); - void binaryClear(); - - void setDeviceConnectedStatus(bool connect); - - MainWindow *mainW() { return pmainW; } - - private slots: - void doinui_slot(QFunction); - - signals: - void doinui_signal(QFunction); -}; - -#define ISHOW(fmt, ...) ZQUI::ins()->iShow(fmt, ##__VA_ARGS__) -#define IRSHOW(fmt, ...) ZQUI::ins()->iRawShow(fmt, ##__VA_ARGS__) -#define ICLEAR() ZQUI::ins()->iClear() - -#define RSHOW(fmt, ...) ZQUI::ins()->reportShow(fmt, ##__VA_ARGS__) -#define RCLEAR() ZQUI::ins()->reportClear() - -#define BSHOW(fmt, ...) ZQUI::ins()->binaryShow(fmt, ##__VA_ARGS__) -#define BCLEAR() ZQUI::ins()->binaryClear() - -#define DOINUI(fn) ZQUI::ins()->doinui(fn) \ No newline at end of file diff --git a/src/zqui/zqui/appnavibar.cpp b/src/zqui/zqui/appnavibar.cpp new file mode 100644 index 0000000..266f504 --- /dev/null +++ b/src/zqui/zqui/appnavibar.cpp @@ -0,0 +1,20 @@ +#include "appnavibar.h" +#include "ui_appnavibar.h" + +AppNaviBar::AppNaviBar(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::AppNaviBar) +{ + ui->setupUi(this); +} + +AppNaviBar::~AppNaviBar() +{ + delete ui; +} + +void AppNaviBar::on_App0_released() +{ + +} + diff --git a/src/zqui/zqui/appnavibar.h b/src/zqui/zqui/appnavibar.h new file mode 100644 index 0000000..124f606 --- /dev/null +++ b/src/zqui/zqui/appnavibar.h @@ -0,0 +1,25 @@ +#ifndef APPNAVIBAR_H +#define APPNAVIBAR_H + +#include + +namespace Ui { +class AppNaviBar; +} + +class AppNaviBar : public QMainWindow +{ + Q_OBJECT + +public: + explicit AppNaviBar(QWidget *parent = nullptr); + ~AppNaviBar(); + +private slots: + void on_App0_released(); + +public: + Ui::AppNaviBar *ui; +}; + +#endif // APPNAVIBAR_H diff --git a/src/zqui/zqui/appnavibar.ui b/src/zqui/zqui/appnavibar.ui new file mode 100644 index 0000000..17332d9 --- /dev/null +++ b/src/zqui/zqui/appnavibar.ui @@ -0,0 +1,155 @@ + + + AppNaviBar + + + + 0 + 0 + 595 + 262 + + + + 产品梦工厂 + + + + + + + + 0 + 0 + + + + + Agency FB + 20 + + + + background-color: rgb(166, 254, 255); + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 20 + + + + background-color: rgb(166, 254, 255); + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 20 + + + + background-color: rgb(166, 254, 255); + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 20 + + + + background-color: rgb(166, 254, 255); + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 20 + + + + background-color: rgb(166, 254, 255); + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 20 + + + + background-color: rgb(166, 254, 255); + + + + + + + + + + + + diff --git a/src/zqui/zqui/mainwindow.cpp b/src/zqui/zqui/mainwindow.cpp new file mode 100644 index 0000000..f39137b --- /dev/null +++ b/src/zqui/zqui/mainwindow.cpp @@ -0,0 +1,154 @@ +#include "mainwindow.h" + +#include +#include +#include +#include +#include + +#include "./ui_mainwindow.h" +#include "zqui/base/QFunction.hpp" +#include "zqui/channelmgr/channelmgr.hpp" + + + +using namespace iflytop; +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { + ui->setupUi(this); + + buildUI(); + ui->serialPortCB->installEventFilter(this); + startTimer(1000); + + ui->version_label_po1->hide(); + ui->version_pos1->hide(); + ui->version_label_po2->hide(); + ui->version_pos2->hide(); + ui->version_label_po3->hide(); + ui->version_pos3->hide(); + + +} + +void MainWindow::buildUI() { + QTSerialChannel *serialch = &ChannelMgr::ins()->serialCh; + + /** + * @brief 指令串口UI + */ + { fillinSerialPort(); } + + ui->serialBaudrateCB->addItem("115200"); + ui->serialBaudrateCB->addItem("500000"); + ui->serialBaudrateCB->addItem("2000000"); + ui->serialBaudrateCB->setCurrentIndex(0); + + connect(ui->serialOpenKey, &QPushButton::clicked, this, [=](bool check) { + // 打开串口 + if (ui->serialOpenKey->text() == "打开") { + serialch->setPortName(ui->serialPortCB->currentText().toStdString()); + serialch->setBaudRate(ui->serialBaudrateCB->currentText().toInt()); + serialch->setDataBits(QSerialPort::Data8); + serialch->setParity(QSerialPort::NoParity); + serialch->setFlowControl(QSerialPort::NoFlowControl); + serialch->setStopBits(QSerialPort::OneStop); + + /** + * @brief 串口打开时,初始化相应参数 + */ + + if (!serialch->open()) { + QMessageBox::about(NULL, "提示", "串口无法打开,串口不存在或已被占??"); + return; + } + ui->serialOpenKey->setText("关闭"); + // 下拉菜单控件使能 + ui->serialBaudrateCB->setEnabled(false); + ui->serialPortCB->setEnabled(false); + } else { + serialch->close(); + ui->serialOpenKey->setText("打开"); + ui->serialBaudrateCB->setEnabled(true); + ui->serialPortCB->setEnabled(true); + } + }); +} + +void MainWindow::on_serialPortCB_customContextMenuRequested(const QPoint &pos) {} + +void MainWindow::setVersionInfo(int pos, QString versionName, QString version) { + + if (pos == 1) { + ui->version_label_po1->setText(versionName); + ui->version_pos1->setText(version); + ui->version_label_po1->show(); + ui->version_pos1->show(); + } else if (pos == 2) { + ui->version_label_po2->setText(versionName); + ui->version_pos2->setText(version); + ui->version_label_po2->show(); + ui->version_pos2->show(); + } else if (pos == 3) { + ui->version_label_po3->setText(versionName); + ui->version_pos3->setText(version); + ui->version_label_po3->show(); + ui->version_pos3->show(); + } +} + +void MainWindow::fillinSerialPort() { + // int curIndex = ui->serialPortCB->currentIndex(); + ui->serialPortCB->clear(); + const auto infos = QSerialPortInfo::availablePorts(); + for (const QSerialPortInfo &info : infos) { + if (info.isBusy()) continue; + ui->serialPortCB->addItem(info.portName()); + } +} +#if 1 +bool MainWindow::eventFilter(QObject *watched, QEvent *event) { + if (event->type() == QEvent::MouseButtonPress) { + if (watched == ui->serialPortCB) { + fillinSerialPort(); + } + } + return QMainWindow::eventFilter(watched, event); +} +#endif + +void MainWindow::timerEvent(QTimerEvent *event) { + // if (ui->serialOpenKey->text() == "打开") { + // fillinSerialPort(); + // } +} + +void MainWindow::iShow(QString content) { + QString info; + info.append(content); + ui->CmdBrowser->append(info); +} +void MainWindow::iClear() { ui->CmdBrowser->clear(); } + +void MainWindow::reportShow(QString content) { + QString info; + info.append(content); + ui->ReportBrowser->append(info); +} +void MainWindow::reportClear() { ui->ReportBrowser->clear(); } + +void MainWindow::binaryShow(QString content) { + QString info; + info.append(content); + ui->BinaryBrowser->append(info); +} +void MainWindow::binaryClear() { ui->BinaryBrowser->clear(); } + +void MainWindow::setConnectedStatus(bool connect) { + if (connect) { + ui->DeviceConnectStateTB->setText("已连接"); + ui->DeviceConnectStateTB->setStyleSheet("color: green"); + } else { + ui->DeviceConnectStateTB->setText("未连接"); + ui->DeviceConnectStateTB->setStyleSheet("color: red"); + } +} diff --git a/src/zqui/zqui/mainwindow.h b/src/zqui/zqui/mainwindow.h new file mode 100644 index 0000000..7c251f2 --- /dev/null +++ b/src/zqui/zqui/mainwindow.h @@ -0,0 +1,73 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// + +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +class MainWindow : public QMainWindow { + Q_OBJECT + + public: + Ui::MainWindow *ui; + + MainWindow(QWidget *parent = nullptr); + ~MainWindow() {}; + + public: + void iShow(QString content); + void iClear(); + + void reportShow(QString content); + void reportClear(); + + void binaryShow(QString content); + void binaryClear(); + void setConnectedStatus(bool connect); + + void setVersionInfo(int pos,QString versionName, QString version); + + private slots: + void on_serialPortCB_customContextMenuRequested(const QPoint &pos); + bool eventFilter(QObject *watched, QEvent *event); + + private: + void buildUI(); + + void fillinSerialPort(); + + private: + void timerEvent(QTimerEvent *event) override; +}; +#endif // MAINWINDOW_H diff --git a/src/zqui/zqui/mainwindow.ui b/src/zqui/zqui/mainwindow.ui new file mode 100644 index 0000000..11a3419 --- /dev/null +++ b/src/zqui/zqui/mainwindow.ui @@ -0,0 +1,1106 @@ + + + MainWindow + + + + 0 + 0 + 753 + 545 + + + + + 0 + 8 + + + + 产品梦工厂 + + + /* +Aqua Style Sheet for QT Applications +Author: Jaime A. Quiroga P. +Company: GTRONICK +Last updated: 22/01/2019, 07:55. +Available at: https://github.com/GTRONICK/QSS/blob/master/Aqua.qss +*/ +QMainWindow { + background-color:#ececec; +} +QTextEdit { + border-width: 1px; + border-style: solid; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QPlainTextEdit { + border-width: 1px; + border-style: solid; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QToolButton { + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QToolButton:hover{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QToolButton:pressed{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(142,142,142); +} +QPushButton{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QPushButton::default{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QPushButton:hover{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QPushButton:pressed{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(142,142,142); +} +QPushButton:disabled{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: #808086; + padding: 2px; + background-color: rgb(142,142,142); +} +QLineEdit { + border-width: 1px; border-radius: 4px; + border-style: solid; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QLabel { + color: #000000; +} +QLCDNumber { + color: rgb(0, 113, 255, 255); +} +QProgressBar { + text-align: center; + color: rgb(240, 240, 240); + border-width: 1px; + border-radius: 10px; + border-color: rgb(230, 230, 230); + border-style: solid; + background-color:rgb(207,207,207); +} +QProgressBar::chunk { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); + border-radius: 10px; +} +QMenuBar { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); +} +QMenuBar::item { + color: #000000; + spacing: 3px; + padding: 1px 4px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); +} + +QMenuBar::item:selected { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #FFFFFF; +} +QMenu::item:selected { + border-style: solid; + border-top-color: transparent; + border-right-color: transparent; + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + border-bottom-color: transparent; + border-left-width: 2px; + color: #000000; + padding-left:15px; + padding-top:4px; + padding-bottom:4px; + padding-right:7px; +} +QMenu::item { + border-style: solid; + border-top-color: transparent; + border-right-color: transparent; + border-left-color: transparent; + border-bottom-color: transparent; + border-bottom-width: 1px; + color: #000000; + padding-left:17px; + padding-top:4px; + padding-bottom:4px; + padding-right:7px; +} +QTabWidget { + color:rgb(0,0,0); + background-color:#000000; +} +QTabWidget::pane { + border-color: rgb(223,223,223); + background-color:rgb(226,226,226); + border-style: solid; + border-width: 2px; + border-radius: 6px; +} +QTabBar::tab:first { + border-style: solid; + border-left-width:1px; + border-right-width:0px; + border-top-width:1px; + border-bottom-width:1px; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + color: #000000; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); +} +QTabBar::tab:last { + border-style: solid; + border-width:1px; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-right-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + color: #000000; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); +} +QTabBar::tab { + border-style: solid; + border-top-width:1px; + border-bottom-width:1px; + border-left-width:1px; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + color: #000000; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); +} +QTabBar::tab:selected, QTabBar::tab:last:selected, QTabBar::tab:hover { + border-style: solid; + border-left-width:1px; + border-right-color: transparent; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + color: #FFFFFF; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} + +QTabBar::tab:selected, QTabBar::tab:first:selected, QTabBar::tab:hover { + border-style: solid; + border-left-width:1px; + border-bottom-width:1px; + border-top-width:1px; + border-right-color: transparent; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + color: #FFFFFF; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} + +QCheckBox { + color: #000000; + padding: 2px; +} +QCheckBox:disabled { + color: #808086; + padding: 2px; +} + +QCheckBox:hover { + border-radius:4px; + border-style:solid; + padding-left: 1px; + padding-right: 1px; + padding-bottom: 1px; + padding-top: 1px; + border-width:1px; + border-color: transparent; +} +QCheckBox::indicator:checked { + + height: 10px; + width: 10px; + border-style:solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #000000; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QCheckBox::indicator:unchecked { + + height: 10px; + width: 10px; + border-style:solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #000000; +} +QRadioButton { + color: 000000; + padding: 1px; +} +QRadioButton::indicator:checked { + height: 10px; + width: 10px; + border-style:solid; + border-radius:5px; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #a9b7c6; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QRadioButton::indicator:!checked { + height: 10px; + width: 10px; + border-style:solid; + border-radius:5px; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #a9b7c6; + background-color: transparent; +} +QStatusBar { + color:#027f7f; +} +QSpinBox { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QDoubleSpinBox { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QTimeEdit { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QDateTimeEdit { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QDateEdit { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} + +QToolBox { + color: #a9b7c6; + background-color:#000000; +} +QToolBox::tab { + color: #a9b7c6; + background-color:#000000; +} +QToolBox::tab:selected { + color: #FFFFFF; + background-color:#000000; +} +QScrollArea { + color: #FFFFFF; + background-color:#000000; +} +QSlider::groove:horizontal { + height: 5px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QSlider::groove:vertical { + width: 5px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QSlider::handle:horizontal { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + width: 12px; + margin: -5px 0; + border-radius: 7px; +} +QSlider::handle:vertical { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + height: 12px; + margin: 0 -5px; + border-radius: 7px; +} +QSlider::add-page:horizontal { + background: rgb(181,181,181); +} +QSlider::add-page:vertical { + background: rgb(181,181,181); +} +QSlider::sub-page:horizontal { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QSlider::sub-page:vertical { + background-color: qlineargradient(spread:pad, y1:0.5, x1:1, y2:0.5, x2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QScrollBar:horizontal { + max-height: 20px; + border: 1px transparent grey; + margin: 0px 20px 0px 20px; +} +QScrollBar:vertical { + max-width: 20px; + border: 1px transparent grey; + margin: 20px 0px 20px 0px; +} +QScrollBar::handle:horizontal { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + border-radius: 7px; + min-width: 25px; +} +QScrollBar::handle:horizontal:hover { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(147, 200, 200); + border-radius: 7px; + min-width: 25px; +} +QScrollBar::handle:vertical { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + border-radius: 7px; + min-height: 25px; +} +QScrollBar::handle:vertical:hover { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(147, 200, 200); + border-radius: 7px; + min-height: 25px; +} +QScrollBar::add-line:horizontal { + border: 2px transparent grey; + border-top-right-radius: 7px; + border-bottom-right-radius: 7px; + background: rgba(34, 142, 255, 255); + width: 20px; + subcontrol-position: right; + subcontrol-origin: margin; +} +QScrollBar::add-line:horizontal:pressed { + border: 2px transparent grey; + border-top-right-radius: 7px; + border-bottom-right-radius: 7px; + background: rgb(181,181,181); + width: 20px; + subcontrol-position: right; + subcontrol-origin: margin; +} +QScrollBar::add-line:vertical { + border: 2px transparent grey; + border-bottom-left-radius: 7px; + border-bottom-right-radius: 7px; + background: rgba(34, 142, 255, 255); + height: 20px; + subcontrol-position: bottom; + subcontrol-origin: margin; +} +QScrollBar::add-line:vertical:pressed { + border: 2px transparent grey; + border-bottom-left-radius: 7px; + border-bottom-right-radius: 7px; + background: rgb(181,181,181); + height: 20px; + subcontrol-position: bottom; + subcontrol-origin: margin; +} +QScrollBar::sub-line:horizontal { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-bottom-left-radius: 7px; + background: rgba(34, 142, 255, 255); + width: 20px; + subcontrol-position: left; + subcontrol-origin: margin; +} +QScrollBar::sub-line:horizontal:pressed { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-bottom-left-radius: 7px; + background: rgb(181,181,181); + width: 20px; + subcontrol-position: left; + subcontrol-origin: margin; +} +QScrollBar::sub-line:vertical { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-top-right-radius: 7px; + background: rgba(34, 142, 255, 255); + height: 20px; + subcontrol-position: top; + subcontrol-origin: margin; +} +QScrollBar::sub-line:vertical:pressed { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-top-right-radius: 7px; + background: rgb(181,181,181); + height: 20px; + subcontrol-position: top; + subcontrol-origin: margin; +} +QScrollBar::left-arrow:horizontal { + border: 1px transparent grey; + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::right-arrow:horizontal { + border: 1px transparent grey; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::up-arrow:vertical { + border: 1px transparent grey; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::down-arrow:vertical { + border: 1px transparent grey; + border-bottom-left-radius: 3px; + border-bottom-right-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { + background: none; +} +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} +QGroupBox { + border-color: rgb(156, 156, 156); + border-width: 1px; + border-style: solid; + border-radius:8px; + padding: 10px 0px 0px 0px; + +} + +QGroupBox:title { + subcontrol-origin: margin; + left: 7px; + padding: 0px 0px 0px 0px; +} + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 5 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 200 + 0 + + + + + 200 + 16777215 + + + + #sidebar{ +background-color: rgb(245, 245, 245); +} + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 16777215 + 16777215 + + + + 端口 + + + + + + 波特率 + + + + + + + 串口号 + + + + + + + 打开 + + + + + + + + + + QComboBox::AdjustToContents + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + + 状态 + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 设备连接状态 + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 2 + + + + + + + + + + 软件信息 + + + + + + + 1 + 0 + + + + + 0 + 25 + + + + + + + + + 1 + 0 + + + + + + + + + + + + 1 + 0 + + + + + 0 + 25 + + + + + + + + + 1 + 0 + + + + + + + + + + + + 1 + 0 + + + + + 0 + 25 + + + + + + + + + 1 + 0 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + <a href="www.iflytop.com">www.iflytop.com + + + true + + + + + + + + + + + 4 + 0 + + + + + DengXian + 9 + + + + + + + + 0 + + + QLayout::SetNoConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 4 + + + + APP + + + + + + + + 0 + 2 + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 1 + + + Qt::ElideLeft + + + false + + + false + + + + 指令交互 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + 上报数据流 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + 二进制流 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + content + sidebar + + + + + + + true + + + 专业模式 + + + 专业模式 + + + + + + diff --git a/src/zqui/zqui/zqui.cpp b/src/zqui/zqui/zqui.cpp new file mode 100644 index 0000000..2577984 --- /dev/null +++ b/src/zqui/zqui/zqui.cpp @@ -0,0 +1,110 @@ +#include "zqui.hpp" + +#include "ui_appnavibar.h" +#include "ui_mainwindow.h" +// +#include "appnavibar.h" +#include "mainwindow.h" + +using namespace std; +#define TAG "ZQUI" + +/*********************************************************************************************************************** + * PreviewShow * + ***********************************************************************************************************************/ + +ZQUI *ZQUI::ins() { + static ZQUI instance; + return &instance; +} + +void ZQUI::iShow(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + char buf[1024] = {0}; + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + QString text(buf); + pmainW->iShow(text); +} +void ZQUI::iRawShow(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + char buf[1024] = {0}; + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + QString text(buf); + pmainW->iShow(text); +} +void ZQUI::iClear() { pmainW->iClear(); } + +void ZQUI::reportShow(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + char buf[1024] = {0}; + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + QString text(buf); + pmainW->reportShow(text); +} +void ZQUI::reportClear() { pmainW->reportClear(); } + +void ZQUI::binaryShow(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + char buf[1024] = {0}; + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + QString text(buf); + pmainW->binaryShow(text); +} +void ZQUI::binaryClear() { pmainW->binaryClear(); } + +void ZQUI::initialize() { + qRegisterMetaType("int32_t"); + qRegisterMetaType("uint32_t"); + qRegisterMetaType("float"); + qRegisterMetaType>("function"); + qRegisterMetaType("QFunction"); + connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); + +#if 0 + AppNaviBar *appNaviBar = new AppNaviBar(); + appNaviBar->show(); + pmainW = new MainWindow(); + + + appNaviBar->ui->App0->setText("十六路同步盒"); + appNaviBar->ui->App1->setText(""); + appNaviBar->ui->App2->setText(""); + appNaviBar->ui->App3->setText(""); + appNaviBar->ui->App4->setText(""); + appNaviBar->ui->App5->setText(""); + + connect(appNaviBar->ui->App0, &QPushButton::clicked, this, [=](bool check) { + QWidget *app = appBuilder(pmainW->ui->app_content); + pmainW->show(); + delete appNaviBar; + }); +#endif + pmainW = new MainWindow(); + DOINUI([this]() { + QVBoxLayout *layout = new QVBoxLayout(pmainW->ui->app_content); + layout->setObjectName(QString::fromUtf8("layout")); + layout->setContentsMargins(0, -1, -1, 0); + + QWidget *app = appBuilder(pmainW->ui->app_content); + layout->addWidget(app); + pmainW->show(); + }); +} +void ZQUI::doinui(function dowhat) { + emit doinui_signal(QFunction([dowhat]() { + if (dowhat) dowhat(); + })); +} +void ZQUI::doinui_slot(QFunction func) { + if (func.get()) func.get()(); +} + +void ZQUI::setDeviceConnectedStatus(bool connect) { pmainW->setConnectedStatus(connect); } diff --git a/src/zqui/zqui/zqui.hpp b/src/zqui/zqui/zqui.hpp new file mode 100644 index 0000000..be25c28 --- /dev/null +++ b/src/zqui/zqui/zqui.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mainwindow.h" +#include "zqui/base/QFunction.hpp" + +typedef std::function appbuilder_fn_t; + +class ZQUI : public QObject { + Q_OBJECT + public: + typedef std::function display_fn_t; + typedef std::function display_clear_fn_t; + MainWindow *pmainW = nullptr; + + appbuilder_fn_t appBuilder; + + public: + static ZQUI *ins(); + + void initialize(); + + void doinui(std::function dowhat); + + void iShow(const char *fmt, ...); + void iRawShow(const char *fmt, ...); + void iClear(); + + void reportShow(const char *fmt, ...); + void reportClear(); + + void binaryShow(const char *fmt, ...); + void binaryClear(); + + void setDeviceConnectedStatus(bool connect); + + void regAppBuilder(appbuilder_fn_t builder) { appBuilder = builder; } + + MainWindow *mainW() { return pmainW; } + + private slots: + void doinui_slot(QFunction); + + signals: + void doinui_signal(QFunction); +}; + +#define ISHOW(fmt, ...) ZQUI::ins()->iShow(fmt, ##__VA_ARGS__) +#define IRSHOW(fmt, ...) ZQUI::ins()->iRawShow(fmt, ##__VA_ARGS__) +#define ICLEAR() ZQUI::ins()->iClear() + +#define RSHOW(fmt, ...) ZQUI::ins()->reportShow(fmt, ##__VA_ARGS__) +#define RCLEAR() ZQUI::ins()->reportClear() + +#define BSHOW(fmt, ...) ZQUI::ins()->binaryShow(fmt, ##__VA_ARGS__) +#define BCLEAR() ZQUI::ins()->binaryClear() + +#define DOINUI(fn) ZQUI::ins()->doinui(fn) \ No newline at end of file