add checkbox option to clear log (#2963)

This commit is contained in:
Zach H 2017-12-17 17:32:31 -05:00 committed by GitHub
parent 297f1f2555
commit 0eae4dbe54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 8 deletions

View file

@ -1,18 +1,26 @@
#include "dlg_viewlog.h"
#include "logger.h"
#include "settingscache.h"
#include <QVBoxLayout>
#include <QPlainTextEdit>
DlgViewLog::DlgViewLog(QWidget *parent)
: QDialog(parent)
DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
{
logArea = new QPlainTextEdit;
logArea->setReadOnly(true);
QVBoxLayout *mainLayout = new QVBoxLayout;
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"));
@ -22,6 +30,11 @@ DlgViewLog::DlgViewLog(QWidget *parent)
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();
@ -36,6 +49,10 @@ void DlgViewLog::logEntryAdded(QString message)
void DlgViewLog::closeEvent(QCloseEvent * /* event */)
{
logArea->clear();
if (coClearLog->isChecked())
{
logArea->clear();
}
logArea->appendPlainText(Logger::getInstance().getClientVersion());
}