mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-17 15:59:50 +00:00
Qt: add show threads option to log viewer
This commit is contained in:
parent
3ed5a935fb
commit
8f02ea1d42
2 changed files with 29 additions and 2 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
LOG_CHANNEL(gui_log, "GUI");
|
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* open = new QAction(tr("&Open log file"));
|
||||||
QAction* filter = new QAction(tr("&Filter log"));
|
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);
|
QActionGroup* log_level_acts = new QActionGroup(this);
|
||||||
QAction* fatal_act = new QAction(tr("Fatal"), log_level_acts);
|
QAction* fatal_act = new QAction(tr("Fatal"), log_level_acts);
|
||||||
QAction* error_act = new QAction(tr("Error"), 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.addSeparator();
|
||||||
menu.addAction(filter);
|
menu.addAction(filter);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
menu.addAction(threads);
|
||||||
|
menu.addSeparator();
|
||||||
menu.addActions(log_level_acts->actions());
|
menu.addActions(log_level_acts->actions());
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(clear);
|
menu.addAction(clear);
|
||||||
|
@ -122,6 +129,12 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
||||||
filter_log();
|
filter_log();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(threads, &QAction::toggled, this, [this](bool checked)
|
||||||
|
{
|
||||||
|
m_show_threads = checked;
|
||||||
|
filter_log();
|
||||||
|
});
|
||||||
|
|
||||||
const auto obj = qobject_cast<QPlainTextEdit*>(sender());
|
const auto obj = qobject_cast<QPlainTextEdit*>(sender());
|
||||||
|
|
||||||
QPoint origin;
|
QPoint origin;
|
||||||
|
@ -187,14 +200,17 @@ void log_viewer::filter_log()
|
||||||
if (!m_log_levels.test(static_cast<u32>(logs::level::notice))) excluded_log_levels.push_back("·! ");
|
if (!m_log_levels.test(static_cast<u32>(logs::level::notice))) excluded_log_levels.push_back("·! ");
|
||||||
if (!m_log_levels.test(static_cast<u32>(logs::level::trace))) excluded_log_levels.push_back("·T ");
|
if (!m_log_levels.test(static_cast<u32>(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->setPlainText(m_full_log);
|
||||||
|
m_log_text->verticalScrollBar()->setValue(pos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
|
QRegularExpression regexp("\{.*\} ");
|
||||||
QTextStream stream(&m_full_log);
|
QTextStream stream(&m_full_log);
|
||||||
for (QString line = stream.readLine(); !line.isNull(); line = stream.readLine())
|
for (QString line = stream.readLine(); !line.isNull(); line = stream.readLine())
|
||||||
{
|
{
|
||||||
|
@ -215,12 +231,22 @@ void log_viewer::filter_log()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_filter_term.isEmpty() || line.contains(m_filter_term))
|
if (m_filter_term.isEmpty() || line.contains(m_filter_term))
|
||||||
|
{
|
||||||
|
if (!m_show_threads)
|
||||||
|
{
|
||||||
|
line.remove(regexp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!line.isEmpty())
|
||||||
{
|
{
|
||||||
result += line + "\n";
|
result += line + "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const int pos = m_log_text->verticalScrollBar()->value();
|
||||||
m_log_text->setPlainText(result);
|
m_log_text->setPlainText(result);
|
||||||
|
m_log_text->verticalScrollBar()->setValue(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool log_viewer::is_valid_file(const QMimeData& md, bool save)
|
bool log_viewer::is_valid_file(const QMimeData& md, bool save)
|
||||||
|
|
|
@ -33,6 +33,7 @@ private:
|
||||||
LogHighlighter* m_log_highlighter;
|
LogHighlighter* m_log_highlighter;
|
||||||
std::unique_ptr<find_dialog> m_find_dialog;
|
std::unique_ptr<find_dialog> m_find_dialog;
|
||||||
std::bitset<32> m_log_levels = std::bitset<32>(0b11111111u);
|
std::bitset<32> m_log_levels = std::bitset<32>(0b11111111u);
|
||||||
|
bool m_show_threads = true;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dropEvent(QDropEvent* ev) override;
|
void dropEvent(QDropEvent* ev) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue