11 changed files with 266 additions and 33 deletions
-
4.vscode/settings.json
-
2CMakeLists.txt
-
11libzqt/zui/z_function_list_box.cpp
-
69libzqt/zui/z_reg_table_list_box.cpp
-
120libzqt/zui/z_reg_table_list_box.hpp
-
7libzqt/zui/zq_vtab_page.cpp
-
4libzqt/zui/zq_vtab_page.hpp
-
5libzqt/zui/zui.hpp
-
30mainwindow.cpp
-
46mainwindow.ui
-
1src/main.cpp
@ -0,0 +1,69 @@ |
|||
#include "z_reg_table_list_box.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
/***********************************************************************************************************************
|
|||
* ZRegItem * |
|||
***********************************************************************************************************************/ |
|||
ZRegItem::ZRegItem(QWidget *parent, QString &title, int addr, ZRegItem::reg_flag_t flag) : QFrame(parent) { |
|||
m_layout = new QHBoxLayout(parent); |
|||
this->setLayout(m_layout); |
|||
m_layout->setMargin(0); |
|||
// m_layout->setSpacing(0);
|
|||
|
|||
m_horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); |
|||
m_lable = new QLabel(title, this); |
|||
m_val = new QLineEdit(this); |
|||
m_writeButton = new QPushButton("写", this); |
|||
m_readButton = new QPushButton("读", this); |
|||
|
|||
// m_lable->setAlignment(Qt::AlignRight);
|
|||
|
|||
m_lable->setMinimumSize(50, 30); |
|||
m_val->setMinimumSize(100, 30); |
|||
m_writeButton->setMinimumSize(100, 30); |
|||
m_readButton->setMinimumSize(100, 30); |
|||
|
|||
m_layout->addWidget(m_lable); |
|||
m_layout->addWidget(m_val); |
|||
m_layout->addItem(m_horizontalSpacer); |
|||
m_layout->addWidget(m_readButton); |
|||
m_layout->addWidget(m_writeButton); |
|||
} |
|||
/***********************************************************************************************************************
|
|||
* ZRegTableList * |
|||
***********************************************************************************************************************/ |
|||
ZRegTableList::ZRegTableList(QWidget *parent, const QString &title) : QGroupBox(title) { |
|||
// fatherLayout
|
|||
m_layout = new QVBoxLayout(this); |
|||
this->setLayout(m_layout); |
|||
parent->layout()->addWidget(this); |
|||
|
|||
// add FunctionList to
|
|||
m_funcBox = new ZQFunctionListBox(this, "", 4); |
|||
m_funcBox->newFunc("读全部", {}, [this](int argn, const char **args) { |
|||
for (auto &item : m_regMap) { |
|||
} |
|||
}); |
|||
m_layout->addWidget(m_funcBox); |
|||
|
|||
// add box to parent
|
|||
m_regBox = new QGroupBox("寄存器列表", this); |
|||
m_regBoxLayout = new QVBoxLayout(this); |
|||
m_regBox->setLayout(m_regBoxLayout); |
|||
|
|||
m_layout->addWidget(m_regBox); |
|||
|
|||
} |
|||
|
|||
void ZRegTableList::regOnException(function<void(const zexception &e)> onException) {} |
|||
void ZRegTableList::addReg(QString title, int addr, ZRegItem::reg_flag_t flag) { |
|||
ZRegItem *item = new ZRegItem(this, title, addr, flag); |
|||
m_regBoxLayout->addWidget(item); |
|||
m_regMap[title] = item; |
|||
} |
|||
|
|||
void ZRegTableList::addSpacer() { |
|||
m_layout->addItem(new QSpacerItem(20, 100, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
|||
m_regBoxLayout->addItem(new QSpacerItem(20, 100, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
|||
} |
@ -0,0 +1,120 @@ |
|||
#pragma once
|
|||
|
|||
#include <QDateTime>
|
|||
#include <QMainWindow>
|
|||
#include <QMessageBox>
|
|||
#include <QObject>
|
|||
#include <QtConcurrent>
|
|||
#include <QtCore/QVariant>
|
|||
#include <QtSerialPort/QSerialPort>
|
|||
#include <QtSerialPort/QSerialPortInfo>
|
|||
#include <QtWidgets/QAction>
|
|||
#include <QtWidgets/QApplication>
|
|||
#include <QtWidgets/QComboBox>
|
|||
#include <QtWidgets/QFormLayout>
|
|||
#include <QtWidgets/QGridLayout>
|
|||
#include <QtWidgets/QGroupBox>
|
|||
#include <QtWidgets/QHBoxLayout>
|
|||
#include <QtWidgets/QLabel>
|
|||
#include <QtWidgets/QLineEdit>
|
|||
#include <QtWidgets/QMainWindow>
|
|||
#include <QtWidgets/QMenu>
|
|||
#include <QtWidgets/QMenuBar>
|
|||
#include <QtWidgets/QPushButton>
|
|||
#include <QtWidgets/QSpacerItem>
|
|||
#include <QtWidgets/QStatusBar>
|
|||
#include <QtWidgets/QTabWidget>
|
|||
#include <QtWidgets/QTextBrowser>
|
|||
#include <QtWidgets/QTextEdit>
|
|||
#include <QtWidgets/QVBoxLayout>
|
|||
#include <QtWidgets/QWidget>
|
|||
//
|
|||
#include <functional>
|
|||
|
|||
#include "../zexception.hpp"
|
|||
#include "z_function_list_box.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
/**
|
|||
* @brief 构造样式如下 |
|||
* |
|||
* +TAB---------------------------------+ |
|||
* |---BOX---------------------------| |
|||
* | 读全部 | |
|||
* | |Lable|Val| 读|写 | |
|||
* | |Lable|Val| 读|写 | |
|||
* | |Lable|Val| 读|写 | |
|||
* | |Lable|Val| 读|写 | |
|||
* | |Lable|Val| 读|写 | |
|||
* | |Lable|Val| 读|写 | |
|||
* |---------------------------------| |
|||
* |
|||
*/ |
|||
|
|||
class ZRegItem : public QFrame { |
|||
Q_OBJECT |
|||
public: |
|||
typedef enum { |
|||
kr = 1 << 0, |
|||
kw = 1 << 1, |
|||
krw = kr | kw, |
|||
khex = 1 << 2, |
|||
kdec = 1 << 3, |
|||
kfloat = 1 << 4, |
|||
kstr = 1 << 5, |
|||
kbinary = 1 << 6, |
|||
} reg_flag_t; |
|||
|
|||
private: |
|||
QHBoxLayout *m_layout = nullptr; |
|||
QLabel *m_lable; |
|||
QLineEdit *m_val; |
|||
QPushButton *m_writeButton; |
|||
QPushButton *m_readButton; |
|||
|
|||
QSpacerItem *m_horizontalSpacer; |
|||
|
|||
QString m_title; |
|||
int m_addr; |
|||
reg_flag_t m_flag; |
|||
|
|||
public: |
|||
ZRegItem(QWidget *parent, QString &title, int addr, ZRegItem::reg_flag_t flag); |
|||
}; |
|||
|
|||
class ZRegTableList : public QGroupBox { |
|||
Q_OBJECT |
|||
public: |
|||
function<void(const zexception &e)> m_onException; |
|||
|
|||
private: |
|||
/**
|
|||
* @brief layout |
|||
* |
|||
* VBoxLayout |
|||
* FunctonListBox |
|||
* Button,param,param |
|||
* Button,param,param |
|||
* RegBox |
|||
* Lable Val Spacer Button0 Button1 |
|||
* |
|||
*/ |
|||
|
|||
QVBoxLayout *m_layout = nullptr; |
|||
ZQFunctionListBox *m_funcBox; |
|||
|
|||
QGroupBox *m_regBox = nullptr; |
|||
QVBoxLayout *m_regBoxLayout = nullptr; |
|||
|
|||
QMap<QString, ZRegItem *> m_regMap; |
|||
|
|||
public: |
|||
ZRegTableList(QWidget *parent, const QString &title); |
|||
|
|||
void regOnException(function<void(const zexception &e)> onException); |
|||
void addReg(QString title, int addr, ZRegItem::reg_flag_t flag); |
|||
void addSpacer(); |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,5 @@ |
|||
#pragma once
|
|||
|
|||
#include "z_function_list_box.hpp"
|
|||
#include "zq_vtab_page.hpp"
|
|||
#include "z_reg_table_list_box.hpp"
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue