mame/src/osd/modules/debugger/qt/breakpointswindow.cpp
Vas Crabb 40a30af10f Still more user experience improvements:
Changed the default mapping for UI select to not trigger on Alt+Enter
fullscreen toggle.  (Fullscreen toggle still doesn't work in menus -
actually fixing that is complicated.)

frontend: Made the about box wrap text properly, made the title and
backtrack menu item always visible, and added a footer with the VCS
revision.

frontend: Don't highlight the favourites and info toolbar buttons if
there's no selection (can happen if filters produce no results).  Also
made the info viewer appear even if no info is available - it's less
confusing to see an empty menu than wonder why clicking the button does
nothing.

debugger: Added a register points view to the GUI debuggers, to go with
the breakpoints and watchpoints views.

debugger: Extended [brw]p(clear|(en|dis)able) commands to accept
multiple arguments to perform the same action on multiple
(break|watch|register)points at once.  Also made rplist accept a CPU for
showing a single CPU's register points ([bw]plist already support this).

docs: Updated registerpoints debugger commands page, and updated other
pages for latest extensions to syntax.
2021-10-18 08:22:21 +11:00

152 lines
4.2 KiB
C++

// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
#include "breakpointswindow.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#include <QtWidgets/QActionGroup>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QVBoxLayout>
BreakpointsWindow::BreakpointsWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
setWindowTitle("Debug: All Breakpoints");
if (parent)
{
QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
}
//
// The main frame and its input and breakpoints widgets
//
QFrame *mainWindowFrame = new QFrame(this);
// The main breakpoints view
m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this);
// Layout
QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->setObjectName("vlayout");
vLayout->setSpacing(3);
vLayout->setContentsMargins(2,2,2,2);
vLayout->addWidget(m_breakpointsView);
setCentralWidget(mainWindowFrame);
//
// Menu bars
//
QActionGroup *typeGroup = new QActionGroup(this);
typeGroup->setObjectName("typegroup");
QAction *typeBreak = new QAction("Breakpoints", this);
typeBreak->setObjectName("typebreak");
typeBreak->setCheckable(true);
typeBreak->setActionGroup(typeGroup);
typeBreak->setShortcut(QKeySequence("Ctrl+1"));
QAction *typeWatch = new QAction("Watchpoints", this);
typeWatch->setObjectName("typewatch");
typeWatch->setCheckable(true);
typeWatch->setActionGroup(typeGroup);
typeWatch->setShortcut(QKeySequence("Ctrl+2"));
QAction *typeRegister = new QAction("Registerpoints", this);
typeRegister->setObjectName("typeregister");
typeRegister->setCheckable(true);
typeRegister->setActionGroup(typeGroup);
typeRegister->setShortcut(QKeySequence("Ctrl+3"));
typeBreak->setChecked(true);
connect(typeGroup, &QActionGroup::triggered, this, &BreakpointsWindow::typeChanged);
// Assemble the options menu
QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addActions(typeGroup->actions());
}
BreakpointsWindow::~BreakpointsWindow()
{
}
void BreakpointsWindow::typeChanged(QAction* changedTo)
{
// Clean
delete m_breakpointsView;
m_breakpointsView = nullptr;
// Create
if (changedTo->text() == "Breakpoints")
{
m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this);
setWindowTitle("Debug: All Breakpoints");
}
else if (changedTo->text() == "Watchpoints")
{
m_breakpointsView = new DebuggerView(DVT_WATCH_POINTS, m_machine, this);
setWindowTitle("Debug: All Watchpoints");
}
else if (changedTo->text() == "Registerpoints")
{
m_breakpointsView = new DebuggerView(DVT_REGISTER_POINTS, m_machine, this);
setWindowTitle("Debug: All Registerpoints");
}
// Re-register
QVBoxLayout *layout = findChild<QVBoxLayout *>("vlayout");
layout->addWidget(m_breakpointsView);
}
//=========================================================================
// BreakpointsWindowQtConfig
//=========================================================================
void BreakpointsWindowQtConfig::buildFromQWidget(QWidget *widget)
{
WindowQtConfig::buildFromQWidget(widget);
BreakpointsWindow *window = dynamic_cast<BreakpointsWindow *>(widget);
QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup");
if (typeGroup->checkedAction()->text() == "Breakpoints")
m_bwType = 0;
else if (typeGroup->checkedAction()->text() == "Watchpoints")
m_bwType = 1;
else if (typeGroup->checkedAction()->text() == "Registerpoints")
m_bwType = 2;
}
void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget)
{
WindowQtConfig::applyToQWidget(widget);
BreakpointsWindow *window = dynamic_cast<BreakpointsWindow *>(widget);
QActionGroup *typeGroup = window->findChild<QActionGroup *>("typegroup");
typeGroup->actions()[m_bwType]->trigger();
}
void BreakpointsWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
{
WindowQtConfig::addToXmlDataNode(node);
node.set_attribute_int("bwtype", m_bwType);
}
void BreakpointsWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
WindowQtConfig::recoverFromXmlNode(node);
m_bwType = node.get_attribute_int("bwtype", m_bwType);
}