diff --git a/launcher/launch/LogModel.cpp b/launcher/launch/LogModel.cpp
index 23a33ae18..dd32d46a2 100644
--- a/launcher/launch/LogModel.cpp
+++ b/launcher/launch/LogModel.cpp
@@ -149,3 +149,15 @@ bool LogModel::wrapLines() const
{
return m_lineWrap;
}
+
+void LogModel::setColorLines(bool state)
+{
+ if (m_colorLines != state) {
+ m_colorLines = state;
+ }
+}
+
+bool LogModel::colorLines() const
+{
+ return m_colorLines;
+}
diff --git a/launcher/launch/LogModel.h b/launcher/launch/LogModel.h
index 167f74190..6c2a8cff3 100644
--- a/launcher/launch/LogModel.h
+++ b/launcher/launch/LogModel.h
@@ -27,6 +27,8 @@ class LogModel : public QAbstractListModel {
void setLineWrap(bool state);
bool wrapLines() const;
+ void setColorLines(bool state);
+ bool colorLines() const;
enum Roles { LevelRole = Qt::UserRole };
@@ -47,6 +49,7 @@ class LogModel : public QAbstractListModel {
QString m_overflowMessage = "OVERFLOW";
bool m_suspended = false;
bool m_lineWrap = true;
+ bool m_colorLines = true;
private:
Q_DISABLE_COPY(LogModel)
diff --git a/launcher/ui/pages/instance/LogPage.cpp b/launcher/ui/pages/instance/LogPage.cpp
index f050212b0..7897a2932 100644
--- a/launcher/ui/pages/instance/LogPage.cpp
+++ b/launcher/ui/pages/instance/LogPage.cpp
@@ -180,6 +180,13 @@ void LogPage::modelStateToUI()
ui->text->setWordWrap(false);
ui->wrapCheckbox->setCheckState(Qt::Unchecked);
}
+ if (m_model->colorLines()) {
+ ui->text->setColorLines(true);
+ ui->colorCheckbox->setCheckState(Qt::Checked);
+ } else {
+ ui->text->setColorLines(false);
+ ui->colorCheckbox->setCheckState(Qt::Unchecked);
+ }
if (m_model->suspended()) {
ui->trackLogCheckbox->setCheckState(Qt::Unchecked);
} else {
@@ -193,6 +200,7 @@ void LogPage::UIToModelState()
return;
}
m_model->setLineWrap(ui->wrapCheckbox->checkState() == Qt::Checked);
+ m_model->setColorLines(ui->colorCheckbox->checkState() == Qt::Checked);
m_model->suspend(ui->trackLogCheckbox->checkState() != Qt::Checked);
}
@@ -282,6 +290,14 @@ void LogPage::on_wrapCheckbox_clicked(bool checked)
m_model->setLineWrap(checked);
}
+void LogPage::on_colorCheckbox_clicked(bool checked)
+{
+ ui->text->setColorLines(checked);
+ if (!m_model)
+ return;
+ m_model->setColorLines(checked);
+}
+
void LogPage::on_findButton_clicked()
{
auto modifiers = QApplication::keyboardModifiers();
diff --git a/launcher/ui/pages/instance/LogPage.h b/launcher/ui/pages/instance/LogPage.h
index 1295410ea..b4d74fb9c 100644
--- a/launcher/ui/pages/instance/LogPage.h
+++ b/launcher/ui/pages/instance/LogPage.h
@@ -82,6 +82,7 @@ class LogPage : public QWidget, public BasePage {
void on_trackLogCheckbox_clicked(bool checked);
void on_wrapCheckbox_clicked(bool checked);
+ void on_colorCheckbox_clicked(bool checked);
void on_findButton_clicked();
void findActivated();
diff --git a/launcher/ui/pages/instance/LogPage.ui b/launcher/ui/pages/instance/LogPage.ui
index 31bb368c8..fb8690581 100644
--- a/launcher/ui/pages/instance/LogPage.ui
+++ b/launcher/ui/pages/instance/LogPage.ui
@@ -74,6 +74,16 @@
+ -
+
+
+ Color lines
+
+
+ true
+
+
+
-
@@ -170,6 +180,7 @@
tabWidget
trackLogCheckbox
wrapCheckbox
+ colorCheckbox
btnCopy
btnPaste
btnClear
diff --git a/launcher/ui/widgets/LogView.cpp b/launcher/ui/widgets/LogView.cpp
index 6578b1f12..181893af4 100644
--- a/launcher/ui/widgets/LogView.cpp
+++ b/launcher/ui/widgets/LogView.cpp
@@ -60,6 +60,14 @@ void LogView::setWordWrap(bool wrapping)
}
}
+void LogView::setColorLines(bool colorLines)
+{
+ if (m_colorLines == colorLines)
+ return;
+ m_colorLines = colorLines;
+ repopulate();
+}
+
void LogView::setModel(QAbstractItemModel* model)
{
if (m_model) {
@@ -130,11 +138,11 @@ void LogView::rowsInserted(const QModelIndex& parent, int first, int last)
format.setFont(font.value());
}
auto fg = m_model->data(idx, Qt::ForegroundRole);
- if (fg.isValid()) {
+ if (fg.isValid() && m_colorLines) {
format.setForeground(fg.value());
}
auto bg = m_model->data(idx, Qt::BackgroundRole);
- if (bg.isValid()) {
+ if (bg.isValid() && m_colorLines) {
format.setBackground(bg.value());
}
cursor.movePosition(QTextCursor::End);
diff --git a/launcher/ui/widgets/LogView.h b/launcher/ui/widgets/LogView.h
index dde5f8f76..69ca332bb 100644
--- a/launcher/ui/widgets/LogView.h
+++ b/launcher/ui/widgets/LogView.h
@@ -15,6 +15,7 @@ class LogView : public QPlainTextEdit {
public slots:
void setWordWrap(bool wrapping);
+ void setColorLines(bool colorLines);
void findNext(const QString& what, bool reverse);
void scrollToBottom();
@@ -32,4 +33,5 @@ class LogView : public QPlainTextEdit {
QTextCharFormat* m_defaultFormat = nullptr;
bool m_scroll = false;
bool m_scrolling = false;
+ bool m_colorLines = true;
};