You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.0 KiB
C++
115 lines
3.0 KiB
C++
#ifndef WIDGET_H
|
|
#define WIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QComboBox>
|
|
#include <QTimer>
|
|
// 串口类
|
|
#include <QSerialPort>
|
|
#include <QSerialPortInfo>
|
|
|
|
#include "AuthorityDialog.h"
|
|
#include "BaseSetupWidget.h"
|
|
#include "AdvanceSetupWidget.h"
|
|
|
|
#define MAIN_VERSION (1)
|
|
#define SUB_VERSION (0)
|
|
#define VERSION (char)((((MAIN_VERSION) & 0x0F) << 4 & 0xF0) | ((SUB_VERSION) & 0x0F))
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
namespace Ui { class Widget; }
|
|
QT_END_NAMESPACE
|
|
|
|
//QSerialPort::BaudRate gDefaultBaudRate = QSerialPort::Baud115200;
|
|
//QSerialPort::DataBits gDefaultDataBits = QSerialPort::Data8;
|
|
//QSerialPort::StopBits gDefaultStopBits = QSerialPort::OneStop;
|
|
//QSerialPort::Parity gDefaultParity = QSerialPort::NoParity;
|
|
|
|
class Widget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
Widget(QWidget *parent = nullptr);
|
|
~Widget();
|
|
|
|
// L0 - 初始化串口区域
|
|
void initSerialPortArea();
|
|
|
|
// L0 - 初始化业务区域
|
|
void initServiceArea();
|
|
|
|
// L1 - 串口区域初始化
|
|
void initComboBoxPortName();
|
|
void initComboBoxBaudRate();
|
|
void initComboBoxDataBits();
|
|
void initComboBoxStopBits();
|
|
void initComboBoxParity();
|
|
void updateComboBoxPortName();
|
|
|
|
// L1 - 日志区域
|
|
void initLogArea();
|
|
|
|
// 切换高级设置的授权定时器
|
|
void initAuthorityTimer(int msec = 600);
|
|
void startAuthorityTimer();
|
|
void stopAuthorityTimer();
|
|
|
|
// 版本
|
|
QString version();
|
|
|
|
unsigned char getCurrentType();
|
|
|
|
|
|
|
|
protected:
|
|
void showEvent(QShowEvent *event);
|
|
void closeEvent(QCloseEvent *event);
|
|
|
|
private slots:
|
|
// 串口区域
|
|
void slot_OpenSerial();
|
|
void slot_SearchSerial();
|
|
|
|
void slot_comboBoxPortName_currentIndexChanged(QString text);
|
|
void slot_comboBoxBaudRate_currentIndexChanged(QString text);
|
|
void slot_comboBoxDataBits_currentIndexChanged(QString text);
|
|
void slot_comboBoxStopBits_currentIndexChanged(QString text);
|
|
void slot_comboBoxParity_currentIndexChanged(QString text);
|
|
|
|
// 授权定时器
|
|
void slot_autorityTimer();
|
|
void slot_changeTab(int index); // 切换tab事件
|
|
void slot_clickTabBar(int index); // tab点击事件
|
|
|
|
// 日志区域
|
|
void slot_clearTextEdit();
|
|
|
|
void slot_logAdded(QString log);
|
|
|
|
void slot_tabComboBox_currentIndexChanged(int index);
|
|
|
|
private:
|
|
Ui::Widget *ui;
|
|
|
|
// 切换高级Tab相关
|
|
bool m_bAuthority; // 切换高级设置时是否验证通过
|
|
QTimer m_authorityTimer; // 授权定时器,授权之后启动定时器,定时器超时关闭授权并关闭定时器
|
|
AuthorityDialog m_authorityDialog;
|
|
|
|
QComboBox m_typeComboBox;
|
|
bool m_bElectric; // 电动扳手
|
|
bool m_bCharged; // 充电扳手
|
|
bool m_bHydraulic; // 液压扳手
|
|
bool m_bPneumatic; // 气动扳手
|
|
|
|
|
|
// 这里必须用指针,否则在自适应分辨率时,所有控件都不可见,需要用其他方式处理才行。
|
|
BaseSetupWidget *m_baseSetupWidget;
|
|
AdvanceSetupWidget *m_advanceSetupWidget;
|
|
|
|
std::string m_cfgFileName;
|
|
};
|
|
#endif // WIDGET_H
|