Qt Sink : Allow for darker colors (for light background). (#2817)

Default are too bright if background is light(white).
This commit is contained in:
qwark 2023-07-14 19:21:25 +02:00 committed by GitHub
parent 7e635fca68
commit 76dfc7e7c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,7 @@ template<typename Mutex>
class qt_color_sink : public base_sink<Mutex>
{
public:
qt_color_sink(QTextEdit *qt_text_edit, int max_lines)
qt_color_sink(QTextEdit *qt_text_edit, int max_lines, bool dark_colors=false)
: qt_text_edit_(qt_text_edit)
, max_lines_(max_lines)
{
@ -84,16 +84,16 @@ public:
// set colors
QTextCharFormat format;
// trace
format.setForeground(Qt::gray);
format.setForeground(dark_colors ? Qt::darkGray : Qt::gray);
colors_.at(level::trace) = format;
// debug
format.setForeground(Qt::cyan);
format.setForeground(dark_colors ? Qt::darkCyan : Qt::cyan);
colors_.at(level::debug) = format;
// info
format.setForeground(Qt::green);
format.setForeground(dark_colors ? Qt::darkGreen : Qt::green);
colors_.at(level::info) = format;
// warn
format.setForeground(Qt::yellow);
format.setForeground(dark_colors ? Qt::darkYellow : Qt::yellow);
colors_.at(level::warn) = format;
// err
format.setForeground(Qt::red);