diff --git a/rpcs3/rpcs3qt/log_viewer.cpp b/rpcs3/rpcs3qt/log_viewer.cpp index 7bc2d80389..284fbe3059 100644 --- a/rpcs3/rpcs3qt/log_viewer.cpp +++ b/rpcs3/rpcs3qt/log_viewer.cpp @@ -14,6 +14,7 @@ #include #include #include +#include LOG_CHANNEL(gui_log, "GUI"); @@ -62,6 +63,10 @@ void log_viewer::show_context_menu(const QPoint& pos) QAction* open = new QAction(tr("&Open log file")); QAction* filter = new QAction(tr("&Filter log")); + QAction* threads = new QAction(tr("&Show Threads")); + threads->setCheckable(true); + threads->setChecked(m_show_threads); + QActionGroup* log_level_acts = new QActionGroup(this); QAction* fatal_act = new QAction(tr("Fatal"), log_level_acts); QAction* error_act = new QAction(tr("Error"), log_level_acts); @@ -97,6 +102,8 @@ void log_viewer::show_context_menu(const QPoint& pos) menu.addSeparator(); menu.addAction(filter); menu.addSeparator(); + menu.addAction(threads); + menu.addSeparator(); menu.addActions(log_level_acts->actions()); menu.addSeparator(); menu.addAction(clear); @@ -122,6 +129,12 @@ void log_viewer::show_context_menu(const QPoint& pos) filter_log(); }); + connect(threads, &QAction::toggled, this, [this](bool checked) + { + m_show_threads = checked; + filter_log(); + }); + const auto obj = qobject_cast(sender()); QPoint origin; @@ -187,14 +200,17 @@ void log_viewer::filter_log() if (!m_log_levels.test(static_cast(logs::level::notice))) excluded_log_levels.push_back("·! "); if (!m_log_levels.test(static_cast(logs::level::trace))) excluded_log_levels.push_back("·T "); - if (m_filter_term.isEmpty() && excluded_log_levels.empty()) + if (m_filter_term.isEmpty() && excluded_log_levels.empty() && m_show_threads) { + const int pos = m_log_text->verticalScrollBar()->value(); m_log_text->setPlainText(m_full_log); + m_log_text->verticalScrollBar()->setValue(pos); return; } QString result; + QRegularExpression regexp("\{.*\} "); QTextStream stream(&m_full_log); for (QString line = stream.readLine(); !line.isNull(); line = stream.readLine()) { @@ -216,11 +232,21 @@ void log_viewer::filter_log() if (m_filter_term.isEmpty() || line.contains(m_filter_term)) { - result += line + "\n"; + if (!m_show_threads) + { + line.remove(regexp); + } + + if (!line.isEmpty()) + { + result += line + "\n"; + } } }; + const int pos = m_log_text->verticalScrollBar()->value(); m_log_text->setPlainText(result); + m_log_text->verticalScrollBar()->setValue(pos); } bool log_viewer::is_valid_file(const QMimeData& md, bool save) diff --git a/rpcs3/rpcs3qt/log_viewer.h b/rpcs3/rpcs3qt/log_viewer.h index c85cdeedb2..340274e9c0 100644 --- a/rpcs3/rpcs3qt/log_viewer.h +++ b/rpcs3/rpcs3qt/log_viewer.h @@ -33,6 +33,7 @@ private: LogHighlighter* m_log_highlighter; std::unique_ptr m_find_dialog; std::bitset<32> m_log_levels = std::bitset<32>(0b11111111u); + bool m_show_threads = true; protected: void dropEvent(QDropEvent* ev) override;