-
Notifications
You must be signed in to change notification settings - Fork 10
/
mainwindow.h
72 lines (60 loc) · 1.46 KB
/
mainwindow.h
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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "drivers/serialport.h"
#include "ui_mainwindow.h"
#include <QMainWindow>
#include <QSerialPort>
#include <QWidget>
#include <QJsonArray>
#include <QSettings>
class MainWindow : public QMainWindow, private Ui::MainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
void sendBytes(const QByteArray &data);
protected:
void resizeEvent(QResizeEvent *event);
private slots:
void onReset();
void onSend();
void onBreak();
void onClear();
void onOpen();
void onClose();
void onToggleOpen();
void onMutualTest();
void onTabPageChanged(int index);
void refreshStatistics();
void onDataReceived(QByteArray data);
void onIdle();
void onBreakChanged(bool set);
private:
QList<SerialPort *> ports;
void appendText(QString text, QColor color);
bool eventFilter(QObject *object, QEvent *event);
void fitTerminal();
void refreshOpenStatus();
void saveSettings();
void loadSettings();
quint64 bytesRecv;
quint64 bytesSent;
QList<QPair<quint64, qint64>> recvRecord;
QList<QPair<quint64, qint64>> sentRecord;
QTimer *timer;
QLabel *statisticsLabel;
QIcon playIcon, stopIcon;
bool isOpened;
QSettings settings;
};
class JsInterface : public QObject
{
Q_OBJECT
private:
MainWindow* parentWindow;
public:
JsInterface(MainWindow *_parent) : QObject(_parent) {
parentWindow = _parent;
}
Q_INVOKABLE void sendBytes(const QJsonArray& data) const;
};
#endif