From be208df11b6cc2558a82bd9b32f565187c5b5e31 Mon Sep 17 00:00:00 2001 From: Dan McCarthy Date: Wed, 24 Jan 2024 22:24:48 -0600 Subject: [PATCH] Debugger: Allow copying address of memory search results Adds the ability to copy the address directly of a memory search result through the right click context menu. --- pcsx2-qt/Debugger/CpuWidget.cpp | 15 +++++++++++++++ pcsx2-qt/Debugger/CpuWidget.h | 1 + 2 files changed, 16 insertions(+) diff --git a/pcsx2-qt/Debugger/CpuWidget.cpp b/pcsx2-qt/Debugger/CpuWidget.cpp index 961c0f1fa0..65f44c746c 100644 --- a/pcsx2-qt/Debugger/CpuWidget.cpp +++ b/pcsx2-qt/Debugger/CpuWidget.cpp @@ -592,6 +592,17 @@ void CpuWidget::contextRemoveSearchResult() delete rowToRemove; } +void CpuWidget::contextCopySearchResultAddress() +{ + if (!m_ui.listSearchResults->selectionModel()->hasSelection()) + return; + + const u32 selectedResultIndex = m_ui.listSearchResults->row(m_ui.listSearchResults->selectedItems().first()); + const u32 rowAddress = m_ui.listSearchResults->item(selectedResultIndex)->data(Qt::UserRole).toUInt(); + const QString addressString = FilledQStringFromValue(rowAddress, 16); + QApplication::clipboard()->setText(addressString); +} + void CpuWidget::updateFunctionList(bool whenEmpty) { if (!m_cpu.isAlive()) @@ -894,6 +905,10 @@ void CpuWidget::onListSearchResultsContextMenu(QPoint pos) if (selModel->hasSelection()) { + QAction* copyAddressAction = new QAction(tr("Copy Address"), m_ui.listSearchResults); + connect(copyAddressAction, &QAction::triggered, this, &CpuWidget::contextCopySearchResultAddress); + contextMenu->addAction(copyAddressAction); + QAction* goToDisassemblyAction = new QAction(tr("Go to in Disassembly"), m_ui.listSearchResults); connect(goToDisassemblyAction, &QAction::triggered, this, &CpuWidget::contextSearchResultGoToDisassembly); contextMenu->addAction(goToDisassemblyAction); diff --git a/pcsx2-qt/Debugger/CpuWidget.h b/pcsx2-qt/Debugger/CpuWidget.h index ce12fc9854..be871df1be 100644 --- a/pcsx2-qt/Debugger/CpuWidget.h +++ b/pcsx2-qt/Debugger/CpuWidget.h @@ -116,6 +116,7 @@ public slots: void loadSearchResults(); void contextSearchResultGoToDisassembly(); void contextRemoveSearchResult(); + void contextCopySearchResultAddress(); void onListSearchResultsContextMenu(QPoint pos); void saveBreakpointsToDebuggerSettings();