PrimeWorldEditor/src/Editor/CErrorLogDialog.cpp

52 lines
1.2 KiB
C++
Raw Normal View History

2016-01-05 10:20:47 +00:00
#include "CErrorLogDialog.h"
#include "ui_CErrorLogDialog.h"
#include "UICommon.h"
#include <Common/Log.h>
2016-01-05 10:20:47 +00:00
2016-03-27 19:09:38 +00:00
CErrorLogDialog::CErrorLogDialog(QWidget *pParent)
: QDialog(pParent)
, ui(new Ui::CErrorLogDialog)
2016-01-05 10:20:47 +00:00
{
ui->setupUi(this);
connect(ui->CloseButton, SIGNAL(clicked()), this, SLOT(close()));
}
CErrorLogDialog::~CErrorLogDialog()
{
delete ui;
}
bool CErrorLogDialog::GatherErrors()
{
const TStringList& rkErrors = NLog::GetErrorLog();
2016-01-05 10:20:47 +00:00
if (rkErrors.empty()) return false;
QString DialogString;
for (auto it = rkErrors.begin(); it != rkErrors.end(); it++)
{
QString Error = TO_QSTRING(*it);
QString LineColor;
if (Error.startsWith("ERROR: "))
LineColor = "#ff0000";
else if (Error.startsWith("Warning: "))
LineColor = "#ff8000";
QString FullLine = Error;
if (!LineColor.isEmpty())
{
FullLine.prepend(QString("<font color=\"%1\">").arg(LineColor));
FullLine.append("</font>");
}
FullLine.append("<br />");
DialogString += FullLine;
}
ui->ErrorLogTextEdit->setText(DialogString);
NLog::ClearErrorLog();
2016-01-05 10:20:47 +00:00
return true;
}