Clean qt_color_sink

This commit is contained in:
gabime 2023-06-17 18:09:08 +03:00
parent a29cef5787
commit da1e671d42

View File

@ -157,26 +157,24 @@ private:
memory_buf_t formatted; memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted); base_sink<Mutex>::formatter_->format(msg, formatted);
string_view_t str = string_view_t(formatted.data(), formatted.size()); const string_view_t str = string_view_t(formatted.data(), formatted.size());
// apply the color to the color range in the formatted message. // apply the color to the color range in the formatted message.
auto payload = QString::fromLatin1(str.data(), static_cast<int>(str.size())); auto payload = QString::fromLatin1(str.data(), static_cast<int>(str.size()));
// if color needed, apply it as invoke_params params {
//if (msg.color_range_end > msg.color_range_start) max_lines_, // max lines
{ qt_text_edit_, // text edit to append to
invoke_params params { std::move(payload), // text to append
max_lines_, // max lines default_color_, // default color
qt_text_edit_, // text edit to append to colors_.at(msg.level), // color to apply
std::move(payload), // text to append msg.color_range_start, // color range start
default_color_, // default color msg.color_range_end}; // color range end
colors_.at(msg.level), // color to apply
msg.color_range_start, // color range start QMetaObject::invokeMethod(
msg.color_range_end}; // color range end qt_text_edit_,
QMetaObject::invokeMethod( [params]() {invoke_method_(params);},
qt_text_edit_, Qt::AutoConnection);
[params]() {invoke_method_(params);},
Qt::AutoConnection);
}
} }
void flush_() override {} void flush_() override {}