mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-23 21:40:09 +00:00
citra-qt: Edit and copy register values
This commit is contained in:
parent
868e6f2d82
commit
15afa4aefb
@ -5,6 +5,9 @@
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QShortcut>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include "core/debugger/debug_interface.h"
|
||||
|
||||
@ -29,13 +32,17 @@ RegisterView::RegisterView(QWidget* parent) : QFrame(parent) {
|
||||
last_pc = 0;
|
||||
selection = 0;
|
||||
|
||||
QShortcut* up_shortcut = new QShortcut(QKeySequence(Qt::Key_Up), this);
|
||||
QShortcut* up_shortcut = new QShortcut(QKeySequence("Up"), this);
|
||||
up_shortcut->setContext(Qt::WidgetShortcut);
|
||||
connect(up_shortcut, SIGNAL(activated()), this, SLOT(previousRegister()));
|
||||
connect(up_shortcut, SIGNAL(activated()), this, SLOT(moveSelectionUp()));
|
||||
|
||||
QShortcut* down_shortcut = new QShortcut(QKeySequence(Qt::Key_Down), this);
|
||||
QShortcut* down_shortcut = new QShortcut(QKeySequence("Down"), this);
|
||||
down_shortcut->setContext(Qt::WidgetShortcut);
|
||||
connect(down_shortcut, SIGNAL(activated()), this, SLOT(nextRegister()));
|
||||
connect(down_shortcut, SIGNAL(activated()), this, SLOT(moveSelectionDown()));
|
||||
|
||||
QShortcut* copy_shortcut = new QShortcut(QKeySequence("Ctrl+C"), this);
|
||||
down_shortcut->setContext(Qt::WidgetShortcut);
|
||||
connect(copy_shortcut, SIGNAL(activated()), this, SLOT(copyRegisterValue()));
|
||||
|
||||
setFocusPolicy(Qt::FocusPolicy::ClickFocus);
|
||||
}
|
||||
@ -157,6 +164,11 @@ void RegisterView::mouseMoveEvent(QMouseEvent* event) {
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterView::mouseDoubleClickEvent(QMouseEvent* event) {
|
||||
if (event->button() == Qt::MouseButton::LeftButton)
|
||||
editRegisterValue();
|
||||
}
|
||||
|
||||
void RegisterView::moveSelectionUp() {
|
||||
selection = qMax<int>(0, selection - 1);
|
||||
update();
|
||||
@ -166,3 +178,27 @@ void RegisterView::moveSelectionDown() {
|
||||
selection = qMin<int>(registers.size() - 1, selection + 1);
|
||||
update();
|
||||
}
|
||||
|
||||
void RegisterView::copyRegisterValue() {
|
||||
QString value;
|
||||
|
||||
Register& reg = registers[selection];
|
||||
value.sprintf("0x%08X", g_debug->GetRegValue(reg.category, reg.index));
|
||||
QApplication::clipboard()->setText(value);
|
||||
}
|
||||
|
||||
void RegisterView::editRegisterValue() {
|
||||
QString value;
|
||||
|
||||
Register& reg = registers[selection];
|
||||
value.sprintf("0x%08X", g_debug->GetRegValue(reg.category, reg.index));
|
||||
|
||||
QString result = QInputDialog::getText(this,"Input value","Input new value",QLineEdit::EchoMode::Normal,value);
|
||||
|
||||
u32 newValue;
|
||||
if (!result.isEmpty() && parseExpression(result,newValue)) {
|
||||
g_debug->SetRegValue(reg.category,reg.index,newValue);
|
||||
emit registerValueChanged();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent* event) override;
|
||||
|
||||
private slots:
|
||||
// Select previous register
|
||||
@ -24,6 +25,16 @@ private slots:
|
||||
// Select next register
|
||||
void moveSelectionDown();
|
||||
|
||||
// Copies a string representation of the selected
|
||||
// register's value to the clipboard
|
||||
void copyRegisterValue();
|
||||
|
||||
void editRegisterValue();
|
||||
|
||||
signals:
|
||||
// Emitted when the value of a register was changed by the user
|
||||
void registerValueChanged();
|
||||
|
||||
private:
|
||||
// Reloads register values if necessary
|
||||
void refreshChangedRegs();
|
||||
|
@ -24,6 +24,9 @@ RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent)
|
||||
}
|
||||
|
||||
cpu_regs_ui.flags->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding));
|
||||
|
||||
// reload cpsr flags when register values have been changed
|
||||
connect(cpu_regs_ui.registerView,SIGNAL(registerValueChanged()),this,SLOT(OnDebugModeEntered()));
|
||||
}
|
||||
|
||||
void RegistersWidget::OnFlagToggled(int state)
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include <QFontMetrics>
|
||||
|
||||
#include "core/debugger/debug_interface.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
DebuggerFont::DebuggerFont() {
|
||||
@ -27,3 +29,12 @@ void DebuggerFont::updateMetrics() {
|
||||
height = metrics.height();
|
||||
descent = metrics.descent();
|
||||
}
|
||||
|
||||
|
||||
bool parseExpression(QString& exp, u32& dest) {
|
||||
PostfixExpression postfix;
|
||||
if (!g_debug->InitExpression(exp.toLatin1().data(),postfix))
|
||||
return false;
|
||||
|
||||
return g_debug->ParseExpression(postfix,dest);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <QFont>
|
||||
#include <QPoint>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
// Abstracts font calculations used by some
|
||||
// debugger widgets
|
||||
class DebuggerFont {
|
||||
@ -31,3 +33,5 @@ private:
|
||||
int height;
|
||||
int descent;
|
||||
};
|
||||
|
||||
bool parseExpression(QString& exp, u32& dest);
|
||||
|
Loading…
Reference in New Issue
Block a user