[Qt] style adjustments 5

rename even more members and clean headers
adjust some more connects
move some function bodies to cpp
This commit is contained in:
Megamouse 2017-09-06 20:13:01 +02:00 committed by Ani
parent 95231c4dee
commit 43bae9f9d7
8 changed files with 189 additions and 197 deletions

View File

@ -11,15 +11,12 @@ extern bool user_asked_for_frame_capture;
debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *parent) debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *parent)
: QDockWidget(tr("Debugger"), parent), xgui_settings(settings) : QDockWidget(tr("Debugger"), parent), xgui_settings(settings)
{ {
pSize = 10; m_update = new QTimer(this);
connect(m_update, &QTimer::timeout, this, &debugger_frame::UpdateUI);
update = new QTimer(this);
connect(update, &QTimer::timeout, this, &debugger_frame::UpdateUI);
EnableUpdateTimer(true); EnableUpdateTimer(true);
body = new QWidget(this); m_mono = QFontDatabase::systemFont(QFontDatabase::FixedFont);
mono = QFontDatabase::systemFont(QFontDatabase::FixedFont); m_mono.setPointSize(10);
mono.setPointSize(pSize);
QVBoxLayout* vbox_p_main = new QVBoxLayout(); QVBoxLayout* vbox_p_main = new QVBoxLayout();
QHBoxLayout* hbox_b_main = new QHBoxLayout(); QHBoxLayout* hbox_b_main = new QHBoxLayout();
@ -57,8 +54,8 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *
m_regs->setLineWrapMode(QTextEdit::NoWrap); m_regs->setLineWrapMode(QTextEdit::NoWrap);
m_regs->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); m_regs->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
m_list->setFont(mono); m_list->setFont(m_mono);
m_regs->setFont(mono); m_regs->setFont(m_mono);
m_splitter = new QSplitter(this); m_splitter = new QSplitter(this);
m_splitter->addWidget(m_list); m_splitter->addWidget(m_list);
@ -70,6 +67,7 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *
vbox_p_main->addLayout(hbox_b_main); vbox_p_main->addLayout(hbox_b_main);
vbox_p_main->addLayout(hbox_w_list); vbox_p_main->addLayout(hbox_w_list);
QWidget* body = new QWidget(this);
body->setLayout(vbox_p_main); body->setLayout(vbox_p_main);
setWidget(body); setWidget(body);
@ -191,7 +189,7 @@ void debugger_frame::UpdateUI()
{ {
UpdateUnitList(); UpdateUnitList();
if (m_noThreadSelected) return; if (m_no_thread_selected) return;
const auto cpu = this->cpu.lock(); const auto cpu = this->cpu.lock();
@ -279,13 +277,13 @@ void debugger_frame::OnSelectUnit()
if (m_choice_units->count() < 1 || m_current_choice == m_choice_units->currentText()) return; if (m_choice_units->count() < 1 || m_current_choice == m_choice_units->currentText()) return;
m_current_choice = m_choice_units->currentText(); m_current_choice = m_choice_units->currentText();
m_noThreadSelected = m_current_choice == NoThread; m_no_thread_selected = m_current_choice == NoThread;
m_list->m_noThreadSelected = m_noThreadSelected; m_list->m_no_thread_selected = m_no_thread_selected;
m_disasm.reset(); m_disasm.reset();
cpu.reset(); cpu.reset();
if (!m_noThreadSelected) if (!m_no_thread_selected)
{ {
const auto on_select = [&](u32, cpu_thread& cpu) const auto on_select = [&](u32, cpu_thread& cpu)
{ {
@ -356,11 +354,11 @@ void debugger_frame::Show_Val()
QHBoxLayout* hbox_text_panel(new QHBoxLayout()); QHBoxLayout* hbox_text_panel(new QHBoxLayout());
QHBoxLayout* hbox_button_panel(new QHBoxLayout()); QHBoxLayout* hbox_button_panel(new QHBoxLayout());
QLineEdit* p_pc(new QLineEdit(diag)); QLineEdit* p_pc(new QLineEdit(diag));
p_pc->setFont(mono); p_pc->setFont(m_mono);
p_pc->setMaxLength(8); p_pc->setMaxLength(8);
p_pc->setFixedWidth(90); p_pc->setFixedWidth(90);
QLabel* addr(new QLabel(diag)); QLabel* addr(new QLabel(diag));
addr->setFont(mono); addr->setFont(m_mono);
hbox_text_panel->addWidget(addr); hbox_text_panel->addWidget(addr);
hbox_text_panel->addWidget(p_pc); hbox_text_panel->addWidget(p_pc);
@ -450,7 +448,7 @@ void debugger_frame::DoStep()
void debugger_frame::EnableUpdateTimer(bool enable) void debugger_frame::EnableUpdateTimer(bool enable)
{ {
enable ? update->start(50) : update->stop(); enable ? m_update->start(50) : m_update->stop();
} }
void debugger_frame::EnableButtons(bool enable) void debugger_frame::EnableButtons(bool enable)
@ -589,7 +587,7 @@ void debugger_list::keyPressEvent(QKeyEvent* event)
void debugger_list::mouseDoubleClickEvent(QMouseEvent* event) void debugger_list::mouseDoubleClickEvent(QMouseEvent* event)
{ {
if (event->button() == Qt::LeftButton && !Emu.IsStopped() && !m_noThreadSelected) if (event->button() == Qt::LeftButton && !Emu.IsStopped() && !m_no_thread_selected)
{ {
long i = currentRow(); long i = currentRow();
if (i < 0) return; if (i < 0) return;

View File

@ -35,10 +35,8 @@ class debugger_frame : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
QWidget* body;
debugger_list* m_list; debugger_list* m_list;
int pSize; QFont m_mono;
QFont mono;
QTextEdit* m_regs; QTextEdit* m_regs;
QPushButton* m_go_to_addr; QPushButton* m_go_to_addr;
QPushButton* m_go_to_pc; QPushButton* m_go_to_pc;
@ -47,14 +45,14 @@ class debugger_frame : public QDockWidget
QPushButton* m_btn_run; QPushButton* m_btn_run;
QComboBox* m_choice_units; QComboBox* m_choice_units;
QString m_current_choice; QString m_current_choice;
bool m_noThreadSelected = true; bool m_no_thread_selected = true;
u64 m_threads_created = 0; u64 m_threads_created = 0;
u64 m_threads_deleted = 0; u64 m_threads_deleted = 0;
u32 m_last_pc = -1; u32 m_last_pc = -1;
u32 m_last_stat = 0; u32 m_last_stat = 0;
QTimer* update; QTimer* m_update;
QSplitter* m_splitter; QSplitter* m_splitter;
const QString NoThread = tr("No Thread"); const QString NoThread = tr("No Thread");
@ -109,7 +107,7 @@ class debugger_list : public QListWidget
public: public:
u32 m_pc; u32 m_pc;
u32 m_item_count; u32 m_item_count;
bool m_noThreadSelected; bool m_no_thread_selected;
public: public:
debugger_list(debugger_frame* parent); debugger_list(debugger_frame* parent);

View File

@ -8,14 +8,19 @@
inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); } inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); }
gui_settings::gui_settings(QObject* parent) : QObject(parent), settings(ComputeSettingsDir() + tr("CurrentSettings") + ".ini", QSettings::Format::IniFormat, parent), gui_settings::gui_settings(QObject* parent) : QObject(parent), m_settings(ComputeSettingsDir() + tr("CurrentSettings") + ".ini", QSettings::Format::IniFormat, parent),
settingsDir(ComputeSettingsDir()) m_settingsDir(ComputeSettingsDir())
{ {
} }
gui_settings::~gui_settings() gui_settings::~gui_settings()
{ {
settings.sync(); m_settings.sync();
}
QString gui_settings::GetSettingsDir()
{
return m_settingsDir.absolutePath();
} }
QString gui_settings::ComputeSettingsDir() QString gui_settings::ComputeSettingsDir()
@ -29,14 +34,14 @@ void gui_settings::ChangeToConfig(const QString& name)
{ // don't try to change to yourself. { // don't try to change to yourself.
Reset(false); Reset(false);
QSettings other(settingsDir.absoluteFilePath(name + ".ini"), QSettings::IniFormat); QSettings other(m_settingsDir.absoluteFilePath(name + ".ini"), QSettings::IniFormat);
QStringList keys = other.allKeys(); QStringList keys = other.allKeys();
for (QStringList::iterator i = keys.begin(); i != keys.end(); i++) for (QStringList::iterator i = keys.begin(); i != keys.end(); i++)
{ {
settings.setValue(*i, other.value(*i)); m_settings.setValue(*i, other.value(*i));
} }
settings.sync(); m_settings.sync();
} }
} }
@ -44,19 +49,19 @@ void gui_settings::Reset(bool removeMeta)
{ {
if (removeMeta) if (removeMeta)
{ {
settings.clear(); m_settings.clear();
} }
else else
{ {
settings.remove(GUI::logger); m_settings.remove(GUI::logger);
settings.remove(GUI::main_window); m_settings.remove(GUI::main_window);
settings.remove(GUI::game_list); m_settings.remove(GUI::game_list);
} }
} }
QVariant gui_settings::GetValue(const GUI_SAVE& entry) QVariant gui_settings::GetValue(const GUI_SAVE& entry)
{ {
return settings.value(entry.key + "/" + entry.name, entry.def); return m_settings.value(entry.key + "/" + entry.name, entry.def);
} }
QVariant gui_settings::List2Var(const q_pair_list& list) QVariant gui_settings::List2Var(const q_pair_list& list)
@ -138,9 +143,9 @@ QPixmap gui_settings::colorizedPixmap(const QPixmap& old_pixmap, const QColor& o
void gui_settings::SetValue(const GUI_SAVE& entry, const QVariant& value) void gui_settings::SetValue(const GUI_SAVE& entry, const QVariant& value)
{ {
settings.beginGroup(entry.key); m_settings.beginGroup(entry.key);
settings.setValue(entry.name, value); m_settings.setValue(entry.name, value);
settings.endGroup(); m_settings.endGroup();
} }
QStringList gui_settings::GetGameListCategoryFilters() QStringList gui_settings::GetGameListCategoryFilters()
@ -269,7 +274,7 @@ QStringList gui_settings::GetConfigEntries()
{ {
QStringList nameFilter; QStringList nameFilter;
nameFilter << "*.ini"; nameFilter << "*.ini";
QFileInfoList entries = settingsDir.entryInfoList(nameFilter, QDir::Files); QFileInfoList entries = m_settingsDir.entryInfoList(nameFilter, QDir::Files);
QStringList res; QStringList res;
for (QFileInfo entry : entries) for (QFileInfo entry : entries)
{ {
@ -282,12 +287,12 @@ QStringList gui_settings::GetConfigEntries()
void gui_settings::BackupSettingsToTarget(const QString& friendlyName) void gui_settings::BackupSettingsToTarget(const QString& friendlyName)
{ {
QSettings target(ComputeSettingsDir() + friendlyName + ".ini", QSettings::Format::IniFormat); QSettings target(ComputeSettingsDir() + friendlyName + ".ini", QSettings::Format::IniFormat);
QStringList keys = settings.allKeys(); QStringList keys = m_settings.allKeys();
for (QStringList::iterator i = keys.begin(); i != keys.end(); i++) for (QStringList::iterator i = keys.begin(); i != keys.end(); i++)
{ {
if (!i->startsWith(GUI::meta)) if (!i->startsWith(GUI::meta))
{ {
target.setValue(*i, settings.value(*i)); target.setValue(*i, m_settings.value(*i));
} }
} }
target.sync(); target.sync();
@ -297,8 +302,8 @@ QStringList gui_settings::GetStylesheetEntries()
{ {
QStringList nameFilter; QStringList nameFilter;
nameFilter << "*.qss"; nameFilter << "*.qss";
QString path = settingsDir.absolutePath(); QString path = m_settingsDir.absolutePath();
QFileInfoList entries = settingsDir.entryInfoList(nameFilter, QDir::Files); QFileInfoList entries = m_settingsDir.entryInfoList(nameFilter, QDir::Files);
QStringList res; QStringList res;
for (QFileInfo entry : entries) for (QFileInfo entry : entries)
{ {
@ -317,5 +322,5 @@ QString gui_settings::GetCurrentStylesheetPath()
return ""; return "";
} }
return settingsDir.absoluteFilePath(stylesheet + ".qss"); return m_settingsDir.absoluteFilePath(stylesheet + ".qss");
} }

View File

@ -166,9 +166,7 @@ public:
explicit gui_settings(QObject* parent = nullptr); explicit gui_settings(QObject* parent = nullptr);
~gui_settings(); ~gui_settings();
QString GetSettingsDir() { QString GetSettingsDir();
return settingsDir.absolutePath();
}
/** Changes the settings file to the destination preset*/ /** Changes the settings file to the destination preset*/
void ChangeToConfig(const QString& destination); void ChangeToConfig(const QString& destination);
@ -217,6 +215,6 @@ private:
QString ComputeSettingsDir(); QString ComputeSettingsDir();
void BackupSettingsToTarget(const QString& destination); void BackupSettingsToTarget(const QString& destination);
QSettings settings; QSettings m_settings;
QDir settingsDir; QDir m_settingsDir;
}; };

View File

@ -102,42 +102,31 @@ static gui_listener s_gui_listener;
log_frame::log_frame(std::shared_ptr<gui_settings> guiSettings, QWidget *parent) : QDockWidget(tr("Log"), parent), xgui_settings(guiSettings) log_frame::log_frame(std::shared_ptr<gui_settings> guiSettings, QWidget *parent) : QDockWidget(tr("Log"), parent), xgui_settings(guiSettings)
{ {
tabWidget = new QTabWidget; QTabWidget* tabWidget = new QTabWidget;
log = new QTextEdit(tabWidget); m_log = new QTextEdit(tabWidget);
QPalette logPalette = log->palette(); QPalette logPalette = m_log->palette();
logPalette.setColor(QPalette::Base, Qt::black); logPalette.setColor(QPalette::Base, Qt::black);
log->setPalette(logPalette); m_log->setPalette(logPalette);
log->setReadOnly(true); m_log->setReadOnly(true);
m_log->setContextMenuPolicy(Qt::CustomContextMenu);
tty = new QTextEdit(tabWidget); m_tty = new QTextEdit(tabWidget);
QPalette ttyPalette = log->palette(); QPalette ttyPalette = m_log->palette();
ttyPalette.setColor(QPalette::Base, Qt::black); ttyPalette.setColor(QPalette::Base, Qt::black);
ttyPalette.setColor(QPalette::Text, Qt::white); ttyPalette.setColor(QPalette::Text, Qt::white);
tty->setPalette(ttyPalette); m_tty->setPalette(ttyPalette);
tty->setReadOnly(true); m_tty->setReadOnly(true);
tabWidget->addTab(log, tr("Log")); tabWidget->addTab(m_log, tr("Log"));
tabWidget->addTab(tty, tr("TTY")); tabWidget->addTab(m_tty, tr("TTY"));
setWidget(tabWidget); setWidget(tabWidget);
// Open or create TTY.log // Open or create TTY.log
tty_file.open(fs::get_config_dir() + "TTY.log", fs::read + fs::create); m_tty_file.open(fs::get_config_dir() + "TTY.log", fs::read + fs::create);
CreateAndConnectActions(); CreateAndConnectActions();
log->setContextMenuPolicy(Qt::CustomContextMenu);
connect(log, &QWidget::customContextMenuRequested, [=](const QPoint& pos){
QMenu* menu = log->createStandardContextMenu();
menu->addAction(clearAct);
menu->addSeparator();
menu->addActions({ nothingAct, fatalAct, errorAct, todoAct, successAct, warningAct, noticeAct, traceAct });
menu->addSeparator();
menu->addAction(stackAct);
menu->addSeparator();
menu->addAction(TTYAct);
menu->exec(mapToGlobal(pos));
});
// Check for updates every ~10 ms // Check for updates every ~10 ms
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
@ -152,47 +141,47 @@ void log_frame::SetLogLevel(logs::level lev)
case logs::level::always: case logs::level::always:
case logs::level::fatal: case logs::level::fatal:
{ {
fatalAct->trigger(); m_fatalAct->trigger();
break; break;
} }
case logs::level::error: case logs::level::error:
{ {
errorAct->trigger(); m_errorAct->trigger();
break; break;
} }
case logs::level::todo: case logs::level::todo:
{ {
todoAct->trigger(); m_todoAct->trigger();
break; break;
} }
case logs::level::success: case logs::level::success:
{ {
successAct->trigger(); m_successAct->trigger();
break; break;
} }
case logs::level::warning: case logs::level::warning:
{ {
warningAct->trigger(); m_warningAct->trigger();
break; break;
} }
case logs::level::notice: case logs::level::notice:
{ {
noticeAct->trigger(); m_noticeAct->trigger();
break; break;
} }
case logs::level::trace: case logs::level::trace:
{ {
traceAct->trigger(); m_traceAct->trigger();
break; break;
} }
default: default:
warningAct->trigger(); m_warningAct->trigger();
} }
} }
void log_frame::SetTTYLogging(bool val) void log_frame::SetTTYLogging(bool val)
{ {
TTYAct->setChecked(val); m_TTYAct->setChecked(val);
} }
void log_frame::CreateAndConnectActions() void log_frame::CreateAndConnectActions()
@ -212,42 +201,57 @@ void log_frame::CreateAndConnectActions()
}); });
}; };
clearAct = new QAction(tr("Clear"), this); m_clearAct = new QAction(tr("Clear"), this);
connect(clearAct, &QAction::triggered, log, &QTextEdit::clear); connect(m_clearAct, &QAction::triggered, m_log, &QTextEdit::clear);
// Action groups make these actions mutually exclusive. // Action groups make these actions mutually exclusive.
logLevels = new QActionGroup(this); m_logLevels = new QActionGroup(this);
nothingAct = new QAction(tr("Nothing"), logLevels); m_nothingAct = new QAction(tr("Nothing"), m_logLevels);
nothingAct->setVisible(false); m_nothingAct->setVisible(false);
fatalAct = new QAction(tr("Fatal"), logLevels); m_fatalAct = new QAction(tr("Fatal"), m_logLevels);
errorAct = new QAction(tr("Error"), logLevels); m_errorAct = new QAction(tr("Error"), m_logLevels);
todoAct = new QAction(tr("Todo"), logLevels); m_todoAct = new QAction(tr("Todo"), m_logLevels);
successAct = new QAction(tr("Success"), logLevels); m_successAct = new QAction(tr("Success"), m_logLevels);
warningAct = new QAction(tr("Warning"), logLevels); m_warningAct = new QAction(tr("Warning"), m_logLevels);
noticeAct = new QAction(tr("Notice"), logLevels); m_noticeAct = new QAction(tr("Notice"), m_logLevels);
traceAct = new QAction(tr("Trace"), logLevels); m_traceAct = new QAction(tr("Trace"), m_logLevels);
stackAct = new QAction(tr("Stack Mode"), this); m_stackAct = new QAction(tr("Stack Mode"), this);
stackAct->setCheckable(true); m_stackAct->setCheckable(true);
connect(stackAct, &QAction::toggled, xgui_settings.get(), [=](bool checked) { connect(m_stackAct, &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;
}); });
TTYAct = new QAction(tr("TTY"), this); m_TTYAct = new QAction(tr("TTY"), this);
TTYAct->setCheckable(true); m_TTYAct->setCheckable(true);
connect(TTYAct, &QAction::triggered, xgui_settings.get(), [=](bool checked){ connect(m_TTYAct, &QAction::triggered, xgui_settings.get(), [=](bool checked)
{
xgui_settings->SetValue(GUI::l_tty, checked); xgui_settings->SetValue(GUI::l_tty, checked);
}); });
l_initAct(nothingAct, logs::level::fatal); l_initAct(m_nothingAct, logs::level::fatal);
l_initAct(fatalAct, logs::level::fatal); l_initAct(m_fatalAct, logs::level::fatal);
l_initAct(errorAct, logs::level::error); l_initAct(m_errorAct, logs::level::error);
l_initAct(todoAct, logs::level::todo); l_initAct(m_todoAct, logs::level::todo);
l_initAct(successAct, logs::level::success); l_initAct(m_successAct, logs::level::success);
l_initAct(warningAct, logs::level::warning); l_initAct(m_warningAct, logs::level::warning);
l_initAct(noticeAct, logs::level::notice); l_initAct(m_noticeAct, logs::level::notice);
l_initAct(traceAct, logs::level::trace); l_initAct(m_traceAct, logs::level::trace);
connect(m_log, &QWidget::customContextMenuRequested, [=](const QPoint& pos)
{
QMenu* menu = m_log->createStandardContextMenu();
menu->addAction(m_clearAct);
menu->addSeparator();
menu->addActions({ m_nothingAct, m_fatalAct, m_errorAct, m_todoAct, m_successAct, m_warningAct, m_noticeAct, m_traceAct });
menu->addSeparator();
menu->addAction(m_stackAct);
menu->addSeparator();
menu->addAction(m_TTYAct);
menu->exec(mapToGlobal(pos));
});
LoadSettings(); LoadSettings();
} }
@ -257,7 +261,7 @@ 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();
stackAct->setChecked(m_stack_log); m_stackAct->setChecked(m_stack_log);
} }
void log_frame::UpdateUI() void log_frame::UpdateUI()
@ -291,15 +295,15 @@ void log_frame::UpdateUI()
// Check TTY logs // Check TTY logs
while (const u64 size = std::min<u64>(buf.size(), tty_file.size() - tty_file.pos())) while (const u64 size = std::min<u64>(buf.size(), m_tty_file.size() - m_tty_file.pos()))
{ {
QString text = get_utf8(tty_file, size); QString text = get_utf8(m_tty_file, size);
// Hackily used the state of the check.. be better if I actually stored this value. // Hackily used the state of the check.. be better if I actually stored this value.
if (TTYAct->isChecked()) if (m_TTYAct->isChecked())
{ {
text.chop(1); // remove newline since Qt automatically adds a newline. text.chop(1); // remove newline since Qt automatically adds a newline.
tty->append(text); m_tty->append(text);
} }
// Limit processing time // Limit processing time
if (steady_clock::now() >= start + 4ms || text.isEmpty()) break; if (steady_clock::now() >= start + 4ms || text.isEmpty()) break;
@ -331,17 +335,17 @@ void log_frame::UpdateUI()
text += qstr(packet->msg); text += qstr(packet->msg);
// save old log state // save old log state
QScrollBar *sb = log->verticalScrollBar(); QScrollBar *sb = m_log->verticalScrollBar();
bool isMax = sb->value() == sb->maximum(); bool isMax = sb->value() == sb->maximum();
int sb_pos = sb->value(); int sb_pos = sb->value();
int sel_pos = log->textCursor().position(); int sel_pos = m_log->textCursor().position();
int sel_start = log->textCursor().selectionStart(); int sel_start = m_log->textCursor().selectionStart();
int sel_end = log->textCursor().selectionEnd(); int sel_end = m_log->textCursor().selectionEnd();
// clear selection or else it will get colorized as well // clear selection or else it will get colorized as well
QTextCursor c = log->textCursor(); QTextCursor c = m_log->textCursor();
c.clearSelection(); c.clearSelection();
log->setTextCursor(c); m_log->setTextCursor(c);
// remove the new line because Qt's append adds a new line already. // remove the new line because Qt's append adds a new line already.
text.chop(1); text.chop(1);
@ -356,11 +360,11 @@ void log_frame::UpdateUI()
{ {
m_log_counter++; m_log_counter++;
suffix = QString(" x%1").arg(m_log_counter); suffix = QString(" x%1").arg(m_log_counter);
log->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); m_log->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
log->moveCursor(QTextCursor::StartOfLine, QTextCursor::MoveAnchor); m_log->moveCursor(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);
log->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor); m_log->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor);
log->textCursor().removeSelectedText(); m_log->textCursor().removeSelectedText();
log->textCursor().deletePreviousChar(); m_log->textCursor().deletePreviousChar();
} }
else else
{ {
@ -370,14 +374,14 @@ void log_frame::UpdateUI()
} }
// add actual log message // add actual log message
log->setTextColor(color); m_log->setTextColor(color);
log->append(text); m_log->append(text);
// add counter suffix if needed // add counter suffix if needed
if (m_stack_log && isSame) if (m_stack_log && isSame)
{ {
log->setTextColor(Qt::white); m_log->setTextColor(Qt::white);
log->insertPlainText(suffix); m_log->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)
@ -389,7 +393,7 @@ void log_frame::UpdateUI()
// reset old text cursor and selection // reset old text cursor and selection
c.setPosition(sel_start); c.setPosition(sel_start);
c.setPosition(sel_end, QTextCursor::KeepAnchor); c.setPosition(sel_end, QTextCursor::KeepAnchor);
log->setTextCursor(c); m_log->setTextCursor(c);
// set scrollbar to max means auto-scroll // set scrollbar to max means auto-scroll
sb->setValue(isMax ? sb->maximum() : sb_pos); sb->setValue(isMax ? sb->maximum() : sb_pos);

View File

@ -35,30 +35,29 @@ private:
void CreateAndConnectActions(); void CreateAndConnectActions();
QTabWidget *tabWidget; QTextEdit *m_log;
QTextEdit *log; QTextEdit *m_tty;
QTextEdit *tty;
QString m_old_text; QString m_old_text;
ullong m_log_counter; ullong m_log_counter;
bool m_stack_log; bool m_stack_log;
fs::file tty_file; fs::file m_tty_file;
QAction* clearAct; QAction* m_clearAct;
QActionGroup* logLevels; QActionGroup* m_logLevels;
QAction* nothingAct; QAction* m_nothingAct;
QAction* fatalAct; QAction* m_fatalAct;
QAction* errorAct; QAction* m_errorAct;
QAction* todoAct; QAction* m_todoAct;
QAction* successAct; QAction* m_successAct;
QAction* warningAct; QAction* m_warningAct;
QAction* noticeAct; QAction* m_noticeAct;
QAction* traceAct; QAction* m_traceAct;
QAction* stackAct; QAction* m_stackAct;
QAction* TTYAct; QAction* m_TTYAct;
std::shared_ptr<gui_settings> xgui_settings; std::shared_ptr<gui_settings> xgui_settings;
}; };

