mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-09 15:54:47 -07:00
add checkbox option to clear log (#2963)
This commit is contained in:
parent
297f1f2555
commit
0eae4dbe54
5 changed files with 48 additions and 8 deletions
|
|
@ -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());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue