Qt: Add actions to debugger context menu

This commit is contained in:
Connor McLaughlin 2023-01-15 15:13:45 +10:00
parent fe08d34e52
commit ae529a6195
2 changed files with 37 additions and 0 deletions

View File

@ -239,6 +239,39 @@ void DebuggerWindow::onCodeViewItemActivated(QModelIndex index)
}
}
void DebuggerWindow::onCodeViewContextMenuRequested(const QPoint& pt)
{
const QModelIndex index = m_ui.codeView->indexAt(pt);
if (!index.isValid())
return;
const VirtualMemoryAddress address = m_code_model->getAddressForIndex(index);
QMenu menu;
menu.addAction(QStringLiteral("0x%1").arg(static_cast<uint>(address), 8, 16, QChar('0')))->setEnabled(false);
menu.addSeparator();
QAction* action = menu.addAction(QIcon(":/icons/media-record@2x.png"), tr("Toggle &Breakpoint"));
connect(action, &QAction::triggered, this, [this, address]() { toggleBreakpoint(address); });
action = menu.addAction(QIcon(":/icons/debug-run-cursor.png"), tr("&Run To Cursor"));
connect(action, &QAction::triggered, this, [address]() {
Host::RunOnCPUThread([address]() {
CPU::AddBreakpoint(address, true, true);
g_emu_thread->setSystemPaused(false);
});
});
menu.addSeparator();
action = menu.addAction(QIcon(":/icons/antialias-icon.png"), tr("View in &Dump"));
connect(action, &QAction::triggered, this, [this, address]() { scrollToMemoryAddress(address); });
action = menu.addAction(QIcon(":/icons/debug-trace.png"), tr("Follow Load/Store"));
connect(action, &QAction::triggered, this, [this, address]() { tryFollowLoadStore(address); });
menu.exec(m_ui.codeView->mapToGlobal(pt));
}
void DebuggerWindow::onMemorySearchTriggered()
{
m_ui.memoryView->clearHighlightRange();
@ -380,6 +413,8 @@ void DebuggerWindow::setupAdditionalUi()
m_ui.memoryView->setFont(fixedFont);
m_ui.stackView->setFont(fixedFont);
m_ui.codeView->setContextMenuPolicy(Qt::CustomContextMenu);
setCentralWidget(nullptr);
delete m_ui.centralwidget;
}
@ -405,6 +440,7 @@ void DebuggerWindow::connectSignals()
connect(m_ui.actionClearBreakpoints, &QAction::triggered, this, &DebuggerWindow::onClearBreakpointsTriggered);
connect(m_ui.actionClose, &QAction::triggered, this, &DebuggerWindow::close);
connect(m_ui.codeView, &QTreeView::activated, this, &DebuggerWindow::onCodeViewItemActivated);
connect(m_ui.codeView, &QTreeView::customContextMenuRequested, this, &DebuggerWindow::onCodeViewContextMenuRequested);
connect(m_ui.memoryRegionRAM, &QRadioButton::clicked, [this]() { setMemoryViewRegion(Bus::MemoryRegion::RAM); });
connect(m_ui.memoryRegionEXP1, &QRadioButton::clicked, [this]() { setMemoryViewRegion(Bus::MemoryRegion::EXP1); });

View File

@ -55,6 +55,7 @@ private Q_SLOTS:
void onStepOverActionTriggered();
void onStepOutActionTriggered();
void onCodeViewItemActivated(QModelIndex index);
void onCodeViewContextMenuRequested(const QPoint& pt);
void onMemorySearchTriggered();
void onMemorySearchStringChanged(const QString&);