View File

@ -15,18 +15,14 @@ rsx_debugger::rsx_debugger(QWidget* parent)
, m_addr(0x0) , m_addr(0x0)
, m_cur_texture(0) , m_cur_texture(0)
, exit(false) , exit(false)
, palette_bg()
{ {
setWindowTitle(tr("RSX Debugger")); setWindowTitle(tr("RSX Debugger"));
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
//Fonts and Colors //Fonts and Colors
pSize = 8; QFont mono = QFontDatabase::systemFont(QFontDatabase::FixedFont);
mono = QFontDatabase::systemFont(QFontDatabase::FixedFont); mono.setPointSize(8);
mono.setPointSize(pSize);
fontMetrics = new QFontMetrics(mono);
palette_bg.setColor(backgroundRole(), QColor(240, 240, 240));
QHBoxLayout* hbox_panel = new QHBoxLayout(); QHBoxLayout* hbox_panel = new QHBoxLayout();
//Tools //Tools
@ -39,12 +35,12 @@ rsx_debugger::rsx_debugger(QWidget* parent)
// Controls: Address // Controls: Address
QGroupBox* gb_controls_addr = new QGroupBox(tr("Address:"), this); QGroupBox* gb_controls_addr = new QGroupBox(tr("Address:"), this);
QHBoxLayout* hbox_controls_addr = new QHBoxLayout(); QHBoxLayout* hbox_controls_addr = new QHBoxLayout();
t_addr = new QLineEdit(); m_addr_line = new QLineEdit();
t_addr->setFont(mono); m_addr_line->setFont(mono);
t_addr->setPlaceholderText("00000000"); m_addr_line->setPlaceholderText("00000000");
t_addr->setMaxLength(8); m_addr_line->setMaxLength(8);
t_addr->setMaximumWidth(65); m_addr_line->setMaximumWidth(65);
hbox_controls_addr->addWidget(t_addr); hbox_controls_addr->addWidget(m_addr_line);
gb_controls_addr->setLayout(hbox_controls_addr); gb_controls_addr->setLayout(hbox_controls_addr);
// Controls: Go to // Controls: Go to
@ -220,10 +216,10 @@ rsx_debugger::rsx_debugger(QWidget* parent)
gb_buffers_text ->setLayout(hbox_buffers_text); gb_buffers_text ->setLayout(hbox_buffers_text);
//Buffers and textures //Buffers and textures
m_panel_width = 108; int m_panel_width = 108;
m_panel_height = 108; int m_panel_height = 108;
m_text_width = 108; int m_text_width = 108;
m_text_height = 108; int m_text_height = 108;
//Panels for displaying the buffers //Panels for displaying the buffers
m_buffer_colorA = new Buffer(p_buffers, false, 0); m_buffer_colorA = new Buffer(p_buffers, false, 0);
@ -282,17 +278,22 @@ rsx_debugger::rsx_debugger(QWidget* parent)
setLayout(hbox_panel); setLayout(hbox_panel);
//Events //Events
connect(b_goto_get, &QAbstractButton::clicked, [=](){ connect(b_goto_get, &QAbstractButton::clicked, [=]
if (const auto render = fxm::get<GSRender>()){ {
if (const auto render = fxm::get<GSRender>())
{
u32 realAddr; u32 realAddr;
if (RSXIOMem.getRealAddr(render->ctrl->get.load(), realAddr)){ if (RSXIOMem.getRealAddr(render->ctrl->get.load(), realAddr))
{
m_addr = realAddr; m_addr = realAddr;
UpdateInformation(); UpdateInformation();
} }
} }
}); });
connect(b_goto_put, &QAbstractButton::clicked, [=](){ connect(b_goto_put, &QAbstractButton::clicked, [=]
if (const auto render = fxm::get<GSRender>()){ {
if (const auto render = fxm::get<GSRender>())
{
u32 realAddr; u32 realAddr;
if (RSXIOMem.getRealAddr(render->ctrl->put.load(), realAddr)) if (RSXIOMem.getRealAddr(render->ctrl->put.load(), realAddr))
{ {
@ -301,9 +302,10 @@ rsx_debugger::rsx_debugger(QWidget* parent)
} }
} }
}); });
connect(t_addr, &QLineEdit::returnPressed, [=](){ connect(m_addr_line, &QLineEdit::returnPressed, [=]
{
bool ok; bool ok;
m_addr = t_addr->text().toULong(&ok, 16); m_addr = m_addr_line->text().toULong(&ok, 16);
UpdateInformation(); UpdateInformation();
}); });
connect(m_list_flags, &QTableWidget::itemClicked, this, &rsx_debugger::SetFlags); connect(m_list_flags, &QTableWidget::itemClicked, this, &rsx_debugger::SetFlags);
@ -318,8 +320,8 @@ rsx_debugger::rsx_debugger(QWidget* parent)
//Fill the frame //Fill the frame
UpdateInformation(); UpdateInformation();
setFixedSize(sizeHint()); setFixedSize(sizeHint());
setFocusProxy(t_addr); setFocusProxy(m_addr_line);
}; }
rsx_debugger::~rsx_debugger() rsx_debugger::~rsx_debugger()
{ {
@ -399,14 +401,14 @@ void Buffer::showImage(const QImage& image)
{ {
if (image.isNull()) return; if (image.isNull()) return;
m_image = image; m_image = image;
m_scaled = m_image.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); QImage scaled = m_image.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
m_canvas = new QLabel(); QLabel* m_canvas = new QLabel();
m_canvas->setFixedSize(size()); m_canvas->setFixedSize(size());
m_canvas->setPixmap(QPixmap::fromImage(m_scaled)); m_canvas->setPixmap(QPixmap::fromImage(scaled));
m_layout = new QHBoxLayout(); QHBoxLayout* layout = new QHBoxLayout();
m_layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
m_layout->addWidget(m_canvas); layout->addWidget(m_canvas);
setLayout(m_layout); setLayout(layout);
} }
void Buffer::mouseDoubleClickEvent(QMouseEvent* event) void Buffer::mouseDoubleClickEvent(QMouseEvent* event)
@ -643,7 +645,7 @@ void rsx_debugger::OnClickDrawCalls()
void rsx_debugger::UpdateInformation() void rsx_debugger::UpdateInformation()
{ {
t_addr->setText(QString("%1").arg(m_addr, 8, 16, QChar('0'))); // get 8 digits in input line m_addr_line->setText(QString("%1").arg(m_addr, 8, 16, QChar('0'))); // get 8 digits in input line
GetMemory(); GetMemory();
GetBuffers(); GetBuffers();
GetFlags(); GetFlags();
@ -1192,3 +1194,8 @@ QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA
return qstr(disasm); return qstr(disasm);
} }
void rsx_debugger::SetPC(const uint pc)
{
m_addr = pc;
}

View File

@ -29,15 +29,11 @@
class Buffer : public QWidget class Buffer : public QWidget
{ {
QHBoxLayout* m_layout;
QImage m_scaled;
u32 m_id; u32 m_id;
bool m_isTex; bool m_isTex;
public:
QLabel* m_canvas;
QImage m_image; QImage m_image;
public:
Buffer(QWidget* parent, bool isTex, u32 id = 4) Buffer(QWidget* parent, bool isTex, u32 id = 4)
: QWidget(parent), m_isTex(isTex), m_id(id){}; : QWidget(parent), m_isTex(isTex), m_id(id){};
void showImage(const QImage& image = QImage()); void showImage(const QImage& image = QImage());
@ -52,17 +48,7 @@ class rsx_debugger : public QDialog
u32 m_addr; u32 m_addr;
u32 m_panel_width; QLineEdit* m_addr_line;
u32 m_panel_height;
u32 m_text_width;
u32 m_text_height;
u32 pSize;
QLineEdit* t_addr;
QPalette palette_bg;
QFont mono;
QFontMetrics* fontMetrics;
u32 m_item_count; u32 m_item_count;
QTableWidget* m_list_commands; QTableWidget* m_list_commands;
@ -103,10 +89,7 @@ public:
const char* ParseGCMEnum(u32 value, u32 type); const char* ParseGCMEnum(u32 value, u32 type);
QString DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioAddr); QString DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioAddr);
void SetPC(const uint pc) { m_addr = pc; } void SetPC(const uint pc);
private:
QSignalMapper *signalMapper;
public Q_SLOTS: public Q_SLOTS:
virtual void keyPressEvent(QKeyEvent* event); virtual void keyPressEvent(QKeyEvent* event);