106 lines
1.7 KiB
C
106 lines
1.7 KiB
C
|
/**
|
||
|
* @file DebugWidget.h
|
||
|
* @author jinchao
|
||
|
* @brief 调试窗口类
|
||
|
* @version 1.0
|
||
|
* @date 2025-03-10
|
||
|
*
|
||
|
*/
|
||
|
#pragma once
|
||
|
|
||
|
#include <QWidget>
|
||
|
#include <QTextEdit>
|
||
|
#include <QPushButton>
|
||
|
#include <QVBoxLayout>
|
||
|
#include <QCheckBox>
|
||
|
|
||
|
/**
|
||
|
* @brief 调试窗口类
|
||
|
*/
|
||
|
class DebugWidget : public QWidget
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
/**
|
||
|
* @brief 构造函数
|
||
|
* @param parent 父窗口
|
||
|
*/
|
||
|
DebugWidget(QWidget *parent = nullptr);
|
||
|
/**
|
||
|
* @brief 析构函数
|
||
|
*/
|
||
|
~DebugWidget();
|
||
|
|
||
|
/**
|
||
|
* @brief 添加普通消息
|
||
|
* @param message 消息
|
||
|
*/
|
||
|
void appendMessage(const QString &message);
|
||
|
/**
|
||
|
* @brief 添加错误消息
|
||
|
* @param error 错误
|
||
|
*/
|
||
|
void appendError(const QString &error);
|
||
|
/**
|
||
|
* @brief 添加警告消息
|
||
|
* @param warning 警告
|
||
|
*/
|
||
|
void appendWarning(const QString &warning);
|
||
|
public slots:
|
||
|
/**
|
||
|
* @brief 接收调试消息槽函数
|
||
|
* @param type 类型
|
||
|
* @param message 消息
|
||
|
*/
|
||
|
void onSendDebugMessage(int type, const QString &message);
|
||
|
|
||
|
private slots:
|
||
|
/**
|
||
|
* @brief 清空日志槽函数
|
||
|
*/
|
||
|
void clearLog();
|
||
|
/**
|
||
|
* @brief 保存日志槽函数
|
||
|
*/
|
||
|
void saveLog();
|
||
|
|
||
|
private:
|
||
|
/**
|
||
|
* @brief 设置UI
|
||
|
*/
|
||
|
void setupUI();
|
||
|
/**
|
||
|
* @brief 是否显示消息类型
|
||
|
* @param type 类型
|
||
|
* @return 是否显示
|
||
|
*/
|
||
|
bool shouldShowMessageType(int type) const;
|
||
|
/**
|
||
|
* @brief 文本编辑器
|
||
|
*/
|
||
|
QTextEdit *m_textEdit;
|
||
|
/**
|
||
|
* @brief 清除按钮
|
||
|
*/
|
||
|
QPushButton *m_clearButton;
|
||
|
/**
|
||
|
* @brief 保存按钮
|
||
|
*/
|
||
|
QPushButton *m_saveButton;
|
||
|
/**
|
||
|
* @brief 布局
|
||
|
*/
|
||
|
QVBoxLayout *m_layout;
|
||
|
/**
|
||
|
* @brief 显示信息复选框
|
||
|
*/
|
||
|
QCheckBox *m_showInfoCheck;
|
||
|
/**
|
||
|
* @brief 显示错误复选框
|
||
|
*/
|
||
|
QCheckBox *m_showErrorCheck;
|
||
|
/**
|
||
|
* @brief 显示警告复选框
|
||
|
*/
|
||
|
QCheckBox *m_showWarningCheck;
|
||
|
};
|