-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminaldock.cpp
46 lines (40 loc) · 1.47 KB
/
terminaldock.cpp
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
#include <QScrollBar>
#include "terminaldock.h"
#include "ui_terminaldock.h"
TerminalDock::TerminalDock(QWidget *parent) :
QDockWidget(parent)
{
setupUi(this);
connect(terminalSendButton, &QPushButton::clicked, this, &TerminalDock::buttonClicked);
connect(terminalLineEdit, &QLineEdit::returnPressed, this, &TerminalDock::buttonClicked);
}
void TerminalDock::rawIncomingPacket(QString string) {
terminalTextEdit->moveCursor(QTextCursor::End);
if (string[0] == "E") {
terminalTextEdit->setTextColor(QColorConstants::Red);
}
else {
terminalTextEdit->setTextColor(QColorConstants::Black);
}
terminalTextEdit->insertPlainText(">>> ");
terminalTextEdit->insertPlainText(string);
terminalTextEdit->verticalScrollBar()->setValue(terminalTextEdit->verticalScrollBar()->maximum());
}
void TerminalDock::rawOutgoingPacket(QString string) {
terminalTextEdit->moveCursor(QTextCursor::End);
if (string[0] == "E") {
terminalTextEdit->setTextColor(QColorConstants::Red);
}
else {
terminalTextEdit->setTextColor(QColorConstants::Black);
}
terminalTextEdit->insertPlainText("<<< ");
terminalTextEdit->insertPlainText(string);
terminalTextEdit->verticalScrollBar()->setValue(terminalTextEdit->verticalScrollBar()->maximum());
}
void TerminalDock::buttonClicked() {
auto text = terminalLineEdit->text();
text.append(QString::fromStdString("\n"));
sendRaw(text);
terminalLineEdit->clear();
}