diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-08-20 01:49:03 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-08-20 01:49:03 +0200 |
commit | d0e88011dc025a1e68964a9363cece66c677969f (patch) | |
tree | c8f2701fb0c959ba4fc63c0e447ee71722002096 /application/pages/LogPage.cpp | |
parent | 6858f1dd6294a93c1e1ec8007cb0434b53646488 (diff) | |
download | MultiMC-d0e88011dc025a1e68964a9363cece66c677969f.tar MultiMC-d0e88011dc025a1e68964a9363cece66c677969f.tar.gz MultiMC-d0e88011dc025a1e68964a9363cece66c677969f.tar.lz MultiMC-d0e88011dc025a1e68964a9363cece66c677969f.tar.xz MultiMC-d0e88011dc025a1e68964a9363cece66c677969f.zip |
GH-1197 finish color stuff
Diffstat (limited to 'application/pages/LogPage.cpp')
-rw-r--r-- | application/pages/LogPage.cpp | 50 |
1 files changed, 7 insertions, 43 deletions
diff --git a/application/pages/LogPage.cpp b/application/pages/LogPage.cpp index 280f64d0..892ba324 100644 --- a/application/pages/LogPage.cpp +++ b/application/pages/LogPage.cpp @@ -10,7 +10,7 @@ #include "launch/LaunchTask.h" #include <settings/Setting.h> #include "GuiUtil.h" -#include <Colors.h> +#include <ColorCache.h> LogPage::LogPage(std::shared_ptr<LaunchTask> proc, QWidget *parent) : QWidget(parent), ui(new Ui::LogPage), m_process(proc) @@ -41,6 +41,10 @@ LogPage::LogPage(std::shared_ptr<LaunchTask> proc, QWidget *parent) } ui->text->setMaximumBlockCount(maxLines); + auto origForeground = ui->text->palette().color(ui->text->foregroundRole()); + auto origBackground = ui->text->palette().color(ui->text->backgroundRole()); + m_colors.reset(new LogColorCache(origForeground, origBackground)); + m_stopOnOverflow = MMC->settings()->get("ConsoleOverflowStop").toBool(); auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this); @@ -204,48 +208,8 @@ 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: - { - foreground(QColor("purple")); - break; - } - case MessageLevel::Debug: - { - foreground(QColor("green")); - break; - } - case MessageLevel::Warning: - { - foreground(QColor("orange")); - break; - } - case MessageLevel::Error: - { - foreground(QColor("red")); - break; - } - case MessageLevel::Fatal: - { - origBackground = QColor("black"); - foreground(QColor("red")); - format.setBackground(QColor("black")); - break; - } - case MessageLevel::Info: - case MessageLevel::Message: - default: - { - foreground(QColor("black")); - } - } + format.setForeground(m_colors->getFront(mode)); + format.setBackground(m_colors->getBack(mode)); while (iter.hasNext()) { |