servatrice/cockatrice/src/dlg_viewlog.cpp
ctrlaltca b29bd9e070
Clang-format (#3028)
* 1/3 Add .clang-format file and travis compilation check

* 2/3 Run clang-format

* 3/3 Fix compilation problems due to include reordering

* 3bis/3 AfterControlStatement: false
2018-01-27 10:41:32 +01:00

57 lines
1.5 KiB
C++

#include "dlg_viewlog.h"
#include "logger.h"
#include "settingscache.h"
#include <QPlainTextEdit>
#include <QVBoxLayout>
DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
{
logArea = new QPlainTextEdit;
logArea->setReadOnly(true);
auto *mainLayout = new QVBoxLayout;
mainLayout->addWidget(logArea);
coClearLog = new QCheckBox;
coClearLog->setText(tr("Clear log when closing"));
coClearLog->setChecked(settingsCache->servers().getClearDebugLogStatus(true));
connect(coClearLog, SIGNAL(toggled(bool)), this, SLOT(actCheckBoxChanged(bool)));
mainLayout->addWidget(coClearLog);
setLayout(mainLayout);
setWindowTitle(tr("Debug Log"));
resize(800, 500);
loadInitialLogBuffer();
connect(&Logger::getInstance(), SIGNAL(logEntryAdded(QString)), this, SLOT(logEntryAdded(QString)));
}
void DlgViewLog::actCheckBoxChanged(bool abNewValue)
{
settingsCache->servers().setClearDebugLogStatus(abNewValue);
}
void DlgViewLog::loadInitialLogBuffer()
{
QList<QString> logBuffer = Logger::getInstance().getLogBuffer();
foreach (QString message, logBuffer)
logEntryAdded(message);
}
void DlgViewLog::logEntryAdded(QString message)
{
logArea->appendPlainText(message);
}
void DlgViewLog::closeEvent(QCloseEvent * /* event */)
{
if (coClearLog->isChecked()) {
logArea->clear();
}
logArea->appendPlainText(Logger::getInstance().getClientVersion());
logArea->appendPlainText(Logger::getInstance().getSystemArchitecture());
}