Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log viewer improvements #13100

Merged
merged 3 commits into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions rpcs3/rpcs3qt/gui_settings.h
Expand Up @@ -115,6 +115,7 @@ namespace gui
const QString localization = "Localization";
const QString pad_settings = "PadSettings";
const QString config = "Config";
const QString log_viewer = "LogViewer";

const QString update_on = "true";
const QString update_off = "false";
Expand Down Expand Up @@ -252,6 +253,10 @@ namespace gui

const gui_save pads_show_emulated = gui_save(pad_settings, "show_emulated_values", false);
const gui_save pads_geometry = gui_save(pad_settings, "geometry", QByteArray());

const gui_save lv_show_timestamps = gui_save(log_viewer, "show_timestamps", true);
const gui_save lv_show_threads = gui_save(log_viewer, "show_threads", true);
const gui_save lv_log_levels = gui_save(log_viewer, "log_levels", 0b11111111u);
}

/** Class for GUI settings..
Expand Down
32 changes: 18 additions & 14 deletions rpcs3/rpcs3qt/log_viewer.cpp
Expand Up @@ -41,6 +41,9 @@ log_viewer::log_viewer(std::shared_ptr<gui_settings> gui_settings)
resize(QSize(620, 395));

m_path_last = m_gui_settings->GetValue(gui::fd_log_viewer).toString();
m_show_timestamps = m_gui_settings->GetValue(gui::lv_show_timestamps).toBool();
m_show_threads = m_gui_settings->GetValue(gui::lv_show_threads).toBool();
m_log_levels = std::bitset<32>(m_gui_settings->GetValue(gui::lv_log_levels).toUInt());

m_log_text = new QPlainTextEdit(this);
m_log_text->setReadOnly(true);
Expand Down Expand Up @@ -99,6 +102,7 @@ void log_viewer::show_context_menu(const QPoint& pos)
connect(act, &QAction::triggered, this, [this, logLevel](bool checked)
{
m_log_levels.set(static_cast<u32>(logLevel), checked);
m_gui_settings->SetValue(gui::lv_log_levels, ::narrow<u32>(m_log_levels.to_ulong()));
filter_log();
});
};
Expand Down Expand Up @@ -169,12 +173,14 @@ void log_viewer::show_context_menu(const QPoint& pos)
connect(threads, &QAction::toggled, this, [this](bool checked)
{
m_show_threads = checked;
m_gui_settings->SetValue(gui::lv_show_threads, m_show_threads);
filter_log();
});

connect(timestamps, &QAction::toggled, this, [this](bool checked)
{
m_show_timestamps = checked;
m_gui_settings->SetValue(gui::lv_show_timestamps, m_show_timestamps);
filter_log();
});

Expand Down Expand Up @@ -218,9 +224,8 @@ void log_viewer::show_log()
m_gui_settings->SetValue(gui::fd_log_viewer, m_path_last);

QTextStream stream(&file);
QString text = stream.readAll();
text.replace('\0', '0');
m_log_text->setPlainText(text);
m_full_log = stream.readAll();
m_full_log.replace('\0', '0');
file.close();
}
else
Expand All @@ -234,6 +239,9 @@ void log_viewer::show_log()

void log_viewer::set_text_and_keep_position(const QString& text)
{
m_log_text->setPlainText(tr("Pasting..."));
QApplication::processEvents();

const int pos = m_log_text->verticalScrollBar()->value();
m_log_text->setPlainText(text);
m_log_text->verticalScrollBar()->setValue(pos);
Expand All @@ -243,14 +251,12 @@ void log_viewer::filter_log()
{
if (m_full_log.isEmpty())
{
m_full_log = m_log_text->toPlainText();

if (m_full_log.isEmpty())
{
return;
}
set_text_and_keep_position(m_full_log);
return;
}

m_log_text->setPlainText(tr("Filtering..."));

std::vector<QString> excluded_log_levels;
if (!m_log_levels.test(static_cast<u32>(logs::level::fatal))) excluded_log_levels.push_back("·F ");
if (!m_log_levels.test(static_cast<u32>(logs::level::error))) excluded_log_levels.push_back("·E ");
Expand Down Expand Up @@ -353,11 +359,9 @@ void log_viewer::filter_log()
set_text_and_keep_position(result);
return;
}
else
{
QMessageBox::information(this, tr("Ooops!"), tr("Cannot find any game boot!"));
// Pass through to regular log filter
}

QMessageBox::information(this, tr("Ooops!"), tr("Cannot find any game boot!"));
// Pass through to regular log filter
}

if (!stream.seek(0))
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/syntax_highlighter.cpp
Expand Up @@ -15,7 +15,7 @@ void Highlighter::addRule(const QString &pattern, const QBrush &brush)

void Highlighter::highlightBlock(const QString &text)
{
for (const HighlightingRule &rule : highlightingRules)
for (const HighlightingRule& rule : highlightingRules)
{
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
while (matchIterator.hasNext())
Expand Down Expand Up @@ -168,7 +168,7 @@ GlslHighlighter::GlslHighlighter(QTextDocument *parent) : Highlighter(parent)
<< "r16_snorm" << "r32ui"
<< "r8_snorm" << "r16ui";

for (const QString &pattern : keywordPatterns)
for (const QString& pattern : keywordPatterns)
addRule("\\b" + pattern + "\\b", Qt::darkBlue); // normal words like: soka, nani, or gomen

addRule("\\bGL_(?:[A-Z]|_)+\\b", Qt::darkMagenta); // constants like: GL_OMAE_WA_MOU_SHINDEIRU
Expand Down