-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8030 from spycrab/qt_patch_preview
Qt/Debugger: Implement patch instruction preview
- Loading branch information
Showing
5 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2019 Dolphin Emulator Project | ||
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
#include "DolphinQt/Debugger/PatchInstructionDialog.h" | ||
|
||
#include <QDialogButtonBox> | ||
#include <QLabel> | ||
#include <QLineEdit> | ||
#include <QPushButton> | ||
#include <QVBoxLayout> | ||
|
||
#include "Common/GekkoDisassembler.h" | ||
|
||
PatchInstructionDialog::PatchInstructionDialog(QWidget* parent, u32 address, u32 value) | ||
: QDialog(parent), m_address(address) | ||
{ | ||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | ||
setWindowModality(Qt::WindowModal); | ||
setWindowTitle(tr("Instruction")); | ||
|
||
CreateWidgets(); | ||
ConnectWidgets(); | ||
|
||
m_input_edit->setText(QStringLiteral("%1").arg(value, 8, 16, QLatin1Char('0'))); | ||
} | ||
|
||
void PatchInstructionDialog::CreateWidgets() | ||
{ | ||
auto* layout = new QVBoxLayout; | ||
|
||
m_input_edit = new QLineEdit; | ||
m_preview_label = new QLabel; | ||
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | ||
|
||
layout->addWidget(new QLabel(tr("New instruction:"))); | ||
layout->addWidget(m_input_edit); | ||
layout->addWidget(m_preview_label); | ||
layout->addWidget(m_button_box); | ||
|
||
setLayout(layout); | ||
} | ||
|
||
void PatchInstructionDialog::ConnectWidgets() | ||
{ | ||
connect(m_button_box, &QDialogButtonBox::accepted, this, &QDialog::accept); | ||
connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); | ||
|
||
connect(m_input_edit, &QLineEdit::textChanged, this, &PatchInstructionDialog::OnEditChanged); | ||
} | ||
|
||
void PatchInstructionDialog::OnEditChanged() | ||
{ | ||
bool good; | ||
m_code = m_input_edit->text().toUInt(&good, 16); | ||
|
||
m_button_box->button(QDialogButtonBox::Ok)->setEnabled(good); | ||
|
||
m_preview_label->setText( | ||
tr("Instruction: %1") | ||
.arg(QString::fromStdString(Common::GekkoDisassembler::Disassemble(m_code, m_address)))); | ||
} | ||
|
||
u32 PatchInstructionDialog::GetCode() const | ||
{ | ||
return m_code; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2019 Dolphin Emulator Project | ||
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
#pragma once | ||
|
||
#include <QDialog> | ||
|
||
#include "Common/CommonTypes.h" | ||
|
||
class QDialogButtonBox; | ||
class QLabel; | ||
class QLineEdit; | ||
|
||
class PatchInstructionDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PatchInstructionDialog(QWidget* parent, u32 address, u32 value); | ||
|
||
u32 GetCode() const; | ||
|
||
private: | ||
void CreateWidgets(); | ||
void ConnectWidgets(); | ||
|
||
void OnEditChanged(); | ||
|
||
u32 m_code; | ||
u32 m_address; | ||
|
||
QLineEdit* m_input_edit; | ||
QLabel* m_preview_label; | ||
QDialogButtonBox* m_button_box; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters