-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.cpp
More file actions
56 lines (45 loc) · 946 Bytes
/
console.cpp
File metadata and controls
56 lines (45 loc) · 946 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "console.h"
#include <QScrollBar>
Console::Console(QWidget *parent) :
QPlainTextEdit(parent)
{
document()->setMaximumBlockCount(100);
m_update = true;
}
void Console::putData(const QByteArray &data, const QBrush &col)
{
if (data.length() > 4)
m_update = false;
if (m_update)
{
QTextCharFormat tf;
tf = currentCharFormat();
tf.setForeground(col);
setCurrentCharFormat(tf);
insertPlainText(data);
QScrollBar *bar = verticalScrollBar();
bar->setValue(bar->maximum());
}
}
void Console::keyPressEvent(QKeyEvent *e)
{
Q_UNUSED(e)
}
void Console::mousePressEvent(QMouseEvent *e)
{
Q_UNUSED(e)
setFocus();
}
void Console::mouseDoubleClickEvent(QMouseEvent *e)
{
Q_UNUSED(e)
}
void Console::contextMenuEvent(QContextMenuEvent *e)
{
Q_UNUSED(e)
}
void Console::clear()
{
QPlainTextEdit::clear();
m_update = true;
}