-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.h
More file actions
77 lines (65 loc) · 1.91 KB
/
widget.h
File metadata and controls
77 lines (65 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QTimer>
#include <QScrollBar>
#include "serialworker.h"
#include "dataprocessor.h"
#include "databuffer.h"
#include "serialconfig.h"
#include "keywordhighlighter.h"
#include "speedmonitor.h"
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
/**
* @brief Widget - 主界面控件
*
* 负责UI显示和用户交互,集成 SerialWorker、DataProcessor、DataBuffer 组件。
* 实现定时批量刷新机制和自动滚动暂停/恢复逻辑。
*
* Requirements: 1.3, 6.1, 6.2, 6.3, 6.4
*/
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = nullptr);
~Widget();
static constexpr int REFRESH_INTERVAL_MS = 33; // ~30 FPS
private slots:
void on_clear_clicked();
void on_cbPortName_clicked();
void on_open_clicked();
void on_send_clicked();
void on_clearSend_clicked();
void onRefreshTimeout();
void onDataReceived(const QByteArray &data);
void onDataProcessed(const QString &text);
void onSerialError(const QString &error);
void onSerialStarted();
void onSerialStopped();
void onScrollValueChanged(int value);
void onSpeedUpdated(double bytesPerSecond, qint64 totalBytes);
void onSplitterMoved(int pos, int index);
void on_openSetButton_clicked();
private:
void setupConnections();
void updatePortList();
void setPortControlsEnabled(bool enabled);
void appendToDisplay(const QString &text);
void showSystemMessage(const QString &message);
void performSend();
SerialConfig buildConfig() const;
void applyDarkMode(bool enabled);
Ui::Widget *ui;
SerialWorker *m_worker;
DataProcessor *m_processor;
DataBuffer *m_buffer;
QTimer *m_refreshTimer;
KeywordHighlighter *m_highlighter;
SpeedMonitor *m_speedMonitor;
QString m_pendingText;
bool m_autoScroll = true;
};
#endif // WIDGET_H