From e3d85ffe35ffac253cdae5b08c50c33a17db9ce3 Mon Sep 17 00:00:00 2001 From: Sepalani Date: Wed, 17 Feb 2021 21:12:27 +0400 Subject: [PATCH] MemoryWidget: Add "Add to watch" action --- Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp | 5 +++++ Source/Core/DolphinQt/Debugger/MemoryViewWidget.h | 1 + Source/Core/DolphinQt/Debugger/MemoryWidget.cpp | 1 + Source/Core/DolphinQt/Debugger/MemoryWidget.h | 1 + Source/Core/DolphinQt/MainWindow.cpp | 1 + 5 files changed, 9 insertions(+) diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index 60d32a8a25..5db9fdfbd9 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -403,6 +403,11 @@ void MemoryViewWidget::OnContextMenu() menu->addSeparator(); + menu->addAction(tr("Add to watch"), this, [this] { + const u32 address = GetContextAddress(); + const QString name = QStringLiteral("mem_%1").arg(address, 8, 16, QLatin1Char('0')); + emit RequestWatch(name, address); + }); menu->addAction(tr("Toggle Breakpoint"), this, &MemoryViewWidget::ToggleBreakpoint); menu->exec(QCursor::pos()); diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h index dcb4409fa7..bb8cdb1520 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h @@ -57,6 +57,7 @@ public: signals: void BreakpointsChanged(); void ShowCode(u32 address); + void RequestWatch(QString name, u32 address); private: void OnContextMenu(); diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index e226046c2a..ce1e043041 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -272,6 +272,7 @@ void MemoryWidget::ConnectWidgets() connect(m_memory_view, &MemoryViewWidget::BreakpointsChanged, this, &MemoryWidget::BreakpointsChanged); connect(m_memory_view, &MemoryViewWidget::ShowCode, this, &MemoryWidget::ShowCode); + connect(m_memory_view, &MemoryViewWidget::RequestWatch, this, &MemoryWidget::RequestWatch); } void MemoryWidget::closeEvent(QCloseEvent*) diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.h b/Source/Core/DolphinQt/Debugger/MemoryWidget.h index 8f779e9be7..d5bfe64fe8 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.h +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.h @@ -31,6 +31,7 @@ public: signals: void BreakpointsChanged(); void ShowCode(u32 address); + void RequestWatch(QString name, u32 address); private: void CreateWidgets(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 9a74adaa3d..67d02d042d 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -442,6 +442,7 @@ void MainWindow::CreateComponents() connect(m_memory_widget, &MemoryWidget::ShowCode, m_code_widget, [this](u32 address) { m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate); }); + connect(m_memory_widget, &MemoryWidget::RequestWatch, request_watch); connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_code_widget, &CodeWidget::Update);