-
Notifications
You must be signed in to change notification settings - Fork 1
/
statuswidget.cpp
57 lines (49 loc) · 1.5 KB
/
statuswidget.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
47
48
49
50
51
52
53
54
55
56
#include "statuswidget.h"
CStatusWidget::CStatusWidget(CStatusPrinter* _statusPrinter)
{
statusPrinter = _statusPrinter;
logTime.start();
this->setAllowedAreas(Qt::BottomDockWidgetArea);
this->setFeatures(QDockWidget::NoDockWidgetFeatures);
statusText = new QTextEdit(this);
titleLbl = new QLabel(tr("Messages"));
statusText->setMaximumWidth(1000);
QWidget* w = new QWidget(this);
statusText->setFixedSize(1000, 200);
QGridLayout* layout = new QGridLayout(w);
layout->addWidget(statusText, 0, 0);
layout->setAlignment(statusText, Qt::AlignLeft);
layout->setColumnMinimumWidth(0, 500);
statusText->resize(1200, 200);
w->setLayout(layout);
this->setSizeIncrement(this->width(), 100);
statusText->setReadOnly(true);
// this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setWidget(w);
}
CStatusWidget::~CStatusWidget()
{
delete statusText;
delete titleLbl;
}
void CStatusWidget::write(QString str, QColor color)
{
if( statusText->textCursor().blockNumber() > 1000 )
statusText->clear();
statusText->setTextColor(color);
statusText->append(QString::number(logTime.elapsed()) + " : " + str);
statusText->setTextColor(QColor("black"));
}
void CStatusWidget::update()
{
CStatusText text;
while(!statusPrinter->textBuffer.isEmpty())
{
text = statusPrinter->textBuffer.dequeue();
write(text.text, text.color);
}
}
void CStatusWidget::closeEvent(QEvent*)
{
emit closeSignal(false);
}