-
Notifications
You must be signed in to change notification settings - Fork 66
/
mainwindow.h
135 lines (116 loc) · 3.93 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
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
126
127
128
129
130
131
132
133
134
135
/*
* Copyright (c) 2015 Meinhard Ritscher <[email protected]>
* Copyright (c) 2017 Slawomir Pabian <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "controlpanel.h"
#include "ctrlcharacterspopup.h"
#include "sessionmanager.h"
#include "settings.h"
#include "statusbar.h"
#include "ui_mainwindow.h"
#include "pluginmanager.h"
#include <QFont>
#include <QMainWindow>
#include <QProgressDialog>
#include <QPropertyAnimation>
#include <QtSerialPort/QSerialPort>
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
enum DeviceState { DEVICE_CLOSED, DEVICE_OPENING, DEVICE_OPEN, DEVICE_CLOSING };
public:
explicit MainWindow(QWidget *parent = 0, const QString &session = "");
~MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *event);
private:
void openDevice();
void closeDevice();
void processData();
void handleError(QSerialPort::SerialPortError);
void printDeviceInfo();
void showAboutMsg();
void setHexOutputFormat(bool checked);
void saveCommandHistory();
private slots:
/**
* @brief Action to handle QAction::triggered signal. It removes selected items from inputs history list.
*/
void removeSelectedInputItems(bool remove);
protected:
void prevCmd();
void nextCmd();
void execCmd();
void commandFromHistoryClicked(QListWidgetItem *item);
bool sendString(const QString &s);
bool sendByte(const char c, unsigned long delay);
void sendKey();
void sendFile();
void readFromStdErr();
void sendDone(int exitCode, QProcess::ExitStatus exitStatus);
void closeEvent(QCloseEvent *event);
protected slots:
/**
* @brief Handles QCheckBox::stateChanged signal received from RTS checkbox (placed in control panel).
*/
void setRTSLineState(int checked);
/**
* @brief Handles QCheckBox::stateChanged signal received from DTR checkbox (placed in control panel).
*/
void setDTRLineState(int checked);
private:
void toggleLogging(bool start);
void fillLineTerminationChooser(const Settings::LineTerminator setting = Settings::LF);
void fillProtocolChooser(const Settings::Protocol setting = Settings::PLAIN);
void killSz();
void switchSession(const QString &session);
void updateCommandHistory();
ControlPanel *controlPanel;
SessionManager *m_sessionManager;
PluginManager *m_plugin_manager;
QSerialPort *m_device;
DeviceState m_deviceState;
StatusBar *m_device_statusbar;
Settings *m_settings;
QProgressDialog *m_progress;
int m_progressStepSize;
QProcess *m_sz;
bool m_devices_needs_refresh;
char m_previousChar;
QTime m_timestamp;
QFile m_logFile;
QCompleter *m_commandCompleter;
QStringListModel *m_command_history_model;
QMenu *m_command_history_menu;
/// @brief Popup widget that provides graphical way to enter ASCII control characters into input field.
popup_widget::CtrlCharactersPopup *m_ctrlCharactersPopup;
/**
* @brief m_keyRepeatTimer
*/
QTimer m_keyRepeatTimer;
char m_keyCode;
/**
* @brief m_cmdBufIndex
*/
int m_cmdBufIndex;
};
#endif // MAINWINDOW_H