forked from avartak/TkCommissioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmterminaldialog.h
78 lines (60 loc) · 1.78 KB
/
frmterminaldialog.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
#ifndef TKTERMINALDIALOG_H
#define TKTERMINALDIALOG_H
// System includes
#include <signal.h>
// Qt includes
#include <QProcess>
#include <QCloseEvent>
#include <QString>
#include <QStringList>
#include <QTimer>
#include <QByteArray>
#include <QDialog>
// UI file
#include "ui_frmterminaldialog.h"
// Debugging output
#include "Debug.h"
class TkTerminalDialog : public QDialog, private Ui::TkTerminalDialog {
Q_OBJECT
private:
QProcess* thisProcess_;
bool correctProcess_;
protected:
void closeEvent(QCloseEvent* event) {
if (thisProcess_ != NULL) delete thisProcess_;
event->accept();
}
public:
TkTerminalDialog(QWidget* p = 0):
QDialog(p)
{
setupUi(this);
btnDone->setEnabled(false);
correctProcess_ = false;
}
~TkTerminalDialog() {
if (thisProcess_ != NULL) delete thisProcess_;
}
void setProcessPtr(QProcess* newProcess) {
thisProcess_ = newProcess;
}
public Q_SLOTS:
void readFromStdout() {
if (thisProcess_) {
QByteArray newChunk;
newChunk = thisProcess_->readAllStandardOutput();
QString newTextString(newChunk);
textOutput->setText(textOutput->text()+newTextString);
textOutput->scrollToBottom();
}
}
void processFinished(int, QProcess::ExitStatus exitStatus) {
if (exitStatus == QProcess::NormalExit) correctProcess_ = true;
btnDone->setEnabled(true);
if (correctProcess_) done(QDialog::Accepted);
}
void executeWaitForReadyRead() {
thisProcess_->waitForReadyRead();
}
};
#endif