mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 07:21:25 +12:00
Add a "stack mode" to the TTY. (#6542)
* Added stack mode to TTY * fix declarations * Fixed spacing, removed namechange to preserve user settings, removed debug string * removed rename of "stack" * Add menu separator and remove whitespace
This commit is contained in:
parent
794a1fef1d
commit
cea975f6a6
3 changed files with 75 additions and 27 deletions
|
@ -192,6 +192,7 @@ namespace gui
|
||||||
const gui_save l_tty = gui_save(logger, "TTY", true);
|
const gui_save l_tty = gui_save(logger, "TTY", true);
|
||||||
const gui_save l_level = gui_save(logger, "level", (uint)(logs::level::success));
|
const gui_save l_level = gui_save(logger, "level", (uint)(logs::level::success));
|
||||||
const gui_save l_stack = gui_save(logger, "stack", true);
|
const gui_save l_stack = gui_save(logger, "stack", true);
|
||||||
|
const gui_save l_stack_tty = gui_save(logger, "TTY stack", false);
|
||||||
|
|
||||||
const gui_save d_splitterState = gui_save(debugger, "splitterState", QByteArray());
|
const gui_save d_splitterState = gui_save(debugger, "splitterState", QByteArray());
|
||||||
const gui_save d_centerPC = gui_save(debugger, "centerPC", false);
|
const gui_save d_centerPC = gui_save(debugger, "centerPC", false);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "log_frame.h"
|
#include "log_frame.h"
|
||||||
#include "qt_utils.h"
|
#include "qt_utils.h"
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "rpcs3_version.h"
|
#include "rpcs3_version.h"
|
||||||
#include "Utilities/sysinfo.h"
|
#include "Utilities/sysinfo.h"
|
||||||
|
@ -10,7 +9,7 @@
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <sstream>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "Utilities/mutex.h"
|
#include "Utilities/mutex.h"
|
||||||
|
@ -227,8 +226,15 @@ void log_frame::CreateAndConnectActions()
|
||||||
m_clearTTYAct = new QAction(tr("Clear"), this);
|
m_clearTTYAct = new QAction(tr("Clear"), this);
|
||||||
connect(m_clearTTYAct, &QAction::triggered, m_tty, &QTextEdit::clear);
|
connect(m_clearTTYAct, &QAction::triggered, m_tty, &QTextEdit::clear);
|
||||||
|
|
||||||
m_tty_channel_acts = new QActionGroup(this);
|
m_stackAct_tty = new QAction(tr("Stack Mode (TTY)"), this);
|
||||||
|
m_stackAct_tty->setCheckable(true);
|
||||||
|
connect(m_stackAct_tty, &QAction::toggled, xgui_settings.get(), [=](bool checked)
|
||||||
|
{
|
||||||
|
xgui_settings->SetValue(gui::l_stack_tty, checked);
|
||||||
|
m_stack_tty = checked;
|
||||||
|
});
|
||||||
|
|
||||||
|
m_tty_channel_acts = new QActionGroup(this);
|
||||||
// Special Channel: All
|
// Special Channel: All
|
||||||
QAction* all_channels_act = new QAction(tr("All user channels"), m_tty_channel_acts);
|
QAction* all_channels_act = new QAction(tr("All user channels"), m_tty_channel_acts);
|
||||||
all_channels_act->setCheckable(true);
|
all_channels_act->setCheckable(true);
|
||||||
|
@ -263,9 +269,9 @@ void log_frame::CreateAndConnectActions()
|
||||||
m_noticeAct = new QAction(tr("Notice"), m_logLevels);
|
m_noticeAct = new QAction(tr("Notice"), m_logLevels);
|
||||||
m_traceAct = new QAction(tr("Trace"), m_logLevels);
|
m_traceAct = new QAction(tr("Trace"), m_logLevels);
|
||||||
|
|
||||||
m_stackAct = new QAction(tr("Stack Mode"), this);
|
m_stackAct_log = new QAction(tr("Stack Mode (Log)"), this);
|
||||||
m_stackAct->setCheckable(true);
|
m_stackAct_log->setCheckable(true);
|
||||||
connect(m_stackAct, &QAction::toggled, xgui_settings.get(), [=](bool checked)
|
connect(m_stackAct_log, &QAction::toggled, xgui_settings.get(), [=](bool checked)
|
||||||
{
|
{
|
||||||
xgui_settings->SetValue(gui::l_stack, checked);
|
xgui_settings->SetValue(gui::l_stack, checked);
|
||||||
m_stack_log = checked;
|
m_stack_log = checked;
|
||||||
|
@ -294,7 +300,7 @@ void log_frame::CreateAndConnectActions()
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addActions(m_logLevels->actions());
|
menu->addActions(m_logLevels->actions());
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(m_stackAct);
|
menu->addAction(m_stackAct_log);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(m_TTYAct);
|
menu->addAction(m_TTYAct);
|
||||||
menu->exec(mapToGlobal(pos));
|
menu->exec(mapToGlobal(pos));
|
||||||
|
@ -305,6 +311,8 @@ void log_frame::CreateAndConnectActions()
|
||||||
QMenu* menu = m_tty->createStandardContextMenu();
|
QMenu* menu = m_tty->createStandardContextMenu();
|
||||||
menu->addAction(m_clearTTYAct);
|
menu->addAction(m_clearTTYAct);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
menu->addAction(m_stackAct_tty);
|
||||||
|
menu->addSeparator();
|
||||||
menu->addActions(m_tty_channel_acts->actions());
|
menu->addActions(m_tty_channel_acts->actions());
|
||||||
menu->exec(mapToGlobal(pos));
|
menu->exec(mapToGlobal(pos));
|
||||||
});
|
});
|
||||||
|
@ -359,7 +367,9 @@ void log_frame::LoadSettings()
|
||||||
SetLogLevel(xgui_settings->GetLogLevel());
|
SetLogLevel(xgui_settings->GetLogLevel());
|
||||||
SetTTYLogging(xgui_settings->GetValue(gui::l_tty).toBool());
|
SetTTYLogging(xgui_settings->GetValue(gui::l_tty).toBool());
|
||||||
m_stack_log = xgui_settings->GetValue(gui::l_stack).toBool();
|
m_stack_log = xgui_settings->GetValue(gui::l_stack).toBool();
|
||||||
m_stackAct->setChecked(m_stack_log);
|
m_stack_tty = xgui_settings->GetValue(gui::l_stack_tty).toBool();
|
||||||
|
m_stackAct_log->setChecked(m_stack_log);
|
||||||
|
m_stackAct_tty->setChecked(m_stack_tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_frame::RepaintTextColors()
|
void log_frame::RepaintTextColors()
|
||||||
|
@ -467,9 +477,41 @@ void log_frame::UpdateUI()
|
||||||
// clear selection or else it will get colorized as well
|
// clear selection or else it will get colorized as well
|
||||||
text_cursor.clearSelection();
|
text_cursor.clearSelection();
|
||||||
|
|
||||||
|
std::stringstream buf_stream;
|
||||||
|
buf_stream.str(buf);
|
||||||
|
std::string buf_line;
|
||||||
|
while (std::getline(buf_stream, buf_line))
|
||||||
|
{
|
||||||
|
QString suffix;
|
||||||
|
QString tty_text = QString::fromStdString(buf_line);
|
||||||
|
bool isSame = tty_text == m_old_tty_text;
|
||||||
|
// create counter suffix and remove recurring line if needed
|
||||||
|
if (m_stack_tty)
|
||||||
|
{
|
||||||
|
if (isSame)
|
||||||
|
{
|
||||||
|
m_tty_counter++;
|
||||||
|
suffix = QString(" x%1").arg(m_tty_counter);
|
||||||
|
m_tty->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||||
|
m_tty->moveCursor(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
|
||||||
|
m_tty->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor);
|
||||||
|
m_tty->textCursor().removeSelectedText();
|
||||||
|
m_tty->textCursor().deletePreviousChar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_tty_counter = 1;
|
||||||
|
m_old_tty_text = tty_text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// write text to the end
|
// write text to the end
|
||||||
text_cursor.movePosition(QTextCursor::End);
|
m_tty->append(tty_text);
|
||||||
text_cursor.insertText(qstr(buf));
|
// add counter suffix if needed
|
||||||
|
if (isSame && m_stack_tty)
|
||||||
|
{
|
||||||
|
m_tty->insertPlainText(suffix);
|
||||||
|
}
|
||||||
|
|
||||||
// if we mark text from right to left we need to swap sides (start is always smaller than end)
|
// if we mark text from right to left we need to swap sides (start is always smaller than end)
|
||||||
if (sel_pos < sel_end)
|
if (sel_pos < sel_end)
|
||||||
|
@ -485,6 +527,7 @@ void log_frame::UpdateUI()
|
||||||
// set scrollbar to max means auto-scroll
|
// set scrollbar to max means auto-scroll
|
||||||
sb->setValue(is_max ? sb->maximum() : sb_pos);
|
sb->setValue(is_max ? sb->maximum() : sb_pos);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Limit processing time
|
// Limit processing time
|
||||||
if (steady_clock::now() >= start + 4ms || buf.empty()) break;
|
if (steady_clock::now() >= start + 4ms || buf.empty()) break;
|
||||||
|
@ -530,7 +573,7 @@ void log_frame::UpdateUI()
|
||||||
text.chop(1);
|
text.chop(1);
|
||||||
|
|
||||||
QString suffix;
|
QString suffix;
|
||||||
bool isSame = text == m_old_text;
|
bool isSame = text == m_old_log_text;
|
||||||
|
|
||||||
// create counter suffix and remove recurring line if needed
|
// create counter suffix and remove recurring line if needed
|
||||||
if (m_stack_log)
|
if (m_stack_log)
|
||||||
|
@ -548,7 +591,7 @@ void log_frame::UpdateUI()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log_counter = 1;
|
m_log_counter = 1;
|
||||||
m_old_text = text;
|
m_old_log_text = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,12 @@ private:
|
||||||
QList<QColor> m_color;
|
QList<QColor> m_color;
|
||||||
QColor m_color_stack;
|
QColor m_color_stack;
|
||||||
QTextEdit* m_log;
|
QTextEdit* m_log;
|
||||||
QString m_old_text;
|
QString m_old_log_text;
|
||||||
|
QString m_old_tty_text;
|
||||||
ullong m_log_counter;
|
ullong m_log_counter;
|
||||||
|
ullong m_tty_counter;
|
||||||
bool m_stack_log;
|
bool m_stack_log;
|
||||||
|
bool m_stack_tty;
|
||||||
|
|
||||||
fs::file m_tty_file;
|
fs::file m_tty_file;
|
||||||
QWidget* m_tty_container;
|
QWidget* m_tty_container;
|
||||||
|
@ -72,7 +75,8 @@ private:
|
||||||
QAction* m_noticeAct;
|
QAction* m_noticeAct;
|
||||||
QAction* m_traceAct;
|
QAction* m_traceAct;
|
||||||
|
|
||||||
QAction* m_stackAct;
|
QAction* m_stackAct_log;
|
||||||
|
QAction* m_stackAct_tty;
|
||||||
|
|
||||||
QAction* m_TTYAct;
|
QAction* m_TTYAct;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue