forked from 2600hz/kazoo-popup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debugdialog.cpp
39 lines (30 loc) · 842 Bytes
/
debugdialog.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
#include "debugdialog.h"
#include "ui_debugdialog.h"
#include "logger.h"
#include <QTimer>
#include <QScrollBar>
DebugDialog::DebugDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::DebugDialog)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
Logger *logger = Logger::instance();
connect(logger, &Logger::newLog,
this, &DebugDialog::appendLog);
ui->plainTextEdit->setPlainText(logger->logs());
QTimer::singleShot(0, this, SLOT(ensureCursorVisible()));
}
DebugDialog::~DebugDialog()
{
delete ui;
}
void DebugDialog::appendLog(const QString &log)
{
ui->plainTextEdit->appendPlainText(log);
}
void DebugDialog::ensureCursorVisible()
{
QScrollBar *scrollBar = ui->plainTextEdit->verticalScrollBar();
scrollBar->setValue(scrollBar->maximum());
}