mirror of
https://github.com/gabime/spdlog.git
synced 2025-03-31 02:12:40 +08:00
Formatted qt_sinks.h code
This commit is contained in:
parent
72a7ec3eb9
commit
bed324e414
@ -30,13 +30,14 @@ template<typename Mutex>
|
||||
class qt_sink : public base_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
qt_sink(QObject *qt_object, std::string meta_method): qt_object_(qt_object), meta_method_(std::move(meta_method))
|
||||
qt_sink(QObject *qt_object, std::string meta_method)
|
||||
: qt_object_(qt_object)
|
||||
, meta_method_(std::move(meta_method))
|
||||
{
|
||||
if (!qt_object_)
|
||||
{
|
||||
throw_spdlog_ex("qt_sink: qt_object is null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
~qt_sink()
|
||||
@ -71,7 +72,8 @@ private:
|
||||
{
|
||||
public:
|
||||
qt_color_sink(QTextEdit *qt_text_edit, int max_lines)
|
||||
: qt_text_edit_(qt_text_edit), max_lines_(max_lines)
|
||||
: qt_text_edit_(qt_text_edit)
|
||||
, max_lines_(max_lines)
|
||||
{
|
||||
if (!qt_text_edit_)
|
||||
{
|
||||
@ -134,17 +136,16 @@ private:
|
||||
protected:
|
||||
struct invoke_params
|
||||
{
|
||||
invoke_params(int max_lines, QTextEdit *q_text_edit, QString payload, QTextCharFormat default_color,
|
||||
QTextCharFormat level_color, int color_range_start, int color_range_end)
|
||||
: max_lines(max_lines),
|
||||
q_text_edit(q_text_edit),
|
||||
payload(std::move(payload)),
|
||||
default_color(default_color),
|
||||
level_color(level_color),
|
||||
color_range_start(color_range_start),
|
||||
color_range_end(color_range_end)
|
||||
{
|
||||
}
|
||||
invoke_params(int max_lines, QTextEdit *q_text_edit, QString payload, QTextCharFormat default_color, QTextCharFormat level_color,
|
||||
int color_range_start, int color_range_end)
|
||||
: max_lines(max_lines)
|
||||
, q_text_edit(q_text_edit)
|
||||
, payload(std::move(payload))
|
||||
, default_color(default_color)
|
||||
, level_color(level_color)
|
||||
, color_range_start(color_range_start)
|
||||
, color_range_end(color_range_end)
|
||||
{}
|
||||
int max_lines;
|
||||
QTextEdit *q_text_edit;
|
||||
QString payload;
|
||||
@ -163,8 +164,7 @@ private:
|
||||
// apply the color to the color range in the formatted message.
|
||||
auto payload = QString::fromLatin1(str.data(), static_cast<int>(str.size()));
|
||||
|
||||
invoke_params params {
|
||||
max_lines_, // max lines
|
||||
invoke_params params{max_lines_, // max lines
|
||||
qt_text_edit_, // text edit to append to
|
||||
std::move(payload), // text to append
|
||||
default_color_, // default color
|
||||
@ -173,10 +173,7 @@ private:
|
||||
static_cast<int>(msg.color_range_end)}; // color range end
|
||||
|
||||
QMetaObject::invokeMethod(
|
||||
qt_text_edit_,
|
||||
[params]() {invoke_method_(params);},
|
||||
Qt::AutoConnection);
|
||||
|
||||
qt_text_edit_, [params]() { invoke_method_(params); }, Qt::AutoConnection);
|
||||
}
|
||||
|
||||
void flush_() override {}
|
||||
|
Loading…
Reference in New Issue
Block a user