-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.hpp
More file actions
125 lines (75 loc) · 2.87 KB
/
Copy pathMainWindow.hpp
File metadata and controls
125 lines (75 loc) · 2.87 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//
// Created by Administrator on 2025/5/2.
//
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QListWidgetItem>
#include <QMainWindow>
#include "TaskExecutor.hpp"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QMainWindow *parent = nullptr);
~MainWindow() override;
private:
Ui::MainWindow *ui;
TaskExecutor *executorPtr = nullptr;
QList<PortMessage> history;
QTimer *timerPtr = nullptr;
QList<QString> checkCodeTypes = {"无校验码", "CRC-8", "CRC-16(L)",
"CRC-16(H)", "XOR", "Checksum"};
static constexpr int kAddItemMagicId = -999; // 标记"添加新指令"占位项
qint64 txBytes = 0; // 发送字节数
qint64 rxBytes = 0; // 接收字节数
bool autoScrollEnabled = true; // 是否自动滚动到底部
bool hexReceiveEnabled = true; // 接收数据是否以十六进制显示
// ====== 菜单栏 ======
void onActionSaveDataClicked();
void onActionClearDataClicked();
void onActionCommandScriptClicked();
void onActionSearchClicked();
void onActionClearHighlightClicked();
void onActionCopyClicked();
void onActionTopmostToggled(bool checked);
void onActionDarkThemeToggled(bool checked);
void onActionAutoScrollToggled(bool checked);
void onActionDecodeStateChanged(const int &state);
void onActionProjectSiteTriggered();
void onActionAboutTriggered();
// ==== 普通操作 ======
void updateCommandList();
void updateComboxState(bool disabled) const;
void onOpenPortButtonClicked();
void onRefreshButtonClicked();
void onCommandItemClicked(const QListWidgetItem *item);
void onAddCommandItemClicked();
void updateCommandWidget(const qint16 &id, const QString &command,
const QString &remark);
void showCommandWidgetContextMenu(const QPoint &pos);
void onCustomAction(const QListWidgetItem *item, const QString &message);
void onSendCommandButtonClicked();
void sendCommand(const QString &command);
void updatePortMessageLog(const QByteArray &data, const QString &direction);
void updateHistoryListWidget(const QString &command);
void onHistoryItemClicked(QListWidgetItem *item);
void onTimeCheckBoxStateChanged(const qint16 &state);
void uncheckTimeCheckBox();
// 编码发送
void onEncodeCheckBoxStateChanged(const qint16 &state);
void onPortDataReceived(const QByteArray &data);
void onPortStateChanged(bool opened);
void onPortErrorOccurred(const QString &msg);
void onTimerTimeout();
QByteArray appendCheckCode(const QByteArray &command,
const int &checkCodeType);
void updateTxRxBytes();
private slots:
void executeTask(const QString &command);
void onScriptFinished();
};
#endif // MAINWINDOW_H