diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-08-19 02:06:32 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-08-19 23:52:53 +0200 |
commit | 6858f1dd6294a93c1e1ec8007cb0434b53646488 (patch) | |
tree | 83656c5ff2ef9aa8d5bf7b2441727282751c78fc /application/pages/LogPage.cpp | |
parent | 9681f724e5ac0d859c575d093c6dd656a3b9e5c7 (diff) | |
download | MultiMC-6858f1dd6294a93c1e1ec8007cb0434b53646488.tar MultiMC-6858f1dd6294a93c1e1ec8007cb0434b53646488.tar.gz MultiMC-6858f1dd6294a93c1e1ec8007cb0434b53646488.tar.lz MultiMC-6858f1dd6294a93c1e1ec8007cb0434b53646488.tar.xz MultiMC-6858f1dd6294a93c1e1ec8007cb0434b53646488.zip |
GH-1197 add console log color adaptation
rainbow library was part of KDE - KGuiAddons
Diffstat (limited to 'application/pages/LogPage.cpp')
-rw-r--r-- | application/pages/LogPage.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/application/pages/LogPage.cpp b/application/pages/LogPage.cpp index 77d5d6b8..280f64d0 100644 --- a/application/pages/LogPage.cpp +++ b/application/pages/LogPage.cpp @@ -10,6 +10,7 @@ #include "launch/LaunchTask.h" #include <settings/Setting.h> #include "GuiUtil.h" +#include <Colors.h> LogPage::LogPage(std::shared_ptr<LaunchTask> proc, QWidget *parent) : QWidget(parent), ui(new Ui::LogPage), m_process(proc) @@ -203,31 +204,38 @@ void LogPage::write(QString data, MessageLevel::Enum mode) QListIterator<QString> iter(filtered); QTextCharFormat format(*defaultFormat); + auto origForeground = ui->text->palette().color(ui->text->foregroundRole()); + auto origBackground = ui->text->palette().color(ui->text->backgroundRole()); + auto foreground = [&](QColor foreColor) + { + format.setForeground(Color::blend(origForeground, origBackground, foreColor, 255)); + }; switch(mode) { case MessageLevel::MultiMC: { - format.setForeground(QColor("blue")); + foreground(QColor("purple")); break; } case MessageLevel::Debug: { - format.setForeground(QColor("green")); + foreground(QColor("green")); break; } case MessageLevel::Warning: { - format.setForeground(QColor("orange")); + foreground(QColor("orange")); break; } case MessageLevel::Error: { - format.setForeground(QColor("red")); + foreground(QColor("red")); break; } case MessageLevel::Fatal: { - format.setForeground(QColor("red")); + origBackground = QColor("black"); + foreground(QColor("red")); format.setBackground(QColor("black")); break; } @@ -235,7 +243,7 @@ void LogPage::write(QString data, MessageLevel::Enum mode) case MessageLevel::Message: default: { - // do nothing, keep original + foreground(QColor("black")); } } |