summaryrefslogtreecommitdiffstats
path: root/tools/qml/loggerwidget.cpp
blob: df94ba0182da788d3c492e4dddc85ed39ac0e3d2 (plain)
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
#include "loggerwidget.h"
#include <qglobal.h>
#include <QDebug>

QT_BEGIN_NAMESPACE

LoggerWidget::LoggerWidget(QWidget *parent) :
    QPlainTextEdit(parent),
    m_keepClosed(false)
{
    setAttribute(Qt::WA_QuitOnClose, false);
    setWindowTitle(tr("Qt Declarative UI Viewer - Logger"));
}

void LoggerWidget::append(QtMsgType /*type*/, const char *msg)
{
    appendPlainText(QString::fromAscii(msg));

    if (!m_keepClosed && !isVisible())
        setVisible(true);
}

void LoggerWidget::closeEvent(QCloseEvent *event)
{
    m_keepClosed = true;
    QWidget::closeEvent(event);
}

QT_END_NAMESPACE