-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.cpp
More file actions
34 lines (29 loc) · 730 Bytes
/
console.cpp
File metadata and controls
34 lines (29 loc) · 730 Bytes
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
#include "console.h"
#include <QTextEdit>
#include <QScrollBar>
#include <QDebug>
Console::Console(QTextEdit* textEdit) : textEdit(textEdit) {
textEdit->clear();
}
void Console::printMessage(QString message) {
qDebug() << message;
if(cur == 0)
textEdit->setText(message);
else {
textEdit->setText(textEdit->toPlainText() + '\n' + message);
cur += 1;
}
cur += message.length();
scrollToBottom();
}
void Console::scrollToBottom() {
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
}
void Console::clear() {
textEdit->setText("");
cur = 0;
}
QString Console::fromBool(bool b) {
if(b) return "true";
else return "false";
}