Expand Up @@ -6,6 +6,8 @@
#include <QDialog>

#include "Common/CommonTypes.h"
#include "Core/PowerPC/BreakPoints.h"
#include "Core/PowerPC/PowerPC.h"

class BreakpointWidget;
class QCheckBox;
Expand All @@ -15,11 +17,20 @@ class QLabel;
class QLineEdit;
class QRadioButton;

class NewBreakpointDialog : public QDialog
class BreakpointDialog : public QDialog
{
Q_OBJECT
public:
explicit NewBreakpointDialog(BreakpointWidget* parent);
enum class OpenMode
{
New,
EditBreakPoint,
EditMemCheck
};

explicit BreakpointDialog(BreakpointWidget* parent);
BreakpointDialog(BreakpointWidget* parent, const TBreakPoint* breakpoint);
BreakpointDialog(BreakpointWidget* parent, const TMemCheck* memcheck);

void accept() override;

Expand Down Expand Up @@ -58,4 +69,6 @@ class NewBreakpointDialog : public QDialog

QDialogButtonBox* m_buttons;
BreakpointWidget* m_parent;

OpenMode m_open_mode;
};
24 changes: 22 additions & 2 deletions Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp
Expand Up @@ -19,8 +19,8 @@
#include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/PowerPC.h"

#include "DolphinQt/Debugger/BreakpointDialog.h"
#include "DolphinQt/Debugger/MemoryWidget.h"
#include "DolphinQt/Debugger/NewBreakpointDialog.h"
#include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h"

Expand Down Expand Up @@ -299,10 +299,27 @@ void BreakpointWidget::OnClear()

void BreakpointWidget::OnNewBreakpoint()
{
NewBreakpointDialog* dialog = new NewBreakpointDialog(this);
BreakpointDialog* dialog = new BreakpointDialog(this);
dialog->exec();
}

void BreakpointWidget::OnEditBreakpoint(u32 address, bool is_instruction_bp)
{
if (is_instruction_bp)
{
auto* dialog = new BreakpointDialog(this, PowerPC::breakpoints.GetBreakpoint(address));
dialog->exec();
}
else
{
auto* dialog = new BreakpointDialog(this, PowerPC::memchecks.GetMemCheck(address));
dialog->exec();
}

emit BreakpointsChanged();
Update();
}

void BreakpointWidget::OnLoad()
{
IniFile ini;
Expand Down Expand Up @@ -389,6 +406,9 @@ void BreakpointWidget::OnContextMenu()
Update();
});
}
menu->addAction(tr("Edit..."), [this, bp_address, is_memory_breakpoint] {
OnEditBreakpoint(bp_address, !is_memory_breakpoint);
});

menu->exec(QCursor::pos());
}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinQt/Debugger/BreakpointWidget.h
Expand Up @@ -44,6 +44,7 @@ class BreakpointWidget : public QDockWidget
void OnDelete();
void OnClear();
void OnNewBreakpoint();
void OnEditBreakpoint(u32 address, bool is_instruction_bp);
void OnLoad();
void OnSave();
void OnContextMenu();
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt/DolphinQt.vcxproj
Expand Up @@ -126,6 +126,7 @@
<ClCompile Include="Config\VerifyWidget.cpp" />
<ClCompile Include="Config\WiimoteControllersWidget.cpp" />
<ClCompile Include="ConvertDialog.cpp" />
<ClCompile Include="Debugger\BreakpointDialog.cpp" />
<ClCompile Include="Debugger\BreakpointWidget.cpp" />
<ClCompile Include="Debugger\CodeDiffDialog.cpp" />
<ClCompile Include="Debugger\CodeViewWidget.cpp" />
Expand All @@ -134,7 +135,6 @@
<ClCompile Include="Debugger\MemoryViewWidget.cpp" />
<ClCompile Include="Debugger\MemoryWidget.cpp" />
<ClCompile Include="Debugger\NetworkWidget.cpp" />
<ClCompile Include="Debugger\NewBreakpointDialog.cpp" />
<ClCompile Include="Debugger\PatchInstructionDialog.cpp" />
<ClCompile Include="Debugger\RegisterColumn.cpp" />
<ClCompile Include="Debugger\RegisterWidget.cpp" />
Expand Down Expand Up @@ -319,6 +319,7 @@
<QtMoc Include="Config\VerifyWidget.h" />
<QtMoc Include="Config\WiimoteControllersWidget.h" />
<QtMoc Include="ConvertDialog.h" />
<QtMoc Include="Debugger\BreakpointDialog.h" />
<QtMoc Include="Debugger\BreakpointWidget.h" />
<QtMoc Include="Debugger\CodeDiffDialog.h" />
<QtMoc Include="Debugger\CodeViewWidget.h" />
Expand All @@ -327,7 +328,6 @@
<QtMoc Include="Debugger\MemoryViewWidget.h" />
<QtMoc Include="Debugger\MemoryWidget.h" />
<QtMoc Include="Debugger\NetworkWidget.h" />
<QtMoc Include="Debugger\NewBreakpointDialog.h" />
<QtMoc Include="Debugger\PatchInstructionDialog.h" />
<QtMoc Include="Debugger\RegisterWidget.h" />
<QtMoc Include="Debugger\ThreadWidget.h" />
Expand Down