summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-01-28 02:59:43 +1100
committer Vas Crabb <vas@vastheman.com>2021-01-28 02:59:43 +1100
commit83c9637635c575972c039d7d63a48d788e41ba34 (patch)
tree59bad3ada8a0f0f61bf503da21acef0f237d4d6b
parent832acf5731d68ca411b5fb358ddb4e79ef0faffa (diff)
-Qt debugger updates:
* Added context menu with Copy Visible and Paste commands to debug views (partially addresses #6066). * Made memory view last PC display a context menu item. * Fixed crash on right-clicking a memory view showing something other than an address space. -debugger: Fixed commas in dumpkbd output.
-rw-r--r--src/emu/natkeyboard.cpp6
-rw-r--r--src/osd/modules/debugger/debugqt.cpp151
-rw-r--r--src/osd/modules/debugger/qt/breakpointswindow.cpp38
-rw-r--r--src/osd/modules/debugger/qt/breakpointswindow.h19
-rw-r--r--src/osd/modules/debugger/qt/dasmwindow.cpp85
-rw-r--r--src/osd/modules/debugger/qt/dasmwindow.h35
-rw-r--r--src/osd/modules/debugger/qt/debuggerview.cpp297
-rw-r--r--src/osd/modules/debugger/qt/debuggerview.h38
-rw-r--r--src/osd/modules/debugger/qt/deviceinformationwindow.cpp47
-rw-r--r--src/osd/modules/debugger/qt/deviceinformationwindow.h12
-rw-r--r--src/osd/modules/debugger/qt/deviceswindow.cpp51
-rw-r--r--src/osd/modules/debugger/qt/deviceswindow.h26
-rw-r--r--src/osd/modules/debugger/qt/logwindow.cpp14
-rw-r--r--src/osd/modules/debugger/qt/logwindow.h15
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.cpp162
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.h110
-rw-r--r--src/osd/modules/debugger/qt/memorywindow.cpp242
-rw-r--r--src/osd/modules/debugger/qt/memorywindow.h51
-rw-r--r--src/osd/modules/debugger/qt/windowqt.cpp91
-rw-r--r--src/osd/modules/debugger/qt/windowqt.h18
20 files changed, 743 insertions, 765 deletions
diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp
index fd5e2a1be44..e686e6385a8 100644
--- a/src/emu/natkeyboard.cpp
+++ b/src/emu/natkeyboard.cpp
@@ -1015,7 +1015,6 @@ void natural_keyboard::dump(std::ostream &str) const
firstdev = false;
// loop through all codes
- bool firstkey(true);
for (auto &code : devinfo.codemap)
{
// describe the character code
@@ -1027,12 +1026,15 @@ void natural_keyboard::dump(std::ostream &str) const
for (auto &entry : code.second)
{
// identify the keys used
+ bool firstkey(true);
for (std::size_t field = 0; (entry.field.size() > field) && entry.field[field]; ++field)
+ {
util::stream_format(str, "%s'%s'", firstkey ? "" : ", ", entry.field[field]->name());
+ firstkey = false;
+ }
// carriage return
str << '\n';
- firstkey = false;
}
}
}
diff --git a/src/osd/modules/debugger/debugqt.cpp b/src/osd/modules/debugger/debugqt.cpp
index 9156fd31c16..c8845d42448 100644
--- a/src/osd/modules/debugger/debugqt.cpp
+++ b/src/osd/modules/debugger/debugqt.cpp
@@ -38,9 +38,7 @@ class debug_qt : public osd_module, public debug_module
#endif
{
public:
- debug_qt()
- : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(),
- m_machine(nullptr)
+ debug_qt() : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(), m_machine(nullptr)
{
}
@@ -78,37 +76,35 @@ MainWindow *mainQtWindow = nullptr;
//============================================================
// Global variable used to feed the xml configuration callbacks
-std::vector<WindowQtConfig*> xmlConfigurations;
+std::vector<std::unique_ptr<WindowQtConfig> > xmlConfigurations;
- void xml_configuration_load(running_machine &machine, config_type cfg_type, util::xml::data_node const *parentnode)
+void xml_configuration_load(running_machine &machine, config_type cfg_type, util::xml::data_node const *parentnode)
{
// We only care about game files
if (cfg_type != config_type::GAME)
return;
// Might not have any data
- if (parentnode == nullptr)
+ if (!parentnode)
return;
- for (int i = 0; i < xmlConfigurations.size(); i++)
- delete xmlConfigurations[i];
xmlConfigurations.clear();
// Configuration load
- util::xml::data_node const * wnode = nullptr;
+ util::xml::data_node const *wnode = nullptr;
for (wnode = parentnode->get_child("window"); wnode != nullptr; wnode = wnode->get_next_sibling("window"))
{
WindowQtConfig::WindowType type = (WindowQtConfig::WindowType)wnode->get_attribute_int("type", WindowQtConfig::WIN_TYPE_UNKNOWN);
switch (type)
{
- case WindowQtConfig::WIN_TYPE_MAIN: xmlConfigurations.push_back(new MainWindowQtConfig()); break;
- case WindowQtConfig::WIN_TYPE_MEMORY: xmlConfigurations.push_back(new MemoryWindowQtConfig()); break;
- case WindowQtConfig::WIN_TYPE_DASM: xmlConfigurations.push_back(new DasmWindowQtConfig()); break;
- case WindowQtConfig::WIN_TYPE_LOG: xmlConfigurations.push_back(new LogWindowQtConfig()); break;
- case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(new BreakpointsWindowQtConfig()); break;
- case WindowQtConfig::WIN_TYPE_DEVICES: xmlConfigurations.push_back(new DevicesWindowQtConfig()); break;
- case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION: xmlConfigurations.push_back(new DeviceInformationWindowQtConfig()); break;
+ case WindowQtConfig::WIN_TYPE_MAIN: xmlConfigurations.push_back(std::make_unique<MainWindowQtConfig>()); break;
+ case WindowQtConfig::WIN_TYPE_MEMORY: xmlConfigurations.push_back(std::make_unique<MemoryWindowQtConfig>()); break;
+ case WindowQtConfig::WIN_TYPE_DASM: xmlConfigurations.push_back(std::make_unique<DasmWindowQtConfig>()); break;
+ case WindowQtConfig::WIN_TYPE_LOG: xmlConfigurations.push_back(std::make_unique<LogWindowQtConfig>()); break;
+ case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(std::make_unique<BreakpointsWindowQtConfig>()); break;
+ case WindowQtConfig::WIN_TYPE_DEVICES: xmlConfigurations.push_back(std::make_unique<DevicesWindowQtConfig>()); break;
+ case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION: xmlConfigurations.push_back(std::make_unique<DeviceInformationWindowQtConfig>()); break;
default: continue;
}
xmlConfigurations.back()->recoverFromXmlNode(*wnode);
@@ -124,27 +120,24 @@ void xml_configuration_save(running_machine &machine, config_type cfg_type, util
for (int i = 0; i < xmlConfigurations.size(); i++)
{
- WindowQtConfig* config = xmlConfigurations[i];
+ WindowQtConfig &config = *xmlConfigurations[i];
// Create an xml node
util::xml::data_node *const debugger_node = parentnode->add_child("window", nullptr);
- if (debugger_node == nullptr)
- continue;
// Insert the appropriate information
- config->addToXmlDataNode(*debugger_node);
+ if (debugger_node)
+ config.addToXmlDataNode(*debugger_node);
}
}
void gather_save_configurations()
{
- for (int i = 0; i < xmlConfigurations.size(); i++)
- delete xmlConfigurations[i];
xmlConfigurations.clear();
// Loop over all the open windows
- foreach (QWidget* widget, QApplication::topLevelWidgets())
+ foreach (QWidget *widget, QApplication::topLevelWidgets())
{
if (!widget->isVisible())
continue;
@@ -153,20 +146,20 @@ void gather_save_configurations()
continue;
// Figure out its type
- if (dynamic_cast<MainWindow*>(widget))
- xmlConfigurations.push_back(new MainWindowQtConfig());
- else if (dynamic_cast<MemoryWindow*>(widget))
- xmlConfigurations.push_back(new MemoryWindowQtConfig());
- else if (dynamic_cast<DasmWindow*>(widget))
- xmlConfigurations.push_back(new DasmWindowQtConfig());
- else if (dynamic_cast<LogWindow*>(widget))
- xmlConfigurations.push_back(new LogWindowQtConfig());
- else if (dynamic_cast<BreakpointsWindow*>(widget))
- xmlConfigurations.push_back(new BreakpointsWindowQtConfig());
- else if (dynamic_cast<DevicesWindow*>(widget))
- xmlConfigurations.push_back(new DevicesWindowQtConfig());
- else if (dynamic_cast<DeviceInformationWindow*>(widget))
- xmlConfigurations.push_back(new DeviceInformationWindowQtConfig());
+ if (dynamic_cast<MainWindow *>(widget))
+ xmlConfigurations.push_back(std::make_unique<MainWindowQtConfig>());
+ else if (dynamic_cast<MemoryWindow *>(widget))
+ xmlConfigurations.push_back(std::make_unique<MemoryWindowQtConfig>());
+ else if (dynamic_cast<DasmWindow *>(widget))
+ xmlConfigurations.push_back(std::make_unique<DasmWindowQtConfig>());
+ else if (dynamic_cast<LogWindow *>(widget))
+ xmlConfigurations.push_back(std::make_unique<LogWindowQtConfig>());
+ else if (dynamic_cast<BreakpointsWindow *>(widget))
+ xmlConfigurations.push_back(std::make_unique<BreakpointsWindowQtConfig>());
+ else if (dynamic_cast<DevicesWindow *>(widget))
+ xmlConfigurations.push_back(std::make_unique<DevicesWindowQtConfig>());
+ else if (dynamic_cast<DeviceInformationWindow *>(widget))
+ xmlConfigurations.push_back(std::make_unique<DeviceInformationWindowQtConfig>());
xmlConfigurations.back()->buildFromQWidget(widget);
}
@@ -177,45 +170,46 @@ void gather_save_configurations()
// Utilities
//============================================================
-void load_and_clear_main_window_config(std::vector<WindowQtConfig*>& configList)
+void load_and_clear_main_window_config(std::vector<std::unique_ptr<WindowQtConfig> > &configList)
{
for (int i = 0; i < configList.size(); i++)
{
- WindowQtConfig* config = configList[i];
- if (config->m_type == WindowQtConfig::WIN_TYPE_MAIN)
+ WindowQtConfig &config = *configList[i];
+ if (config.m_type == WindowQtConfig::WIN_TYPE_MAIN)
{
- config->applyToQWidget(mainQtWindow);
- configList.erase(configList.begin()+i);
+ config.applyToQWidget(mainQtWindow);
+ configList.erase(configList.begin() + i);
break;
}
}
}
-void setup_additional_startup_windows(running_machine& machine, std::vector<WindowQtConfig*>& configList)
+void setup_additional_startup_windows(running_machine &machine, std::vector<std::unique_ptr<WindowQtConfig> > &configList)
{
for (int i = 0; i < configList.size(); i++)
{
- WindowQtConfig* config = configList[i];
+ WindowQtConfig &config = *configList[i];
- WindowQt* foo = nullptr;
- switch (config->m_type)
+ WindowQt *foo = nullptr;
+ switch (config.m_type)
{
- case WindowQtConfig::WIN_TYPE_MEMORY:
- foo = new MemoryWindow(&machine); break;
- case WindowQtConfig::WIN_TYPE_DASM:
- foo = new DasmWindow(&machine); break;
- case WindowQtConfig::WIN_TYPE_LOG:
- foo = new LogWindow(&machine); break;
- case WindowQtConfig::WIN_TYPE_BREAK_POINTS:
- foo = new BreakpointsWindow(&machine); break;
- case WindowQtConfig::WIN_TYPE_DEVICES:
- foo = new DevicesWindow(&machine); break;
- case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION:
- foo = new DeviceInformationWindow(&machine); break;
- default: break;
+ case WindowQtConfig::WIN_TYPE_MEMORY:
+ foo = new MemoryWindow(machine); break;
+ case WindowQtConfig::WIN_TYPE_DASM:
+ foo = new DasmWindow(machine); break;
+ case WindowQtConfig::WIN_TYPE_LOG:
+ foo = new LogWindow(machine); break;
+ case WindowQtConfig::WIN_TYPE_BREAK_POINTS:
+ foo = new BreakpointsWindow(machine); break;
+ case WindowQtConfig::WIN_TYPE_DEVICES:
+ foo = new DevicesWindow(machine); break;
+ case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION:
+ foo = new DeviceInformationWindow(machine); break;
+ default:
+ break;
}
- config->applyToQWidget(foo);
+ config.applyToQWidget(foo);
foo->show();
}
}
@@ -223,12 +217,13 @@ void setup_additional_startup_windows(running_machine& machine, std::vector<Wind
void bring_main_window_to_front()
{
- foreach (QWidget* widget, QApplication::topLevelWidgets())
+ foreach (QWidget *widget, QApplication::topLevelWidgets())
{
- if (!dynamic_cast<MainWindow*>(widget))
- continue;
- widget->activateWindow();
- widget->raise();
+ if (dynamic_cast<MainWindow *>(widget))
+ {
+ widget->activateWindow();
+ widget->raise();
+ }
}
}
@@ -251,7 +246,7 @@ bool debug_qt::nativeEventFilter(const QByteArray &eventType, void *message, lon
void debug_qt::init_debugger(running_machine &machine)
{
- if (qApp == nullptr)
+ if (!qApp)
{
// If you're starting from scratch, create a new qApp
new QApplication(qtArgc, qtArgv);
@@ -262,7 +257,7 @@ void debug_qt::init_debugger(running_machine &machine)
else
{
// If you've done a hard reset, clear out existing widgets & get ready for re-init
- foreach (QWidget* widget, QApplication::topLevelWidgets())
+ foreach (QWidget *widget, QApplication::topLevelWidgets())
{
if (!widget->isWindow() || widget->windowType() != Qt::Window)
continue;
@@ -274,8 +269,8 @@ void debug_qt::init_debugger(running_machine &machine)
m_machine = &machine;
// Setup the configuration XML saving and loading
machine.configuration().config_register("debugger",
- config_load_delegate(&xml_configuration_load, &machine),
- config_save_delegate(&xml_configuration_save, &machine));
+ config_load_delegate(&xml_configuration_load, &machine),
+ config_save_delegate(&xml_configuration_save, &machine));
}
@@ -298,15 +293,15 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
// Dialog initialization
if (oneShot)
{
- mainQtWindow = new MainWindow(m_machine);
+ mainQtWindow = new MainWindow(*m_machine);
load_and_clear_main_window_config(xmlConfigurations);
setup_additional_startup_windows(*m_machine, xmlConfigurations);
mainQtWindow->show();
oneShot = false;
}
- // Insure all top level widgets are visible & bring main window to front
- foreach (QWidget* widget, QApplication::topLevelWidgets())
+ // Ensure all top level widgets are visible & bring main window to front
+ foreach (QWidget *widget, QApplication::topLevelWidgets())
{
if (!widget->isWindow() || widget->windowType() != Qt::Window)
continue;
@@ -314,9 +309,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
}
if (firststop)
- {
bring_main_window_to_front();
- }
// Set the main window to display the proper cpu
mainQtWindow->setProcessor(&device);
@@ -337,7 +330,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
// Hide all top level widgets if requested
if (mainQtWindow->wantsHide())
{
- foreach (QWidget* widget, QApplication::topLevelWidgets())
+ foreach (QWidget *widget, QApplication::topLevelWidgets())
{
if (!widget->isWindow() || widget->windowType() != Qt::Window)
continue;
@@ -355,7 +348,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
gather_save_configurations();
}
#if defined(WIN32) && !defined(SDLMAME_WIN32)
- winwindow_update_cursor_state(*m_machine); // make sure the cursor isn't hidden while in debugger
+ winwindow_update_cursor_state(*m_machine); // make sure the cursor isn't hidden while in debugger
#endif
}
@@ -369,8 +362,10 @@ void debug_qt::debugger_update()
qApp->processEvents(QEventLoop::AllEvents, 1);
}
-#else /* SDLMAME_UNIX */
- MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt")
+#else // USE_QTDEBUG
+
+MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt")
+
#endif
MODULE_DEFINITION(DEBUG_QT, debug_qt)
diff --git a/src/osd/modules/debugger/qt/breakpointswindow.cpp b/src/osd/modules/debugger/qt/breakpointswindow.cpp
index 5d091694d66..4f581137476 100644
--- a/src/osd/modules/debugger/qt/breakpointswindow.cpp
+++ b/src/osd/modules/debugger/qt/breakpointswindow.cpp
@@ -1,12 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
-#include <QtWidgets/QActionGroup>
-#include <QtWidgets/QHBoxLayout>
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QVBoxLayout>
-
#include "breakpointswindow.h"
#include "debug/debugcon.h"
@@ -14,13 +8,19 @@
#include "debug/dvbpoints.h"
#include "debug/dvwpoints.h"
+#include <QtWidgets/QActionGroup>
+#include <QtWidgets/QHBoxLayout>
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QMenuBar>
+#include <QtWidgets/QVBoxLayout>
+
-BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) :
+BreakpointsWindow::BreakpointsWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
setWindowTitle("Debug: All Breakpoints");
- if (parent != nullptr)
+ if (parent)
{
QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@@ -29,13 +29,13 @@ BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent)
//
// The main frame and its input and breakpoints widgets
//
- QFrame* mainWindowFrame = new QFrame(this);
+ 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);
+ QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->setObjectName("vlayout");
vLayout->setSpacing(3);
vLayout->setContentsMargins(2,2,2,2);
@@ -46,11 +46,11 @@ BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent)
//
// Menu bars
//
- QActionGroup* typeGroup = new QActionGroup(this);
+ QActionGroup *typeGroup = new QActionGroup(this);
typeGroup->setObjectName("typegroup");
- QAction* typeBreak = new QAction("Breakpoints", this);
+ QAction *typeBreak = new QAction("Breakpoints", this);
typeBreak->setObjectName("typebreak");
- QAction* typeWatch = new QAction("Watchpoints", this);
+ QAction *typeWatch = new QAction("Watchpoints", this);
typeWatch->setObjectName("typewatch");
typeBreak->setCheckable(true);
typeWatch->setCheckable(true);
@@ -62,7 +62,7 @@ BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent)
connect(typeGroup, &QActionGroup::triggered, this, &BreakpointsWindow::typeChanged);
// Assemble the options menu
- QMenu* optionsMenu = menuBar()->addMenu("&Options");
+ QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addActions(typeGroup->actions());
}
@@ -91,7 +91,7 @@ void BreakpointsWindow::typeChanged(QAction* changedTo)
}
// Re-register
- QVBoxLayout* layout = findChild<QVBoxLayout*>("vlayout");
+ QVBoxLayout *layout = findChild<QVBoxLayout *>("vlayout");
layout->addWidget(m_breakpointsView);
}
@@ -100,10 +100,10 @@ void BreakpointsWindow::typeChanged(QAction* changedTo)
//=========================================================================
// BreakpointsWindowQtConfig
//=========================================================================
-void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget)
+void BreakpointsWindowQtConfig::buildFromQWidget(QWidget *widget)
{
WindowQtConfig::buildFromQWidget(widget);
- BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget);
+ BreakpointsWindow *window = dynamic_cast<BreakpointsWindow *>(widget);
QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup");
if (typeGroup->checkedAction()->text() == "Breakpoints")
@@ -116,9 +116,9 @@ void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget)
void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget)
{
WindowQtConfig::applyToQWidget(widget);
- BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget);
+ BreakpointsWindow *window = dynamic_cast<BreakpointsWindow *>(widget);
- QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup");
+ QActionGroup *typeGroup = window->findChild<QActionGroup *>("typegroup");
typeGroup->actions()[m_bwType]->trigger();
}
diff --git a/src/osd/modules/debugger/qt/breakpointswindow.h b/src/osd/modules/debugger/qt/breakpointswindow.h
index 60bbdc4379f..fab5ea149e9 100644
--- a/src/osd/modules/debugger/qt/breakpointswindow.h
+++ b/src/osd/modules/debugger/qt/breakpointswindow.h
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_BREAK_POINTS_WINDOW_H__
-#define __DEBUG_QT_BREAK_POINTS_WINDOW_H__
+#ifndef MAME_DEBUGGER_QT_BREAKPOINTSWINDOW_H
+#define MAME_DEBUGGER_QT_BREAKPOINTSWINDOW_H
#include "debuggerview.h"
#include "windowqt.h"
@@ -15,17 +15,15 @@ class BreakpointsWindow : public WindowQt
Q_OBJECT
public:
- BreakpointsWindow(running_machine* machine, QWidget* parent=nullptr);
+ BreakpointsWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~BreakpointsWindow();
-
private slots:
- void typeChanged(QAction* changedTo);
-
+ void typeChanged(QAction *changedTo);
private:
// Widgets
- DebuggerView* m_breakpointsView;
+ DebuggerView *m_breakpointsView;
};
@@ -46,11 +44,10 @@ public:
// Settings
int m_bwType;
- void buildFromQWidget(QWidget* widget);
- void applyToQWidget(QWidget* widget);
+ void buildFromQWidget(QWidget *widget);
+ void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
-
-#endif
+#endif // MAME_DEBUGGER_QT_BREAKPOINTSWINDOW_H
diff --git a/src/osd/modules/debugger/qt/dasmwindow.cpp b/src/osd/modules/debugger/qt/dasmwindow.cpp
index 52b33b50da8..4eee8d86fb1 100644
--- a/src/osd/modules/debugger/qt/dasmwindow.cpp
+++ b/src/osd/modules/debugger/qt/dasmwindow.cpp
@@ -1,12 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
-#include <QtWidgets/QHBoxLayout>
-#include <QtWidgets/QVBoxLayout>
-#include <QtWidgets/QAction>
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMenuBar>
-
#include "dasmwindow.h"
#include "debug/debugcon.h"
@@ -14,13 +8,19 @@
#include "debug/dvdisasm.h"
#include "debug/points.h"
+#include <QtWidgets/QHBoxLayout>
+#include <QtWidgets/QVBoxLayout>
+#include <QtWidgets/QAction>
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QMenuBar>
+
-DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
+DasmWindow::DasmWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
setWindowTitle("Debug: Disassembly View");
- if (parent != nullptr)
+ if (parent)
{
QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@@ -29,10 +29,10 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
//
// The main frame and its input and log widgets
//
- QFrame* mainWindowFrame = new QFrame(this);
+ QFrame *mainWindowFrame = new QFrame(this);
// The top frame & groupbox that contains the input widgets
- QFrame* topSubFrame = new QFrame(mainWindowFrame);
+ QFrame *topSubFrame = new QFrame(mainWindowFrame);
// The input edit
m_inputEdit = new QLineEdit(topSubFrame);
@@ -42,28 +42,27 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
m_cpuComboBox = new QComboBox(topSubFrame);
m_cpuComboBox->setObjectName("cpu");
m_cpuComboBox->setMinimumWidth(300);
- connect(m_cpuComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DasmWindow::cpuChanged);
+ connect(m_cpuComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DasmWindow::cpuChanged);
// The main disasm window
m_dasmView = new DebuggerView(DVT_DISASSEMBLY, m_machine, this);
connect(m_dasmView, &DebuggerView::updated, this, &DasmWindow::dasmViewUpdated);
// Force a recompute of the disassembly region
- downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");
+ downcast<debug_view_disasm *>(m_dasmView->view())->set_expression("curpc");
- // Populate the combo box & set the proper cpu
+ // Populate the combo box & set the proper CPU
populateComboBox();
setToCurrentCpu();
-
// Layout
- QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
+ QHBoxLayout *subLayout = new QHBoxLayout(topSubFrame);
subLayout->addWidget(m_inputEdit);
subLayout->addWidget(m_cpuComboBox);
subLayout->setSpacing(3);
subLayout->setContentsMargins(2,2,2,2);
- QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
+ QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->setSpacing(3);
vLayout->setContentsMargins(2,2,2,2);
vLayout->addWidget(topSubFrame);
@@ -86,11 +85,11 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
connect(m_runToCursorAct, &QAction::triggered, this, &DasmWindow::runToCursor);
// Right bar options
- QActionGroup* rightBarGroup = new QActionGroup(this);
+ QActionGroup *rightBarGroup = new QActionGroup(this);
rightBarGroup->setObjectName("rightbargroup");
- QAction* rightActRaw = new QAction("Raw Opcodes", this);
- QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
- QAction* rightActComments = new QAction("Comments", this);
+ QAction *rightActRaw = new QAction("Raw Opcodes", this);
+ QAction *rightActEncrypted = new QAction("Encrypted Opcodes", this);
+ QAction *rightActComments = new QAction("Comments", this);
rightActRaw->setCheckable(true);
rightActEncrypted->setCheckable(true);
rightActComments->setCheckable(true);
@@ -104,7 +103,7 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
connect(rightBarGroup, &QActionGroup::triggered, this, &DasmWindow::rightBarChanged);
// Assemble the options menu
- QMenu* optionsMenu = menuBar()->addMenu("&Options");
+ QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addAction(m_breakpointToggleAct);
optionsMenu->addAction(m_breakpointEnableAct);
optionsMenu->addAction(m_runToCursorAct);
@@ -128,7 +127,7 @@ void DasmWindow::cpuChanged(int index)
void DasmWindow::expressionSubmitted()
{
const QString expression = m_inputEdit->text();
- downcast<debug_view_disasm*>(m_dasmView->view())->set_expression(expression.toLocal8Bit().data());
+ downcast<debug_view_disasm *>(m_dasmView->view())->set_expression(expression.toLocal8Bit().data());
m_dasmView->viewport()->update();
}
@@ -145,19 +144,19 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo)
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
// If none exists, add a new one
- if (bp == nullptr)
+ if (!bp)
{
int32_t bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr);
- m_machine->debugger().console().printf("Breakpoint %X set\n", bpindex);
+ m_machine.debugger().console().printf("Breakpoint %X set\n", bpindex);
}
else
{
int32_t bpindex = bp->index();
cpuinfo->breakpoint_clear(bpindex);
- m_machine->debugger().console().printf("Breakpoint %X cleared\n", bpindex);
+ m_machine.debugger().console().printf("Breakpoint %X cleared\n", bpindex);
}
- m_machine->debug_view().update_all();
- m_machine->debugger().refresh_display();
+ m_machine.debug_view().update_all();
+ m_machine.debugger().refresh_display();
}
refreshAll();
@@ -175,12 +174,12 @@ void DasmWindow::enableBreakpointAtCursor(bool changedTo)
// Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
- if (bp != nullptr)
+ if (bp)
{
cpuinfo->breakpoint_enable(bp->index(), !bp->enabled());
- m_machine->debugger().console().printf("Breakpoint %X %s\n", (uint32_t)bp->index(), bp->enabled() ? "enabled" : "disabled");
- m_machine->debug_view().update_all();
- m_machine->debugger().refresh_display();
+ m_machine.debugger().console().printf("Breakpoint %X %s\n", (uint32_t)bp->index(), bp->enabled() ? "enabled" : "disabled");
+ m_machine.debug_view().update_all();
+ m_machine.debugger().refresh_display();
}
}
@@ -192,7 +191,7 @@ void DasmWindow::runToCursor(bool changedTo)
{
if (m_dasmView->view()->cursor_visible())
{
- offs_t const address = downcast<debug_view_disasm*>(m_dasmView->view())->selected_address();
+ offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address();
m_dasmView->view()->source()->device()->debug()->go(address);
}
}
@@ -231,7 +230,7 @@ void DasmWindow::dasmViewUpdated()
// Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
- if (bp != nullptr)
+ if (bp)
{
haveBreakpoint = true;
breakpointEnabled = bp->enabled();
@@ -248,7 +247,7 @@ void DasmWindow::dasmViewUpdated()
void DasmWindow::populateComboBox()
{
- if (m_dasmView == nullptr)
+ if (!m_dasmView)
return;
m_cpuComboBox->clear();
@@ -261,7 +260,7 @@ void DasmWindow::populateComboBox()
void DasmWindow::setToCurrentCpu()
{
- device_t* curCpu = m_machine->debugger().console().get_visible_cpu();
+ device_t *curCpu = m_machine.debugger().console().get_visible_cpu();
if (curCpu)
{
const debug_view_source *source = m_dasmView->view()->source_for_device(curCpu);
@@ -277,14 +276,14 @@ void DasmWindow::setToCurrentCpu()
//=========================================================================
// DasmWindowQtConfig
//=========================================================================
-void DasmWindowQtConfig::buildFromQWidget(QWidget* widget)
+void DasmWindowQtConfig::buildFromQWidget(QWidget *widget)
{
WindowQtConfig::buildFromQWidget(widget);
- DasmWindow* window = dynamic_cast<DasmWindow*>(widget);
- QComboBox* cpu = window->findChild<QComboBox*>("cpu");
+ DasmWindow *window = dynamic_cast<DasmWindow *>(widget);
+ QComboBox *cpu = window->findChild<QComboBox *>("cpu");
m_cpu = cpu->currentIndex();
- QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
+ QActionGroup *rightBarGroup = window->findChild<QActionGroup *>("rightbargroup");
if (rightBarGroup->checkedAction()->text() == "Raw Opcodes")
m_rightBar = 0;
else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes")
@@ -293,14 +292,14 @@ void DasmWindowQtConfig::buildFromQWidget(QWidget* widget)
m_rightBar = 2;
}
-void DasmWindowQtConfig::applyToQWidget(QWidget* widget)
+void DasmWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
- DasmWindow* window = dynamic_cast<DasmWindow*>(widget);
- QComboBox* cpu = window->findChild<QComboBox*>("cpu");
+ DasmWindow *window = dynamic_cast<DasmWindow *>(widget);
+ QComboBox *cpu = window->findChild<QComboBox *>("cpu");
cpu->setCurrentIndex(m_cpu);
- QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
+ QActionGroup *rightBarGroup = window->findChild<QActionGroup *>("rightbargroup");
rightBarGroup->actions()[m_rightBar]->trigger();
}
diff --git a/src/osd/modules/debugger/qt/dasmwindow.h b/src/osd/modules/debugger/qt/dasmwindow.h
index 9b73fed4534..fc4ce11d731 100644
--- a/src/osd/modules/debugger/qt/dasmwindow.h
+++ b/src/osd/modules/debugger/qt/dasmwindow.h
@@ -1,14 +1,14 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_DASM_WINDOW_H__
-#define __DEBUG_QT_DASM_WINDOW_H__
-
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QComboBox>
+#ifndef MAME_DEBUGGER_QT_DASMWINDOW_H
+#define MAME_DEBUGGER_QT_DASMWINDOW_H
#include "debuggerview.h"
#include "windowqt.h"
+#include <QtWidgets/QComboBox>
+#include <QtWidgets/QLineEdit>
+
//============================================================
// The Disassembly Window.
@@ -18,10 +18,9 @@ class DasmWindow : public WindowQt
Q_OBJECT
public:
- DasmWindow(running_machine* machine, QWidget* parent=nullptr);
+ DasmWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~DasmWindow();
-
private slots:
void cpuChanged(int index);
void expressionSubmitted();
@@ -29,25 +28,23 @@ private slots:
void toggleBreakpointAtCursor(bool changedTo);
void enableBreakpointAtCursor(bool changedTo);
void runToCursor(bool changedTo);
- void rightBarChanged(QAction* changedTo);
+ void rightBarChanged(QAction *changedTo);
void dasmViewUpdated();
-
private:
void populateComboBox();
void setToCurrentCpu();
-
// Widgets
- QLineEdit* m_inputEdit;
- QComboBox* m_cpuComboBox;
- DebuggerView* m_dasmView;
+ QLineEdit *m_inputEdit;
+ QComboBox *m_cpuComboBox;
+ DebuggerView *m_dasmView;
// Menu items
- QAction* m_breakpointToggleAct;
- QAction* m_breakpointEnableAct;
- QAction* m_runToCursorAct;
+ QAction *m_breakpointToggleAct;
+ QAction *m_breakpointEnableAct;
+ QAction *m_runToCursorAct;
};
@@ -70,11 +67,11 @@ public:
int m_cpu;
int m_rightBar;
- void buildFromQWidget(QWidget* widget);
- void applyToQWidget(QWidget* widget);
+ void buildFromQWidget(QWidget *widget);
+ void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
-#endif
+#endif // MAME_DEBUGGER_QT_DASMWINDOW_H
diff --git a/src/osd/modules/debugger/qt/debuggerview.cpp b/src/osd/modules/debugger/qt/debuggerview.cpp
index 150ca8519c5..8b7086684d0 100644
--- a/src/osd/modules/debugger/qt/debuggerview.cpp
+++ b/src/osd/modules/debugger/qt/debuggerview.cpp
@@ -1,54 +1,56 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
-#include <QtWidgets/QScrollBar>
-#include <QtWidgets/QApplication>
-#include <QtGui/QPainter>
-#include <QtGui/QKeyEvent>
-
#include "debuggerview.h"
#include "modules/lib/osdobj_common.h"
+#include <QtCore/QMimeData>
+#include <QtGui/QClipboard>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QPainter>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QScrollBar>
+
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define horizontalAdvance width
#endif
-DebuggerView::DebuggerView(const debug_view_type& type,
- running_machine* machine,
- QWidget* parent) :
+DebuggerView::DebuggerView(
+ debug_view_type type,
+ running_machine &machine,
+ QWidget *parent) :
QAbstractScrollArea(parent),
- m_preferBottom(false),
+ m_machine(machine),
m_view(nullptr),
- m_machine(machine)
+ m_preferBottom(false)
{
- // I like setting the font per-view since it doesn't override the menuing fonts.
- const char *const selectedFont(downcast<osd_options &>(m_machine->options()).debugger_font());
- const float selectedFontSize(downcast<osd_options &>(m_machine->options()).debugger_font_size());
+ // I like setting the font per-view since it doesn't override the menu fonts.
+ const char *const selectedFont(downcast<osd_options &>(m_machine.options()).debugger_font());
+ const float selectedFontSize(downcast<osd_options &>(m_machine.options()).debugger_font_size());
QFont viewFontRequest((!*selectedFont || !strcmp(selectedFont, OSDOPTVAL_AUTO)) ? "Courier New" : selectedFont);
viewFontRequest.setFixedPitch(true);
viewFontRequest.setStyleHint(QFont::TypeWriter);
viewFontRequest.setPointSize((selectedFontSize <= 0) ? 11 : selectedFontSize);
setFont(viewFontRequest);
- m_view = m_machine->debug_view().alloc_view(type,
- DebuggerView::debuggerViewUpdate,
- this);
+ m_view = m_machine.debug_view().alloc_view(
+ type,
+ DebuggerView::debuggerViewUpdate,
+ this);
- connect(verticalScrollBar(), &QScrollBar::valueChanged,
- this, &DebuggerView::verticalScrollSlot);
- connect(horizontalScrollBar(), &QScrollBar::valueChanged,
- this, &DebuggerView::horizontalScrollSlot);
+ connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &DebuggerView::verticalScrollSlot);
+ connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, &DebuggerView::horizontalScrollSlot);
}
DebuggerView::~DebuggerView()
{
- if (m_machine && m_view)
- m_machine->debug_view().free_view(*m_view);
+ if (m_view)
+ m_machine.debug_view().free_view(*m_view);
}
-void DebuggerView::paintEvent(QPaintEvent* event)
+void DebuggerView::paintEvent(QPaintEvent *event)
{
// Tell the MAME debug view how much real estate is available
QFontMetrics actualFont = fontMetrics();
@@ -67,17 +69,10 @@ void DebuggerView::paintEvent(QPaintEvent* event)
const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust;
- bool atEnd = false;
- if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
- {
- atEnd = true;
- }
+ const bool atEnd = verticalScrollBar()->value() == verticalScrollBar()->maximum();
verticalScrollBar()->setRange(0, verticalScrollSize);
if (m_preferBottom && atEnd)
- {
verticalScrollBar()->setValue(verticalScrollSize);
- }
-
// Draw the viewport widget
QPainter painter(viewport());
@@ -104,44 +99,37 @@ void DebuggerView::paintEvent(QPaintEvent* event)
QColor fgColor(0,0,0);
QColor bgColor(255,255,255);
- if(textAttr & DCA_VISITED)
- {
+ if (textAttr & DCA_VISITED)
bgColor.setRgb(0xc6, 0xe2, 0xff);
- }
- if(textAttr & DCA_ANCILLARY)
- {
+
+ if (textAttr & DCA_ANCILLARY)
bgColor.setRgb(0xe0, 0xe0, 0xe0);
- }
- if(textAttr & DCA_SELECTED)
- {
+
+ if (textAttr & DCA_SELECTED)
bgColor.setRgb(0xff, 0x80, 0x80);
- }
- if(textAttr & DCA_CURRENT)
- {
+
+ if (textAttr & DCA_CURRENT)
bgColor.setRgb(0xff, 0xff, 0x00);
- }
+
if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT))
- {
bgColor.setRgb(0xff,0xc0,0x80);
- }
- if(textAttr & DCA_CHANGED)
- {
+
+ if (textAttr & DCA_CHANGED)
fgColor.setRgb(0xff, 0x00, 0x00);
- }
- if(textAttr & DCA_INVALID)
- {
+
+ if (textAttr & DCA_INVALID)
fgColor.setRgb(0x00, 0x00, 0xff);
- }
- if(textAttr & DCA_DISABLED)
+
+ if (textAttr & DCA_DISABLED)
{
- fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1,
- (fgColor.green() + bgColor.green()) >> 1,
- (fgColor.blue() + bgColor.blue()) >> 1);
+ fgColor.setRgb(
+ (fgColor.red() + bgColor.red()) >> 1,
+ (fgColor.green() + bgColor.green()) >> 1,
+ (fgColor.blue() + bgColor.blue()) >> 1);
}
+
if(textAttr & DCA_COMMENT)
- {
fgColor.setRgb(0x00, 0x80, 0x00);
- }
bgBrush.setColor(bgColor);
painter.setBackground(bgBrush);
@@ -176,52 +164,54 @@ void DebuggerView::keyPressEvent(QKeyEvent* event)
int keyPress = -1;
switch (event->key())
{
- case Qt::Key_Up:
- keyPress = DCH_UP;
- break;
- case Qt::Key_Down:
- keyPress = DCH_DOWN;
- break;
- case Qt::Key_Left:
- keyPress = DCH_LEFT;
- if (ctrlDown) keyPress = DCH_CTRLLEFT;
- break;
- case Qt::Key_Right:
- keyPress = DCH_RIGHT;
- if (ctrlDown) keyPress = DCH_CTRLRIGHT;
- break;
- case Qt::Key_PageUp:
- keyPress = DCH_PUP;
- break;
- case Qt::Key_PageDown:
- keyPress = DCH_PDOWN;
- break;
- case Qt::Key_Home:
- keyPress = DCH_HOME;
- if (ctrlDown) keyPress = DCH_CTRLHOME;
- break;
- case Qt::Key_End:
- keyPress = DCH_END;
- if (ctrlDown) keyPress = DCH_CTRLEND;
- break;
- case Qt::Key_0: keyPress = '0'; break;
- case Qt::Key_1: keyPress = '1'; break;
- case Qt::Key_2: keyPress = '2'; break;
- case Qt::Key_3: keyPress = '3'; break;
- case Qt::Key_4: keyPress = '4'; break;
- case Qt::Key_5: keyPress = '5'; break;
- case Qt::Key_6: keyPress = '6'; break;
- case Qt::Key_7: keyPress = '7'; break;
- case Qt::Key_8: keyPress = '8'; break;
- case Qt::Key_9: keyPress = '9'; break;
- case Qt::Key_A: keyPress = 'a'; break;
- case Qt::Key_B: keyPress = 'b'; break;
- case Qt::Key_C: keyPress = 'c'; break;
- case Qt::Key_D: keyPress = 'd'; break;
- case Qt::Key_E: keyPress = 'e'; break;
- case Qt::Key_F: keyPress = 'f'; break;
- default:
- return QWidget::keyPressEvent(event);
+ case Qt::Key_Up:
+ keyPress = DCH_UP;
+ break;
+ case Qt::Key_Down:
+ keyPress = DCH_DOWN;
+ break;
+ case Qt::Key_Left:
+ keyPress = DCH_LEFT;
+ if (ctrlDown)
+ keyPress = DCH_CTRLLEFT;
+ break;
+ case Qt::Key_Right:
+ keyPress = DCH_RIGHT;
+ if (ctrlDown)
+ keyPress = DCH_CTRLRIGHT;
+ break;
+ case Qt::Key_PageUp:
+ keyPress = DCH_PUP;
+ break;
+ case Qt::Key_PageDown:
+ keyPress = DCH_PDOWN;
+ break;
+ case Qt::Key_Home:
+ keyPress = DCH_HOME;
+ if (ctrlDown) keyPress = DCH_CTRLHOME;
+ break;
+ case Qt::Key_End:
+ keyPress = DCH_END;
+ if (ctrlDown) keyPress = DCH_CTRLEND;
+ break;
+ case Qt::Key_0: keyPress = '0'; break;
+ case Qt::Key_1: keyPress = '1'; break;
+ case Qt::Key_2: keyPress = '2'; break;
+ case Qt::Key_3: keyPress = '3'; break;
+ case Qt::Key_4: keyPress = '4'; break;
+ case Qt::Key_5: keyPress = '5'; break;
+ case Qt::Key_6: keyPress = '6'; break;
+ case Qt::Key_7: keyPress = '7'; break;
+ case Qt::Key_8: keyPress = '8'; break;
+ case Qt::Key_9: keyPress = '9'; break;
+ case Qt::Key_A: keyPress = 'a'; break;
+ case Qt::Key_B: keyPress = 'b'; break;
+ case Qt::Key_C: keyPress = 'c'; break;
+ case Qt::Key_D: keyPress = 'd'; break;
+ case Qt::Key_E: keyPress = 'e'; break;
+ case Qt::Key_F: keyPress = 'f'; break;
+ default:
+ return QWidget::keyPressEvent(event);
}
m_view->set_cursor_visible(true);
@@ -235,26 +225,59 @@ void DebuggerView::keyPressEvent(QKeyEvent* event)
}
-void DebuggerView::mousePressEvent(QMouseEvent* event)
+void DebuggerView::mousePressEvent(QMouseEvent *event)
{
- if (m_view == nullptr)
+ if (!m_view)
return;
+ QFontMetrics actualFont = fontMetrics();
+ const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
+ const int fontHeight = std::max(1, actualFont.lineSpacing());
+
+ debug_view_xy topLeft = m_view->visible_position();
+ debug_view_xy clickViewPosition;
+ clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
+ clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
+
if (event->button() == Qt::LeftButton)
{
- QFontMetrics actualFont = fontMetrics();
- const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
- const int fontHeight = std::max(1, actualFont.lineSpacing());
-
- debug_view_xy topLeft = m_view->visible_position();
- debug_view_xy clickViewPosition;
- clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
- clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
m_view->process_click(DCK_LEFT_CLICK, clickViewPosition);
-
- viewport()->update();
- update();
}
+ else if (event->button() == Qt::MiddleButton)
+ {
+ m_view->process_click(DCK_MIDDLE_CLICK, clickViewPosition);
+ }
+ else if (event->button() == Qt::RightButton)
+ {
+ if (m_view->cursor_supported())
+ {
+ m_view->set_cursor_position(clickViewPosition);
+ m_view->set_cursor_visible(true);
+ }
+ }
+
+ viewport()->update();
+ update();
+}
+
+
+void DebuggerView::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *const menu = new QMenu(this);
+ addItemsToContextMenu(menu);
+ menu->popup(event->globalPos());
+}
+
+
+void DebuggerView::addItemsToContextMenu(QMenu *menu)
+{
+ QAction *const copyAct = new QAction("Copy Visible", menu);
+ QAction *const pasteAct = new QAction("Paste", menu);
+ pasteAct->setEnabled(QApplication::clipboard()->mimeData()->hasText());
+ connect(copyAct, &QAction::triggered, this, &DebuggerView::copyVisibleSlot);
+ connect(pasteAct, &QAction::triggered, this, &DebuggerView::pasteSlot);
+ menu->addAction(copyAct);
+ menu->addAction(pasteAct);
}
@@ -270,10 +293,46 @@ void DebuggerView::horizontalScrollSlot(int value)
}
-void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate)
+void DebuggerView::copyVisibleSlot()
+{
+ // get visible text
+ debug_view_xy const visarea = m_view->visible_size();
+ debug_view_char const *viewdata = m_view->viewdata();
+ if (!viewdata)
+ return;
+
+ // turn into a plain string, trimming trailing whitespace
+ std::string text;
+ for (uint32_t row = 0; row < visarea.y; row++, viewdata += visarea.x)
+ {
+ std::string::size_type const start = text.length();
+ for (uint32_t col = 0; col < visarea.x; ++col)
+ text += wchar_t(viewdata[col].byte);
+ std::string::size_type const nonblank = text.find_last_not_of("\t\n\v\r ");
+ if ((nonblank != std::string::npos) && (nonblank >= start))
+ text.resize(nonblank + 1);
+ text += "\n";
+ }
+
+ // copy to the clipboard
+ QApplication::clipboard()->setText(text.c_str());
+}
+
+
+void DebuggerView::pasteSlot()
+{
+ for (QChar ch : QApplication::clipboard()->text())
+ {
+ if ((32 <= ch.unicode()) && (127 >= ch.unicode()))
+ m_view->process_char(ch.unicode());
+ }
+}
+
+
+void DebuggerView::debuggerViewUpdate(debug_view &debugView, void *osdPrivate)
{
- // Get a handle to the DebuggerView being updated & redraw
- DebuggerView* dView = (DebuggerView*)osdPrivate;
+ // Get a handle to the DebuggerView being updated and redraw
+ DebuggerView *dView = reinterpret_cast<DebuggerView *>(osdPrivate);
dView->verticalScrollBar()->setValue(dView->view()->visible_position().y);
dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x);
dView->viewport()->update();
diff --git a/src/osd/modules/debugger/qt/debuggerview.h b/src/osd/modules/debugger/qt/debuggerview.h
index 2e1f35eb306..a38b3b11152 100644
--- a/src/osd/modules/debugger/qt/debuggerview.h
+++ b/src/osd/modules/debugger/qt/debuggerview.h
@@ -1,50 +1,52 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_DEBUGGER_VIEW_H__
-#define __DEBUG_QT_DEBUGGER_VIEW_H__
-
-#include <QtWidgets/QAbstractScrollArea>
+#ifndef MAME_DEBUGGER_QT_DEBUGGERVIEW_H
+#define MAME_DEBUGGER_QT_DEBUGGERVIEW_H
#include "debug/debugvw.h"
+#include <QtWidgets/QAbstractScrollArea>
+#include <QtWidgets/QMenu>
+
class DebuggerView : public QAbstractScrollArea
{
Q_OBJECT
public:
- DebuggerView(const debug_view_type& type,
- running_machine* machine,
- QWidget* parent=nullptr);
+ DebuggerView(debug_view_type type, running_machine &machine, QWidget *parent = nullptr);
virtual ~DebuggerView();
- void paintEvent(QPaintEvent* event);
+ void paintEvent(QPaintEvent *event);
// Setters and accessors
void setPreferBottom(bool pb) { m_preferBottom = pb; }
- debug_view* view() { return m_view; }
+ debug_view *view() { return m_view; }
signals:
void updated();
protected:
- void keyPressEvent(QKeyEvent* event);
- void mousePressEvent(QMouseEvent* event);
+ void keyPressEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void contextMenuEvent(QContextMenuEvent *event) override;
+
+ virtual void addItemsToContextMenu(QMenu *menu);
private slots:
void verticalScrollSlot(int value);
void horizontalScrollSlot(int value);
-
+ void copyVisibleSlot();
+ void pasteSlot();
private:
// Callback to allow MAME to refresh the view
- static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate);
+ static void debuggerViewUpdate(debug_view &debugView, void *osdPrivate);
- bool m_preferBottom;
+ running_machine &m_machine;
+ debug_view *m_view;
- debug_view* m_view;
- running_machine* m_machine;
+ bool m_preferBottom;
};
-
-#endif
+#endif // MAME_DEBUGGER_QT_DEBUGGERVIEW_H
diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.cpp b/src/osd/modules/debugger/qt/deviceinformationwindow.cpp
index 66142462a3b..431a0df492a 100644
--- a/src/osd/modules/debugger/qt/deviceinformationwindow.cpp
+++ b/src/osd/modules/debugger/qt/deviceinformationwindow.cpp
@@ -8,18 +8,17 @@
#include "deviceinformationwindow.h"
-DeviceInformationWindow::DeviceInformationWindow(running_machine* machine, device_t* device, QWidget* parent) :
- WindowQt(machine, nullptr)
+DeviceInformationWindow::DeviceInformationWindow(running_machine &machine, device_t *device, QWidget *parent) :
+ WindowQt(machine, nullptr),
+ m_device(device)
{
- m_device = device;
-
- if (parent != nullptr)
+ if (parent)
{
QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400);
}
- if(m_device)
+ if (m_device)
fill_device_information();
}
@@ -30,10 +29,7 @@ DeviceInformationWindow::~DeviceInformationWindow()
void DeviceInformationWindow::fill_device_information()
{
- char title[4069];
- sprintf(title, "Debug: Device %s", m_device->tag());
- setWindowTitle(title);
-
+ setWindowTitle(util::string_format("Debug: Device %s", m_device->tag()).c_str());
QFrame *mainWindowFrame = new QFrame(this);
QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
@@ -53,9 +49,11 @@ void DeviceInformationWindow::fill_device_information()
int cpos = 3;
device_interface *intf = m_device->interfaces().first();
- if(intf) {
+ if (intf)
+ {
gl1->addWidget(new QLabel(QString("Interfaces"), primaryFrame), cpos, 0);
- while(intf) {
+ while(intf)
+ {
gl1->addWidget(new QLabel(QString(intf->interface_type()), primaryFrame), cpos, 1);
cpos++;
intf = intf->interface_next();
@@ -65,16 +63,19 @@ void DeviceInformationWindow::fill_device_information()
vLayout->addWidget(primaryFrame);
device_memory_interface *d_memory;
- if(m_device->interface(d_memory)) {
+ if (m_device->interface(d_memory))
+ {
QFrame *f = new QFrame(mainWindowFrame);
f->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
QVBoxLayout *vb = new QVBoxLayout(f);
bool first = true;
- for(int i=0; i<d_memory->max_space_count(); i++)
- if(d_memory->has_space(i)) {
+ for (int i=0; i<d_memory->max_space_count(); i++)
+ if (d_memory->has_space(i))
+ {
QFrame *ff = new QFrame(f);
QHBoxLayout *hb = new QHBoxLayout(ff);
- if(first) {
+ if (first)
+ {
hb->addWidget(new QLabel("Memory maps"));
first = false;
}
@@ -92,9 +93,9 @@ void DeviceInformationWindow::fill_device_information()
void DeviceInformationWindow::set_device(const char *tag)
{
- m_device = m_machine->root_device().subdevice(tag);
- if(!m_device)
- m_device = &m_machine->root_device();
+ m_device = m_machine.root_device().subdevice(tag);
+ if (!m_device)
+ m_device = &m_machine.root_device();
fill_device_information();
}
@@ -107,18 +108,18 @@ const char *DeviceInformationWindow::device_tag() const
//=========================================================================
// DeviceInformationWindowQtConfig
//=========================================================================
-void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget* widget)
+void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget *widget)
{
WindowQtConfig::buildFromQWidget(widget);
- DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget);
+ DeviceInformationWindow *window = dynamic_cast<DeviceInformationWindow *>(widget);
m_device_tag = window->device_tag();
}
-void DeviceInformationWindowQtConfig::applyToQWidget(QWidget* widget)
+void DeviceInformationWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
- DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget);
+ DeviceInformationWindow *window = dynamic_cast<DeviceInformationWindow *>(widget);
window->set_device(m_device_tag.c_str());
}
diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.h b/src/osd/modules/debugger/qt/deviceinformationwindow.h
index 5ed1bfbde91..c7bfa68527d 100644
--- a/src/osd/modules/debugger/qt/deviceinformationwindow.h
+++ b/src/osd/modules/debugger/qt/deviceinformationwindow.h
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__
-#define __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__
+#ifndef MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
+#define MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
#include "windowqt.h"
@@ -13,7 +13,7 @@ class DeviceInformationWindow : public WindowQt
Q_OBJECT
public:
- DeviceInformationWindow(running_machine* machine, device_t* device = nullptr, QWidget* parent=nullptr);
+ DeviceInformationWindow(running_machine &machine, device_t *device = nullptr, QWidget* parent=nullptr);
virtual ~DeviceInformationWindow();
void set_device(const char *tag);
@@ -43,11 +43,11 @@ public:
~DeviceInformationWindowQtConfig() {}
- void buildFromQWidget(QWidget* widget);
- void applyToQWidget(QWidget* widget);
+ void buildFromQWidget(QWidget *widget);
+ void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
-#endif
+#endif // MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
diff --git a/src/osd/modules/debugger/qt/deviceswindow.cpp b/src/osd/modules/debugger/qt/deviceswindow.cpp
index 6313e9bf98e..b1b0be2a507 100644
--- a/src/osd/modules/debugger/qt/deviceswindow.cpp
+++ b/src/osd/modules/debugger/qt/deviceswindow.cpp
@@ -4,9 +4,9 @@
#include "deviceswindow.h"
#include "deviceinformationwindow.h"
-DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent)
+DevicesWindowModel::DevicesWindowModel(running_machine &machine, QObject *parent) :
+ m_machine(machine)
{
- m_machine = machine;
}
DevicesWindowModel::~DevicesWindowModel()
@@ -15,12 +15,13 @@ DevicesWindowModel::~DevicesWindowModel()
QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const
{
- if(!index.isValid() || role != Qt::DisplayRole)
+ if (!index.isValid() || role != Qt::DisplayRole)
return QVariant();
device_t *dev = static_cast<device_t *>(index.internalPointer());
- switch(index.column()) {
- case 0: return dev == &m_machine->root_device() ? QString("<root>") : QString(dev->basetag());
+ switch (index.column())
+ {
+ case 0: return (dev == &m_machine.root_device()) ? QString("<root>") : QString(dev->basetag());
case 1: return QString(dev->name());
}
@@ -29,7 +30,7 @@ QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const
{
- if(!index.isValid())
+ if (!index.isValid())
return 0;
return QAbstractItemModel::flags(index);
@@ -37,30 +38,33 @@ Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const
QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if(role != Qt::DisplayRole || section < 0 || section >= 2)
+ if (role != Qt::DisplayRole || section < 0 || section >= 2)
return QVariant();
return QString(section ? "Name" : "Tag");
}
QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const
{
- if(!hasIndex(row, column, parent))
+ if (!hasIndex(row, column, parent))
return QModelIndex();
device_t *target = nullptr;
- if(!parent.isValid()) {
- if(row == 0)
- target = &m_machine->root_device();
+ if (!parent.isValid())
+ {
+ if (row == 0)
+ target = &m_machine.root_device();
- } else {
+ }
+ else
+ {
device_t *dparent = static_cast<device_t *>(parent.internalPointer());
int count = row;
for(target = dparent->subdevices().first(); count && target; target = target->next())
count--;
}
- if(target)
+ if (target)
return createIndex(row, column, target);
return QModelIndex();
@@ -68,19 +72,20 @@ QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &pa
QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const
{
- if(!index.isValid())
+ if (!index.isValid())
return QModelIndex();
device_t *dchild = static_cast<device_t *>(index.internalPointer());
device_t *dparent = dchild->owner();
- if(!dparent)
+ if (!dparent)
return QModelIndex();
device_t *dpp = dparent->owner();
int row = 0;
- if(dpp) {
- for(device_t *child = dpp->subdevices().first(); child && child != dparent; child = child->next())
+ if (dpp)
+ {
+ for (device_t *child = dpp->subdevices().first(); child && child != dparent; child = child->next())
row++;
}
return createIndex(row, 0, dparent);
@@ -88,7 +93,7 @@ QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const
int DevicesWindowModel::rowCount(const QModelIndex &parent) const
{
- if(!parent.isValid())
+ if (!parent.isValid())
return 1;
device_t *dparent = static_cast<device_t *>(parent.internalPointer());
@@ -102,7 +107,7 @@ int DevicesWindowModel::columnCount(const QModelIndex &parent) const
-DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) :
+DevicesWindow::DevicesWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr),
m_devices_model(machine)
{
@@ -151,17 +156,17 @@ void DevicesWindow::activated(const QModelIndex &index)
//=========================================================================
// DevicesWindowQtConfig
//=========================================================================
-void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget)
+void DevicesWindowQtConfig::buildFromQWidget(QWidget *widget)
{
WindowQtConfig::buildFromQWidget(widget);
- // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget);
+ // DevicesWindow *window = dynamic_cast<DevicesWindow *>(widget);
}
-void DevicesWindowQtConfig::applyToQWidget(QWidget* widget)
+void DevicesWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
- // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget);
+ // DevicesWindow *window = dynamic_cast<DevicesWindow *>(widget);
}
diff --git a/src/osd/modules/debugger/qt/deviceswindow.h b/src/osd/modules/debugger/qt/deviceswindow.h
index 87e710a001b..884ad87d421 100644
--- a/src/osd/modules/debugger/qt/deviceswindow.h
+++ b/src/osd/modules/debugger/qt/deviceswindow.h
@@ -1,12 +1,12 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_DEVICES_WINDOW_H__
-#define __DEBUG_QT_DEVICES_WINDOW_H__
-
-#include <QtWidgets/QTreeView>
+#ifndef MAME_DEBUGGER_QT_DEVICESWINDOW_H
+#define MAME_DEBUGGER_QT_DEVICESWINDOW_H
#include "windowqt.h"
+#include <QtWidgets/QTreeView>
+
//============================================================
// The model for the treeview
@@ -17,21 +17,19 @@ class DevicesWindowModel : public QAbstractItemModel
Q_OBJECT
public:
- explicit DevicesWindowModel(running_machine *machine, QObject *parent = 0);
+ explicit DevicesWindowModel(running_machine &machine, QObject *parent = nullptr);
~DevicesWindowModel();
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
private:
- running_machine *m_machine;
+ running_machine &m_machine;
};
//============================================================
@@ -42,7 +40,7 @@ class DevicesWindow : public WindowQt
Q_OBJECT
public:
- DevicesWindow(running_machine* machine, QWidget* parent=nullptr);
+ DevicesWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~DevicesWindow();
public slots:
@@ -71,11 +69,11 @@ public:
~DevicesWindowQtConfig() {}
- void buildFromQWidget(QWidget* widget);
- void applyToQWidget(QWidget* widget);
+ void buildFromQWidget(QWidget *widget);
+ void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
-#endif
+#endif // MAME_DEBUGGER_QT_DEVICESWINDOW_H
diff --git a/src/osd/modules/debugger/qt/logwindow.cpp b/src/osd/modules/debugger/qt/logwindow.cpp
index d0478a24e40..9649014fc6f 100644
--- a/src/osd/modules/debugger/qt/logwindow.cpp
+++ b/src/osd/modules/debugger/qt/logwindow.cpp
@@ -10,12 +10,12 @@
#include "debug/dvdisasm.h"
-LogWindow::LogWindow(running_machine* machine, QWidget* parent) :
+LogWindow::LogWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
setWindowTitle("Debug: Machine Log");
- if (parent != nullptr)
+ if (parent)
{
QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@@ -24,12 +24,10 @@ LogWindow::LogWindow(running_machine* machine, QWidget* parent) :
//
// The main frame and its input and log widgets
//
- QFrame* mainWindowFrame = new QFrame(this);
+ QFrame *mainWindowFrame = new QFrame(this);
// The main log view
- m_logView = new DebuggerView(DVT_LOG,
- m_machine,
- this);
+ m_logView = new DebuggerView(DVT_LOG, m_machine, this);
// Layout
QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
@@ -49,13 +47,13 @@ LogWindow::~LogWindow()
//=========================================================================
// LogWindowQtConfig
//=========================================================================
-void LogWindowQtConfig::buildFromQWidget(QWidget* widget)
+void LogWindowQtConfig::buildFromQWidget(QWidget *widget)
{
WindowQtConfig::buildFromQWidget(widget);
}
-void LogWindowQtConfig::applyToQWidget(QWidget* widget)
+void LogWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
}
diff --git a/src/osd/modules/debugger/qt/logwindow.h b/src/osd/modules/debugger/qt/logwindow.h
index 53228ceafca..05d4d15514f 100644
--- a/src/osd/modules/debugger/qt/logwindow.h
+++ b/src/osd/modules/debugger/qt/logwindow.h
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_LOG_WINDOW_H__
-#define __DEBUG_QT_LOG_WINDOW_H__
+#ifndef MAME_DEBUGGER_QT_LOGWINDOW_H
+#define MAME_DEBUGGER_QT_LOGWINDOW_H
#include "debuggerview.h"
#include "windowqt.h"
@@ -15,13 +15,12 @@ class LogWindow : public WindowQt
Q_OBJECT
public:
- LogWindow(running_machine* machine, QWidget* parent=nullptr);
+ LogWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~LogWindow();
-
private:
// Widgets
- DebuggerView* m_logView;
+ DebuggerView *m_logView;
};
@@ -38,11 +37,11 @@ public:
~LogWindowQtConfig() {}
- void buildFromQWidget(QWidget* widget);
- void applyToQWidget(QWidget* widget);
+ void buildFromQWidget(QWidget *widget);
+ void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
-#endif
+#endif // MAME_DEBUGGER_QT_LOGWINDOW_H
diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp
index 75e25c2670d..b0043c06dee 100644
--- a/src/osd/modules/debugger/qt/mainwindow.cpp
+++ b/src/osd/modules/debugger/qt/mainwindow.cpp
@@ -1,14 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
-#include <QtWidgets/QAction>
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QDockWidget>
-#include <QtWidgets/QScrollBar>
-#include <QtWidgets/QFileDialog>
-#include <QtGui/QCloseEvent>
-
#include "mainwindow.h"
#include "debug/debugcon.h"
@@ -16,8 +8,16 @@
#include "debug/dvdisasm.h"
#include "debug/points.h"
+#include <QtGui/QCloseEvent>
+#include <QtWidgets/QAction>
+#include <QtWidgets/QDockWidget>
+#include <QtWidgets/QFileDialog>
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QMenuBar>
+#include <QtWidgets/QScrollBar>
+
-MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
+MainWindow::MainWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr),
m_historyIndex(0),
m_inputHistory()
@@ -27,7 +27,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
//
// The main frame and its input and log widgets
//
- QFrame* mainWindowFrame = new QFrame(this);
+ QFrame *mainWindowFrame = new QFrame(this);
// The input line
m_inputEdit = new QLineEdit(mainWindowFrame);
@@ -36,13 +36,11 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
// The log view
- m_consoleView = new DebuggerView(DVT_CONSOLE,
- m_machine,
- mainWindowFrame);
+ m_consoleView = new DebuggerView(DVT_CONSOLE, m_machine, mainWindowFrame);
m_consoleView->setFocusPolicy(Qt::NoFocus);
m_consoleView->setPreferBottom(true);
- QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
+ QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->addWidget(m_consoleView);
vLayout->addWidget(m_inputEdit);
vLayout->setSpacing(3);
@@ -65,11 +63,11 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
connect(m_runToCursorAct, &QAction::triggered, this, &MainWindow::runToCursor);
// Right bar options
- QActionGroup* rightBarGroup = new QActionGroup(this);
+ QActionGroup *rightBarGroup = new QActionGroup(this);
rightBarGroup->setObjectName("rightbargroup");
- QAction* rightActRaw = new QAction("Raw Opcodes", this);
- QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
- QAction* rightActComments = new QAction("Comments", this);
+ QAction *rightActRaw = new QAction("Raw Opcodes", this);
+ QAction *rightActEncrypted = new QAction("Encrypted Opcodes", this);
+ QAction *rightActComments = new QAction("Comments", this);
rightActRaw->setCheckable(true);
rightActEncrypted->setCheckable(true);
rightActComments->setCheckable(true);
@@ -83,7 +81,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
connect(rightBarGroup, &QActionGroup::triggered, this, &MainWindow::rightBarChanged);
// Assemble the options menu
- QMenu* optionsMenu = menuBar()->addMenu("&Options");
+ QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addAction(m_breakpointToggleAct);
optionsMenu->addAction(m_breakpointEnableAct);
optionsMenu->addAction(m_runToCursorAct);
@@ -93,22 +91,20 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
//
// Images menu
//
- image_interface_enumerator imageIterTest(m_machine->root_device());
- if (imageIterTest.first() != nullptr)
- {
+ image_interface_enumerator imageIterTest(m_machine.root_device());
+ if (imageIterTest.first())
createImagesMenu();
- }
//
// Dock window menu
//
- QMenu* dockMenu = menuBar()->addMenu("Doc&ks");
+ QMenu *dockMenu = menuBar()->addMenu("Doc&ks");
setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
// The processor dock
- QDockWidget* cpuDock = new QDockWidget("processor", this);
+ QDockWidget *cpuDock = new QDockWidget("processor", this);
cpuDock->setObjectName("cpudock");
cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea);
m_procFrame = new ProcessorDockWidget(m_machine, cpuDock);
@@ -118,7 +114,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
dockMenu->addAction(cpuDock->toggleViewAction());
// The disassembly dock
- QDockWidget* dasmDock = new QDockWidget("dasm", this);
+ QDockWidget *dasmDock = new QDockWidget("dasm", this);
dasmDock->setObjectName("dasmdock");
dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
m_dasmFrame = new DasmDockWidget(m_machine, dasmDock);
@@ -135,7 +131,7 @@ MainWindow::~MainWindow()
}
-void MainWindow::setProcessor(device_t* processor)
+void MainWindow::setProcessor(device_t *processor)
{
// Cpu swap
m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_for_device(processor));
@@ -146,13 +142,12 @@ void MainWindow::setProcessor(device_t* processor)
m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y);
// Window title
- string_format("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag());
- setWindowTitle(string_format("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag()).c_str());
+ setWindowTitle(string_format("Debug: %s - %s '%s'", m_machine.system().name, processor->name(), processor->tag()).c_str());
}
// Used to intercept the user clicking 'X' in the upper corner
-void MainWindow::closeEvent(QCloseEvent* event)
+void MainWindow::closeEvent(QCloseEvent *event)
{
debugActQuit();
@@ -162,18 +157,14 @@ void MainWindow::closeEvent(QCloseEvent* event)
// Used to intercept the user hitting the up arrow in the input widget
-bool MainWindow::eventFilter(QObject* obj, QEvent* event)
+bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
// Only filter keypresses
- QKeyEvent* keyEvent = nullptr;
+ QKeyEvent *keyEvent = nullptr;
if (event->type() == QEvent::KeyPress)
- {
keyEvent = static_cast<QKeyEvent*>(event);
- }
else
- {
return QObject::eventFilter(obj, event);
- }
// Catch up & down keys
if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down)
@@ -215,7 +206,7 @@ bool MainWindow::eventFilter(QObject* obj, QEvent* event)
void MainWindow::toggleBreakpointAtCursor(bool changedTo)
{
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device()))
+ if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
offs_t const address = downcast<debug_view_disasm *>(dasmView)->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug();
@@ -225,15 +216,11 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
// If none exists, add a new one
std::string command;
- if (bp == nullptr)
- {
+ if (!bp)
command = string_format("bpset 0x%X", address);
- }
else
- {
command = string_format("bpclear 0x%X", bp->index());
- }
- m_machine->debugger().console().execute_command(command.c_str(), true);
+ m_machine.debugger().console().execute_command(command.c_str(), true);
}
refreshAll();
@@ -243,7 +230,7 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
void MainWindow::enableBreakpointAtCursor(bool changedTo)
{
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device()))
+ if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
offs_t const address = dasmView->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug();
@@ -251,11 +238,11 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
// Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
- if (bp != nullptr)
+ if (bp)
{
int32_t const bpindex = bp->index();
std::string command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex);
- m_machine->debugger().console().execute_command(command.c_str(), true);
+ m_machine.debugger().console().execute_command(command.c_str(), true);
}
}
@@ -265,31 +252,27 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
void MainWindow::runToCursor(bool changedTo)
{
- debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device()))
+ debug_view_disasm *dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
std::string command = string_format("go 0x%X", address);
- m_machine->debugger().console().execute_command(command.c_str(), true);
+ m_machine.debugger().console().execute_command(command.c_str(), true);
}
}
-void MainWindow::rightBarChanged(QAction* changedTo)
+void MainWindow::rightBarChanged(QAction *changedTo)
{
- debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ debug_view_disasm *dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+
if (changedTo->text() == "Raw Opcodes")
- {
dasmView->set_right_column(DASM_RIGHTCOL_RAW);
- }
else if (changedTo->text() == "Encrypted Opcodes")
- {
dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
- }
else if (changedTo->text() == "Comments")
- {
dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS);
- }
+
m_dasmFrame->view()->viewport()->update();
}
@@ -305,12 +288,12 @@ void MainWindow::executeCommand(bool withClear)
// A blank command is a "silent step"
if (command == "")
{
- m_machine->debugger().console().get_visible_cpu()->debug()->single_step();
+ m_machine.debugger().console().get_visible_cpu()->debug()->single_step();
return;
}
// Send along the command
- m_machine->debugger().console().execute_command(command.toLocal8Bit().data(), true);
+ m_machine.debugger().console().execute_command(command.toLocal8Bit().data(), true);
// Add history & set the index to be the top of the stack
addToHistory(command);
@@ -332,24 +315,25 @@ void MainWindow::mountImage(bool changedTo)
{
// The image interface index was assigned to the QAction's data memeber
const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
- image_interface_enumerator iter(m_machine->root_device());
+ image_interface_enumerator iter(m_machine.root_device());
device_image_interface *img = iter.byindex(imageIndex);
- if (img == nullptr)
+ if (!img)
{
- m_machine->debugger().console().printf("Something is wrong with the mount menu.\n");
+ m_machine.debugger().console().printf("Something is wrong with the mount menu.\n");
refreshAll();
return;
}
// File dialog
- QString filename = QFileDialog::getOpenFileName(this,
- "Select an image file",
- QDir::currentPath(),
- tr("All files (*.*)"));
+ QString filename = QFileDialog::getOpenFileName(
+ this,
+ "Select an image file",
+ QDir::currentPath(),
+ tr("All files (*.*)"));
if (img->load(filename.toUtf8().data()) != image_init_result::PASS)
{
- m_machine->debugger().console().printf("Image could not be mounted.\n");
+ m_machine.debugger().console().printf("Image could not be mounted.\n");
refreshAll();
return;
}
@@ -359,13 +343,13 @@ void MainWindow::mountImage(bool changedTo)
unmountAct->setEnabled(true);
// Set the mount name
- QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
+ QMenu *parentMenuItem = dynamic_cast<QMenu *>(sender()->parent());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString(img->filename());
parentMenuItem->setTitle(newTitle);
- m_machine->debugger().console().printf("Image %s mounted successfully.\n", filename.toUtf8().data());
+ m_machine.debugger().console().printf("Image %s mounted successfully.\n", filename.toUtf8().data());
refreshAll();
}
@@ -373,31 +357,31 @@ void MainWindow::mountImage(bool changedTo)
void MainWindow::unmountImage(bool changedTo)
{
// The image interface index was assigned to the QAction's data memeber
- const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
- image_interface_enumerator iter(m_machine->root_device());
+ const int imageIndex = dynamic_cast<QAction *>(sender())->data().toInt();
+ image_interface_enumerator iter(m_machine.root_device());
device_image_interface *img = iter.byindex(imageIndex);
img->unload();
// Deactivate the unmount menu option
- dynamic_cast<QAction*>(sender())->setEnabled(false);
+ dynamic_cast<QAction *>(sender())->setEnabled(false);
// Set the mount name
- QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
+ QMenu *parentMenuItem = dynamic_cast<QMenu *>(sender()->parent());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString("[empty slot]");
parentMenuItem->setTitle(newTitle);
- m_machine->debugger().console().printf("Image successfully unmounted.\n");
+ m_machine.debugger().console().printf("Image successfully unmounted.\n");
refreshAll();
}
void MainWindow::dasmViewUpdated()
{
- debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- bool const haveCursor = dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device());
+ debug_view_disasm *const dasmView = downcast<debug_view_disasm *>(m_dasmFrame->view()->view());
+ bool const haveCursor = dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device());
bool haveBreakpoint = false;
bool breakpointEnabled = false;
if (haveCursor)
@@ -409,7 +393,7 @@ void MainWindow::dasmViewUpdated()
// Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
- if (bp != nullptr)
+ if (bp)
{
haveBreakpoint = true;
breakpointEnabled = bp->enabled();
@@ -426,7 +410,7 @@ void MainWindow::dasmViewUpdated()
void MainWindow::debugActClose()
{
- m_machine->schedule_exit();
+ m_machine.schedule_exit();
}
@@ -436,7 +420,7 @@ void MainWindow::addToHistory(const QString& command)
return;
// Always push back when there is no previous history
- if (m_inputHistory.size() == 0)
+ if (m_inputHistory.empty())
{
m_inputHistory.push_back(m_inputEdit->text());
return;
@@ -444,26 +428,24 @@ void MainWindow::addToHistory(const QString& command)
// If there is previous history, make sure it's not what you just executed
if (m_inputHistory.back() != m_inputEdit->text())
- {
m_inputHistory.push_back(m_inputEdit->text());
- }
}
void MainWindow::createImagesMenu()
{
- QMenu* imagesMenu = menuBar()->addMenu("&Images");
+ QMenu *imagesMenu = menuBar()->addMenu("&Images");
int interfaceIndex = 0;
- for (device_image_interface &img : image_interface_enumerator(m_machine->root_device()))
+ for (device_image_interface &img : image_interface_enumerator(m_machine.root_device()))
{
std::string menuName = string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[empty slot]");
- QMenu* interfaceMenu = imagesMenu->addMenu(menuName.c_str());
+ QMenu *interfaceMenu = imagesMenu->addMenu(menuName.c_str());
interfaceMenu->setObjectName(img.device().name());
- QAction* mountAct = new QAction("Mount...", interfaceMenu);
- QAction* unmountAct = new QAction("Unmount", interfaceMenu);
+ QAction *mountAct = new QAction("Mount...", interfaceMenu);
+ QAction *unmountAct = new QAction("Unmount", interfaceMenu);
mountAct->setObjectName("mount");
mountAct->setData(QVariant(interfaceIndex));
unmountAct->setObjectName("unmount");
@@ -490,10 +472,10 @@ void MainWindow::createImagesMenu()
void MainWindowQtConfig::buildFromQWidget(QWidget* widget)
{
WindowQtConfig::buildFromQWidget(widget);
- MainWindow* window = dynamic_cast<MainWindow*>(widget);
+ MainWindow *window = dynamic_cast<MainWindow *>(widget);
m_windowState = window->saveState();
- QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
+ QActionGroup *rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
if (rightBarGroup->checkedAction()->text() == "Raw Opcodes")
m_rightBar = 0;
else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes")
@@ -503,10 +485,10 @@ void MainWindowQtConfig::buildFromQWidget(QWidget* widget)
}
-void MainWindowQtConfig::applyToQWidget(QWidget* widget)
+void MainWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
- MainWindow* window = dynamic_cast<MainWindow*>(widget);
+ MainWindow *window = dynamic_cast<MainWindow *>(widget);
window->restoreState(m_windowState);
QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
diff --git a/src/osd/modules/debugger/qt/mainwindow.h b/src/osd/modules/debugger/qt/mainwindow.h
index 95a4e53ca99..6c1e9baefcb 100644
--- a/src/osd/modules/debugger/qt/mainwindow.h
+++ b/src/osd/modules/debugger/qt/mainwindow.h
@@ -1,18 +1,19 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_MAIN_WINDOW_H__
-#define __DEBUG_QT_MAIN_WINDOW_H__
+#ifndef MAME_DEBUGGER_QT_MAINWINDOW_H
+#define MAME_DEBUGGER_QT_MAINWINDOW_H
-#include <vector>
+#include "debuggerview.h"
+#include "windowqt.h"
+
+#include "debug/dvdisasm.h"
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QComboBox>
-#include "debug/dvdisasm.h"
+#include <vector>
-#include "debuggerview.h"
-#include "windowqt.h"
class DasmDockWidget;
class ProcessorDockWidget;
@@ -26,25 +27,24 @@ class MainWindow : public WindowQt
Q_OBJECT
public:
- MainWindow(running_machine* machine, QWidget* parent=nullptr);
+ MainWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~MainWindow();
- void setProcessor(device_t* processor);
+ void setProcessor(device_t *processor);
protected:
// Used to intercept the user clicking 'X' in the upper corner
- void closeEvent(QCloseEvent* event);
+ void closeEvent(QCloseEvent *event);
// Used to intercept the user hitting the up arrow in the input widget
- bool eventFilter(QObject* obj, QEvent* event);
-
+ bool eventFilter(QObject *obj, QEvent *event);
private slots:
void toggleBreakpointAtCursor(bool changedTo);
void enableBreakpointAtCursor(bool changedTo);
void runToCursor(bool changedTo);
- void rightBarChanged(QAction* changedTo);
+ void rightBarChanged(QAction *changedTo);
void executeCommandSlot();
@@ -61,15 +61,15 @@ private:
void createImagesMenu();
// Widgets and docks
- QLineEdit* m_inputEdit;
- DebuggerView* m_consoleView;
- ProcessorDockWidget* m_procFrame;
- DasmDockWidget* m_dasmFrame;
+ QLineEdit *m_inputEdit;
+ DebuggerView *m_consoleView;
+ ProcessorDockWidget *m_procFrame;
+ DasmDockWidget *m_dasmFrame;
// Menu items
- QAction* m_breakpointToggleAct;
- QAction* m_breakpointEnableAct;
- QAction* m_runToCursorAct;
+ QAction *m_breakpointToggleAct;
+ QAction *m_breakpointEnableAct;
+ QAction *m_runToCursorAct;
// Terminal history
int m_historyIndex;
@@ -87,45 +87,31 @@ class DasmDockWidget : public QWidget
Q_OBJECT
public:
- DasmDockWidget(running_machine* machine, QWidget* parent=nullptr) :
+ DasmDockWidget(running_machine &machine, QWidget *parent = nullptr) :
QWidget(parent),
m_machine(machine)
{
- m_dasmView = new DebuggerView(DVT_DISASSEMBLY,
- m_machine,
- this);
+ m_dasmView = new DebuggerView(DVT_DISASSEMBLY, m_machine, this);
// Force a recompute of the disassembly region
downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");
- QVBoxLayout* dvLayout = new QVBoxLayout(this);
+ QVBoxLayout *dvLayout = new QVBoxLayout(this);
dvLayout->addWidget(m_dasmView);
dvLayout->setContentsMargins(4,0,4,0);
}
-
virtual ~DasmDockWidget();
+ DebuggerView *view() { return m_dasmView; }
- DebuggerView* view() { return m_dasmView; }
-
-
- QSize minimumSizeHint() const
- {
- return QSize(150,150);
- }
-
-
- QSize sizeHint() const
- {
- return QSize(150,200);
- }
-
+ QSize minimumSizeHint() const { return QSize(150, 150); }
+ QSize sizeHint() const { return QSize(150, 200); }
private:
- DebuggerView* m_dasmView;
+ running_machine &m_machine;
- running_machine* m_machine;
+ DebuggerView *m_dasmView;
};
@@ -137,45 +123,30 @@ class ProcessorDockWidget : public QWidget
Q_OBJECT
public:
- ProcessorDockWidget(running_machine* machine,
- QWidget* parent=nullptr) :
+ ProcessorDockWidget(running_machine &machine, QWidget *parent = nullptr) :
QWidget(parent),
- m_processorView(nullptr),
- m_machine(machine)
+ m_machine(machine),
+ m_processorView(nullptr)
{
- m_processorView = new DebuggerView(DVT_STATE,
- m_machine,
- this);
+ m_processorView = new DebuggerView(DVT_STATE, m_machine, this);
m_processorView->setFocusPolicy(Qt::NoFocus);
- QVBoxLayout* cvLayout = new QVBoxLayout(this);
+ QVBoxLayout *cvLayout = new QVBoxLayout(this);
cvLayout->addWidget(m_processorView);
cvLayout->setContentsMargins(4,0,4,2);
}
-
virtual ~ProcessorDockWidget();
+ DebuggerView *view() { return m_processorView; }
- DebuggerView* view() { return m_processorView; }
-
-
- QSize minimumSizeHint() const
- {
- return QSize(150,300);
- }
-
-
- QSize sizeHint() const
- {
- return QSize(200,300);
- }
-
+ QSize minimumSizeHint() const { return QSize(150, 300); }
+ QSize sizeHint() const { return QSize(200, 300); }
private:
- DebuggerView* m_processorView;
+ running_machine &m_machine;
- running_machine* m_machine;
+ DebuggerView *m_processorView;
};
@@ -197,12 +168,11 @@ public:
int m_rightBar;
QByteArray m_windowState;
- void buildFromQWidget(QWidget* widget);
- void applyToQWidget(QWidget* widget);
+ void buildFromQWidget(QWidget *widget);
+ void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
-
-#endif
+#endif // MAME_DEBUGGER_QT_MAINWINDOW_H
diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp
index fd86d240f2c..149729e247d 100644
--- a/src/osd/modules/debugger/qt/memorywindow.cpp
+++ b/src/osd/modules/debugger/qt/memorywindow.cpp
@@ -1,6 +1,12 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
+#include "memorywindow.h"
+
+#include "debug/dvmemory.h"
+#include "debug/debugcon.h"
+#include "debug/debugcpu.h"
+
#include <QtGui/QClipboard>
#include <QtGui/QMouseEvent>
#include <QtWidgets/QActionGroup>
@@ -12,22 +18,16 @@
#include <QtWidgets/QToolTip>
#include <QtWidgets/QVBoxLayout>
-#include "memorywindow.h"
-
-#include "debug/dvmemory.h"
-#include "debug/debugcon.h"
-#include "debug/debugcpu.h"
-
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define horizontalAdvance width
#endif
-MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
+MemoryWindow::MemoryWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
setWindowTitle("Debug: Memory View");
- if (parent != nullptr)
+ if (parent)
{
QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@@ -36,10 +36,10 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
//
// The main frame and its input and log widgets
//
- QFrame* mainWindowFrame = new QFrame(this);
+ QFrame *mainWindowFrame = new QFrame(this);
// The top frame & groupbox that contains the input widgets
- QFrame* topSubFrame = new QFrame(mainWindowFrame);
+ QFrame *topSubFrame = new QFrame(mainWindowFrame);
// The input edit
m_inputEdit = new QLineEdit(topSubFrame);
@@ -49,19 +49,19 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
m_memoryComboBox = new QComboBox(topSubFrame);
m_memoryComboBox->setObjectName("memoryregion");
m_memoryComboBox->setMinimumWidth(300);
- connect(m_memoryComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MemoryWindow::memoryRegionChanged);
+ connect(m_memoryComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MemoryWindow::memoryRegionChanged);
// The main memory window
m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this);
// Layout
- QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
+ QHBoxLayout *subLayout = new QHBoxLayout(topSubFrame);
subLayout->addWidget(m_inputEdit);
subLayout->addWidget(m_memoryComboBox);
subLayout->setSpacing(3);
subLayout->setContentsMargins(2,2,2,2);
- QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
+ QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->setSpacing(3);
vLayout->setContentsMargins(2,2,2,2);
vLayout->addWidget(topSubFrame);
@@ -74,15 +74,15 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
//
// Create a data format group
- QActionGroup* dataFormat = new QActionGroup(this);
+ QActionGroup *dataFormat = new QActionGroup(this);
dataFormat->setObjectName("dataformat");
- QAction* formatActOne = new QAction("1-byte chunks", this);
- QAction* formatActTwo = new QAction("2-byte chunks", this);
- QAction* formatActFour = new QAction("4-byte chunks", this);
- QAction* formatActEight = new QAction("8-byte chunks", this);
- QAction* formatAct32bitFloat = new QAction("32 bit floating point", this);
- QAction* formatAct64bitFloat = new QAction("64 bit floating point", this);
- QAction* formatAct80bitFloat = new QAction("80 bit floating point", this);
+ QAction *formatActOne = new QAction("1-byte chunks", this);
+ QAction *formatActTwo = new QAction("2-byte chunks", this);
+ QAction *formatActFour = new QAction("4-byte chunks", this);
+ QAction *formatActEight = new QAction("8-byte chunks", this);
+ QAction *formatAct32bitFloat = new QAction("32 bit floating point", this);
+ QAction *formatAct64bitFloat = new QAction("64 bit floating point", this);
+ QAction *formatAct80bitFloat = new QAction("80 bit floating point", this);
formatActOne->setObjectName("formatActOne");
formatActTwo->setObjectName("formatActTwo");
formatActFour->setObjectName("formatActFour");
@@ -112,10 +112,10 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
formatActOne->setChecked(true);
connect(dataFormat, &QActionGroup::triggered, this, &MemoryWindow::formatChanged);
// Create a address display group
- QActionGroup* addressGroup = new QActionGroup(this);
+ QActionGroup *addressGroup = new QActionGroup(this);
addressGroup->setObjectName("addressgroup");
- QAction* addressActLogical = new QAction("Logical Addresses", this);
- QAction* addressActPhysical = new QAction("Physical Addresses", this);
+ QAction *addressActLogical = new QAction("Logical Addresses", this);
+ QAction *addressActPhysical = new QAction("Physical Addresses", this);
addressActLogical->setCheckable(true);
addressActPhysical->setCheckable(true);
addressActLogical->setActionGroup(addressGroup);
@@ -126,22 +126,22 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
connect(addressGroup, &QActionGroup::triggered, this, &MemoryWindow::addressChanged);
// Create a reverse view radio
- QAction* reverseAct = new QAction("Reverse View", this);
+ QAction *reverseAct = new QAction("Reverse View", this);
reverseAct->setObjectName("reverse");
reverseAct->setCheckable(true);
reverseAct->setShortcut(QKeySequence("Ctrl+R"));
connect(reverseAct, &QAction::toggled, this, &MemoryWindow::reverseChanged);
// Create increase and decrease bytes-per-line actions
- QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this);
- QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this);
+ QAction *increaseBplAct = new QAction("Increase Bytes Per Line", this);
+ QAction *decreaseBplAct = new QAction("Decrease Bytes Per Line", this);
increaseBplAct->setShortcut(QKeySequence("Ctrl+P"));
decreaseBplAct->setShortcut(QKeySequence("Ctrl+O"));
connect(increaseBplAct, &QAction::triggered, this, &MemoryWindow::increaseBytesPerLine);
connect(decreaseBplAct, &QAction::triggered, this, &MemoryWindow::decreaseBytesPerLine);
// Assemble the options menu
- QMenu* optionsMenu = menuBar()->addMenu("&Options");
+ QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addActions(dataFormat->actions());
optionsMenu->addSeparator();
optionsMenu->addActions(addressGroup->actions());
@@ -173,17 +173,17 @@ void MemoryWindow::memoryRegionChanged(int index)
m_memTable->viewport()->update();
// Update the data format radio buttons to the memory region's default
- debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view());
- switch(memView->get_data_format())
+ debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
+ switch (memView->get_data_format())
{
- case 1: dataFormatMenuItem("formatActOne")->setChecked(true); break;
- case 2: dataFormatMenuItem("formatActTwo")->setChecked(true); break;
- case 4: dataFormatMenuItem("formatActFour")->setChecked(true); break;
- case 8: dataFormatMenuItem("formatActEight")->setChecked(true); break;
- case 9: dataFormatMenuItem("formatAct32bitFloat")->setChecked(true); break;
- case 10: dataFormatMenuItem("formatAct64bitFloat")->setChecked(true); break;
- case 11: dataFormatMenuItem("formatAct80bitFloat")->setChecked(true); break;
- default: break;
+ case 1: dataFormatMenuItem("formatActOne")->setChecked(true); break;
+ case 2: dataFormatMenuItem("formatActTwo")->setChecked(true); break;
+ case 4: dataFormatMenuItem("formatActFour")->setChecked(true); break;
+ case 8: dataFormatMenuItem("formatActEight")->setChecked(true); break;
+ case 9: dataFormatMenuItem("formatAct32bitFloat")->setChecked(true); break;
+ case 10: dataFormatMenuItem("formatAct64bitFloat")->setChecked(true); break;
+ case 11: dataFormatMenuItem("formatAct80bitFloat")->setChecked(true); break;
+ default: break;
}
}
@@ -191,7 +191,7 @@ void MemoryWindow::memoryRegionChanged(int index)
void MemoryWindow::expressionSubmitted()
{
const QString expression = m_inputEdit->text();
- downcast<debug_view_memory*>(m_memTable->view())->set_expression(expression.toLocal8Bit().data());
+ downcast<debug_view_memory *>(m_memTable->view())->set_expression(expression.toLocal8Bit().data());
// Make the cursor pop
m_memTable->view()->set_cursor_visible(true);
@@ -208,57 +208,43 @@ void MemoryWindow::expressionSubmitted()
void MemoryWindow::formatChanged(QAction* changedTo)
{
- debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view());
+ debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
+
if (changedTo->text() == "1-byte chunks")
- {
memView->set_data_format(1);
- }
else if (changedTo->text() == "2-byte chunks")
- {
memView->set_data_format(2);
- }
else if (changedTo->text() == "4-byte chunks")
- {
memView->set_data_format(4);
- }
else if (changedTo->text() == "8-byte chunks")
- {
memView->set_data_format(8);
- }
else if (changedTo->text() == "32 bit floating point")
- {
memView->set_data_format(9);
- }
else if (changedTo->text() == "64 bit floating point")
- {
memView->set_data_format(10);
- }
else if (changedTo->text() == "80 bit floating point")
- {
memView->set_data_format(11);
- }
+
m_memTable->viewport()->update();
}
void MemoryWindow::addressChanged(QAction* changedTo)
{
- debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view());
+ debug_view_memory *memView = downcast<debug_view_memory *>(m_memTable->view());
+
if (changedTo->text() == "Logical Addresses")
- {
memView->set_physical(false);
- }
else if (changedTo->text() == "Physical Addresses")
- {
memView->set_physical(true);
- }
+
m_memTable->viewport()->update();
}
void MemoryWindow::reverseChanged(bool changedTo)
{
- debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view());
+ debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
memView->set_reverse(changedTo);
m_memTable->viewport()->update();
}
@@ -266,7 +252,7 @@ void MemoryWindow::reverseChanged(bool changedTo)
void MemoryWindow::increaseBytesPerLine(bool changedTo)
{
- debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view());
+ debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
memView->set_chunks_per_row(memView->chunks_per_row() + 1);
m_memTable->viewport()->update();
}
@@ -274,7 +260,7 @@ void MemoryWindow::increaseBytesPerLine(bool changedTo)
void MemoryWindow::decreaseBytesPerLine(bool checked)
{
- debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view());
+ debug_view_memory *memView = downcast<debug_view_memory *>(m_memTable->view());
memView->set_chunks_per_row(memView->chunks_per_row() - 1);
m_memTable->viewport()->update();
}
@@ -282,20 +268,18 @@ void MemoryWindow::decreaseBytesPerLine(bool checked)
void MemoryWindow::populateComboBox()
{
- if (m_memTable == nullptr)
+ if (!m_memTable)
return;
m_memoryComboBox->clear();
for (auto &source : m_memTable->view()->source_list())
- {
m_memoryComboBox->addItem(source->name());
- }
}
void MemoryWindow::setToCurrentCpu()
{
- device_t* curCpu = m_machine->debugger().console().get_visible_cpu();
+ device_t *curCpu = m_machine.debugger().console().get_visible_cpu();
if (curCpu)
{
const debug_view_source *source = m_memTable->view()->source_for_device(curCpu);
@@ -309,13 +293,14 @@ void MemoryWindow::setToCurrentCpu()
// I have a hard time storing QActions as class members. This is a substitute.
-QAction* MemoryWindow::dataFormatMenuItem(const QString& itemName)
+QAction *MemoryWindow::dataFormatMenuItem(const QString& itemName)
{
- QList<QMenu*> menus = menuBar()->findChildren<QMenu*>();
+ QList<QMenu *> menus = menuBar()->findChildren<QMenu *>();
for (int i = 0; i < menus.length(); i++)
{
- if (menus[i]->title() != "&Options") continue;
- QList<QAction*> actions = menus[i]->actions();
+ if (menus[i]->title() != "&Options")
+ continue;
+ QList<QAction *> actions = menus[i]->actions();
for (int j = 0; j < actions.length(); j++)
{
if (actions[j]->objectName() == itemName)
@@ -329,36 +314,25 @@ QAction* MemoryWindow::dataFormatMenuItem(const QString& itemName)
//=========================================================================
// DebuggerMemView
//=========================================================================
-void DebuggerMemView::mousePressEvent(QMouseEvent* event)
+void DebuggerMemView::addItemsToContextMenu(QMenu *menu)
{
- const bool leftClick = event->button() == Qt::LeftButton;
- const bool rightClick = event->button() == Qt::RightButton;
+ DebuggerView::addItemsToContextMenu(menu);
- if (leftClick || rightClick)
+ if (view()->cursor_visible())
{
- QFontMetrics actualFont = fontMetrics();
- const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
- const int fontHeight = std::max(1, actualFont.lineSpacing());
-
- debug_view_xy topLeft = view()->visible_position();
- debug_view_xy clickViewPosition;
- clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
- clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
- if (leftClick)
+ debug_view_memory &memView = downcast<debug_view_memory &>(*view());
+ debug_view_memory_source const &source = downcast<debug_view_memory_source const &>(*memView.source());
+ address_space *const addressSpace = source.space();
+ if (addressSpace)
{
- view()->process_click(DCK_LEFT_CLICK, clickViewPosition);
- }
- else if (rightClick)
- {
- // Display the last known PC to write to this memory location & copy it onto the clipboard
- debug_view_memory* memView = downcast<debug_view_memory*>(view());
- const offs_t address = memView->addressAtCursorPosition(clickViewPosition);
- const debug_view_memory_source* source = downcast<const debug_view_memory_source*>(memView->source());
- address_space* addressSpace = source->space();
+ // get the last known PC to write to this memory location
+ debug_view_xy const pos = view()->cursor_position();
+ offs_t const address = memView.addressAtCursorPosition(pos);
offs_t a = address & addressSpace->logaddrmask();
+ bool good = false;
if (!addressSpace->device().memory().translate(addressSpace->spacenum(), TRANSLATE_READ_DEBUG, a))
{
- QToolTip::showText(QCursor::pos(), "Bad address", nullptr);
+ m_lastPc = "Bad address";
}
else
{
@@ -366,69 +340,64 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event)
auto dis = addressSpace->device().machine().disable_side_effects();
switch (addressSpace->data_width())
{
- case 8:
- memValue = addressSpace->read_byte(a);
- break;
-
- case 16:
- memValue = addressSpace->read_word_unaligned(a);
- break;
-
- case 32:
- memValue = addressSpace->read_dword_unaligned(a);
- break;
-
- case 64:
- memValue = addressSpace->read_qword_unaligned(a);
- break;
+ case 8: memValue = addressSpace->read_byte(a); break;
+ case 16: memValue = addressSpace->read_word_unaligned(a); break;
+ case 32: memValue = addressSpace->read_dword_unaligned(a); break;
+ case 64: memValue = addressSpace->read_qword_unaligned(a); break;
}
- const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(),
- address,
- memValue);
- if (pc != (offs_t)(-1))
+ offs_t const pc = source.device()->debug()->track_mem_pc_from_space_address_data(
+ addressSpace->spacenum(),
+ address,
+ memValue);
+ if (pc != offs_t(-1))
{
- // TODO: You can specify a box that the tooltip stays alive within - might be good?
- const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16);
- QToolTip::showText(QCursor::pos(), addressAndPc, nullptr);
-
- // Copy the PC into the clipboard as well
- QClipboard *clipboard = QApplication::clipboard();
- clipboard->setText(QString("%1").arg(pc, 2, 16));
+ m_lastPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16);
+ good = true;
}
else
{
- QToolTip::showText(QCursor::pos(), "UNKNOWN PC", nullptr);
+ m_lastPc = "Unknown PC";
}
}
- }
- viewport()->update();
- update();
+ if (!menu->isEmpty())
+ menu->addSeparator();
+ QAction *const act = new QAction(m_lastPc, menu);
+ act->setEnabled(good);
+ connect(act, &QAction::triggered, this, &DebuggerMemView::copyLastPc);
+ menu->addAction(act);
+ }
}
}
+void DebuggerMemView::copyLastPc()
+{
+ QApplication::clipboard()->setText(m_lastPc);
+}
+
+
//=========================================================================
// MemoryWindowQtConfig
//=========================================================================
-void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget)
+void MemoryWindowQtConfig::buildFromQWidget(QWidget *widget)
{
WindowQtConfig::buildFromQWidget(widget);
- MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget);
- QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion");
+ MemoryWindow *window = dynamic_cast<MemoryWindow *>(widget);
+ QComboBox *memoryRegion = window->findChild<QComboBox*>("memoryregion");
m_memoryRegion = memoryRegion->currentIndex();
- QAction* reverse = window->findChild<QAction*>("reverse");
+ QAction *reverse = window->findChild<QAction *>("reverse");
m_reverse = reverse->isChecked();
- QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup");
+ QActionGroup *addressGroup = window->findChild<QActionGroup*>("addressgroup");
if (addressGroup->checkedAction()->text() == "Logical Addresses")
m_addressMode = 0;
else if (addressGroup->checkedAction()->text() == "Physical Addresses")
m_addressMode = 1;
- QActionGroup* dataFormat = window->findChild<QActionGroup*>("dataformat");
+ QActionGroup *dataFormat = window->findChild<QActionGroup*>("dataformat");
if (dataFormat->checkedAction()->text() == "1-byte chunks")
m_dataFormat = 0;
else if (dataFormat->checkedAction()->text() == "2-byte chunks")
@@ -446,20 +415,21 @@ void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget)
}
-void MemoryWindowQtConfig::applyToQWidget(QWidget* widget)
+void MemoryWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
- MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget);
- QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion");
+ MemoryWindow *window = dynamic_cast<MemoryWindow *>(widget);
+ QComboBox *memoryRegion = window->findChild<QComboBox *>("memoryregion");
memoryRegion->setCurrentIndex(m_memoryRegion);
- QAction* reverse = window->findChild<QAction*>("reverse");
- if (m_reverse) reverse->trigger();
+ QAction *reverse = window->findChild<QAction *>("reverse");
+ if (m_reverse)
+ reverse->trigger();
- QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup");
+ QActionGroup *addressGroup = window->findChild<QActionGroup*>("addressgroup");
addressGroup->actions()[m_addressMode]->trigger();
- QActionGroup* dataFormat = window->findChild<QActionGroup*>("dataformat");
+ QActionGroup *dataFormat = window->findChild<QActionGroup*>("dataformat");
dataFormat->actions()[m_dataFormat]->trigger();
}
diff --git a/src/osd/modules/debugger/qt/memorywindow.h b/src/osd/modules/debugger/qt/memorywindow.h
index ff0c974c838..a79e42bc693 100644
--- a/src/osd/modules/debugger/qt/memorywindow.h
+++ b/src/osd/modules/debugger/qt/memorywindow.h
@@ -1,14 +1,14 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_MEMORY_WINDOW_H__
-#define __DEBUG_QT_MEMORY_WINDOW_H__
-
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QComboBox>
+#ifndef MAME_DEBUGGER_QT_MEMORYWINDOW_H
+#define MAME_DEBUGGER_QT_MEMORYWINDOW_H
#include "debuggerview.h"
#include "windowqt.h"
+#include <QtWidgets/QComboBox>
+#include <QtWidgets/QLineEdit>
+
class DebuggerMemView;
@@ -20,31 +20,27 @@ class MemoryWindow : public WindowQt
Q_OBJECT
public:
- MemoryWindow(running_machine* machine, QWidget* parent=nullptr);
+ MemoryWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~MemoryWindow();
-
private slots:
void memoryRegionChanged(int index);
void expressionSubmitted();
- void formatChanged(QAction* changedTo);
- void addressChanged(QAction* changedTo);
+ void formatChanged(QAction *changedTo);
+ void addressChanged(QAction *changedTo);
void reverseChanged(bool changedTo);
void increaseBytesPerLine(bool changedTo);
- void decreaseBytesPerLine(bool checked=false);
-
+ void decreaseBytesPerLine(bool checked = false);
private:
void populateComboBox();
void setToCurrentCpu();
- QAction* dataFormatMenuItem(const QString& itemName);
-
+ QAction *dataFormatMenuItem(const QString &itemName);
-private:
// Widgets
- QLineEdit* m_inputEdit;
- QComboBox* m_memoryComboBox;
- DebuggerMemView* m_memTable;
+ QLineEdit *m_inputEdit;
+ QComboBox *m_memoryComboBox;
+ DebuggerMemView *m_memTable;
};
@@ -53,16 +49,23 @@ private:
//=========================================================================
class DebuggerMemView : public DebuggerView
{
+ Q_OBJECT
+
public:
- DebuggerMemView(const debug_view_type& type,
- running_machine* machine,
- QWidget* parent=nullptr)
+ DebuggerMemView(const debug_view_type& type, running_machine &machine, QWidget *parent = nullptr)
: DebuggerView(type, machine, parent)
{}
+
virtual ~DebuggerMemView() {}
protected:
- void mousePressEvent(QMouseEvent* event);
+ virtual void addItemsToContextMenu(QMenu *menu) override;
+
+private slots:
+ void copyLastPc();
+
+private:
+ QString m_lastPc;
};
@@ -89,11 +92,11 @@ public:
int m_dataFormat;
int m_memoryRegion;
- void buildFromQWidget(QWidget* widget);
- void applyToQWidget(QWidget* widget);
+ void buildFromQWidget(QWidget *widget);
+ void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
-#endif
+#endif // MAME_DEBUGGER_QT_MEMORYWINDOW_H
diff --git a/src/osd/modules/debugger/qt/windowqt.cpp b/src/osd/modules/debugger/qt/windowqt.cpp
index 73d92c632e7..13abd470c6f 100644
--- a/src/osd/modules/debugger/qt/windowqt.cpp
+++ b/src/osd/modules/debugger/qt/windowqt.cpp
@@ -1,18 +1,19 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMenuBar>
-
#include "windowqt.h"
-#include "logwindow.h"
-#include "dasmwindow.h"
-#include "memorywindow.h"
+
#include "breakpointswindow.h"
+#include "dasmwindow.h"
#include "deviceswindow.h"
+#include "logwindow.h"
+#include "memorywindow.h"
-#include "debug/debugcpu.h"
#include "debug/debugcon.h"
+#include "debug/debugcpu.h"
+
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QMenuBar>
bool WindowQt::s_refreshAll = false;
bool WindowQt::s_hideAll = false;
@@ -23,83 +24,83 @@ bool WindowQt::s_hideAll = false;
// however, is often used to place each child window & the code to do this can
// be found in most of the inherited classes.
-WindowQt::WindowQt(running_machine* machine, QWidget* parent) :
+WindowQt::WindowQt(running_machine &machine, QWidget *parent) :
QMainWindow(parent),
m_machine(machine)
{
setAttribute(Qt::WA_DeleteOnClose, true);
// The Debug menu bar
- QAction* debugActOpenMemory = new QAction("New &Memory Window", this);
+ QAction *debugActOpenMemory = new QAction("New &Memory Window", this);
debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M"));
connect(debugActOpenMemory, &QAction::triggered, this, &WindowQt::debugActOpenMemory);
- QAction* debugActOpenDasm = new QAction("New &Dasm Window", this);
+ QAction *debugActOpenDasm = new QAction("New &Dasm Window", this);
debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D"));
connect(debugActOpenDasm, &QAction::triggered, this, &WindowQt::debugActOpenDasm);
- QAction* debugActOpenLog = new QAction("New &Log Window", this);
+ QAction *debugActOpenLog = new QAction("New &Log Window", this);
debugActOpenLog->setShortcut(QKeySequence("Ctrl+L"));
connect(debugActOpenLog, &QAction::triggered, this, &WindowQt::debugActOpenLog);
- QAction* debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this);
+ QAction *debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this);
debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B"));
connect(debugActOpenPoints, &QAction::triggered, this, &WindowQt::debugActOpenPoints);
- QAction* debugActOpenDevices = new QAction("New D&evices Window", this);
+ QAction *debugActOpenDevices = new QAction("New D&evices Window", this);
debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D"));
connect(debugActOpenDevices, &QAction::triggered, this, &WindowQt::debugActOpenDevices);
- QAction* dbgActRun = new QAction("Run", this);
+ QAction *dbgActRun = new QAction("Run", this);
dbgActRun->setShortcut(Qt::Key_F5);
connect(dbgActRun, &QAction::triggered, this, &WindowQt::debugActRun);
- QAction* dbgActRunAndHide = new QAction("Run And Hide Debugger", this);
+ QAction *dbgActRunAndHide = new QAction("Run And Hide Debugger", this);
dbgActRunAndHide->setShortcut(Qt::Key_F12);
connect(dbgActRunAndHide, &QAction::triggered, this, &WindowQt::debugActRunAndHide);
- QAction* dbgActRunToNextCpu = new QAction("Run to Next CPU", this);
+ QAction *dbgActRunToNextCpu = new QAction("Run to Next CPU", this);
dbgActRunToNextCpu->setShortcut(Qt::Key_F6);
connect(dbgActRunToNextCpu, &QAction::triggered, this, &WindowQt::debugActRunToNextCpu);
- QAction* dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this);
+ QAction *dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this);
dbgActRunNextInt->setShortcut(Qt::Key_F7);
connect(dbgActRunNextInt, &QAction::triggered, this, &WindowQt::debugActRunNextInt);
- QAction* dbgActRunNextVBlank = new QAction("Run to Next VBlank", this);
+ QAction *dbgActRunNextVBlank = new QAction("Run to Next VBlank", this);
dbgActRunNextVBlank->setShortcut(Qt::Key_F8);
connect(dbgActRunNextVBlank, &QAction::triggered, this, &WindowQt::debugActRunNextVBlank);
- QAction* dbgActStepInto = new QAction("Step Into", this);
+ QAction *dbgActStepInto = new QAction("Step Into", this);
dbgActStepInto->setShortcut(Qt::Key_F11);
connect(dbgActStepInto, &QAction::triggered, this, &WindowQt::debugActStepInto);
- QAction* dbgActStepOver = new QAction("Step Over", this);
+ QAction *dbgActStepOver = new QAction("Step Over", this);
dbgActStepOver->setShortcut(Qt::Key_F10);
connect(dbgActStepOver, &QAction::triggered, this, &WindowQt::debugActStepOver);
- QAction* dbgActStepOut = new QAction("Step Out", this);
+ QAction *dbgActStepOut = new QAction("Step Out", this);
dbgActStepOut->setShortcut(QKeySequence("Shift+F11"));
connect(dbgActStepOut, &QAction::triggered, this, &WindowQt::debugActStepOut);
- QAction* dbgActSoftReset = new QAction("Soft Reset", this);
+ QAction *dbgActSoftReset = new QAction("Soft Reset", this);
dbgActSoftReset->setShortcut(Qt::Key_F3);
connect(dbgActSoftReset, &QAction::triggered, this, &WindowQt::debugActSoftReset);
- QAction* dbgActHardReset = new QAction("Hard Reset", this);
+ QAction *dbgActHardReset = new QAction("Hard Reset", this);
dbgActHardReset->setShortcut(QKeySequence("Shift+F3"));
connect(dbgActHardReset, &QAction::triggered, this, &WindowQt::debugActHardReset);
- QAction* dbgActClose = new QAction("Close &Window", this);
+ QAction *dbgActClose = new QAction("Close &Window", this);
dbgActClose->setShortcut(QKeySequence::Close);
connect(dbgActClose, &QAction::triggered, this, &WindowQt::debugActClose);
- QAction* dbgActQuit = new QAction("&Quit", this);
+ QAction *dbgActQuit = new QAction("&Quit", this);
dbgActQuit->setShortcut(QKeySequence::Quit);
connect(dbgActQuit, &QAction::triggered, this, &WindowQt::debugActQuit);
// Construct the menu
- QMenu* debugMenu = menuBar()->addMenu("&Debug");
+ QMenu *debugMenu = menuBar()->addMenu("&Debug");
debugMenu->addAction(debugActOpenMemory);
debugMenu->addAction(debugActOpenDasm);
debugMenu->addAction(debugActOpenLog);
@@ -130,7 +131,7 @@ WindowQt::~WindowQt()
void WindowQt::debugActOpenMemory()
{
- MemoryWindow* foo = new MemoryWindow(m_machine, this);
+ MemoryWindow *foo = new MemoryWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@@ -140,7 +141,7 @@ void WindowQt::debugActOpenMemory()
void WindowQt::debugActOpenDasm()
{
- DasmWindow* foo = new DasmWindow(m_machine, this);
+ DasmWindow *foo = new DasmWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@@ -150,7 +151,7 @@ void WindowQt::debugActOpenDasm()
void WindowQt::debugActOpenLog()
{
- LogWindow* foo = new LogWindow(m_machine, this);
+ LogWindow *foo = new LogWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@@ -160,7 +161,7 @@ void WindowQt::debugActOpenLog()
void WindowQt::debugActOpenPoints()
{
- BreakpointsWindow* foo = new BreakpointsWindow(m_machine, this);
+ BreakpointsWindow *foo = new BreakpointsWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@@ -170,7 +171,7 @@ void WindowQt::debugActOpenPoints()
void WindowQt::debugActOpenDevices()
{
- DevicesWindow* foo = new DevicesWindow(m_machine, this);
+ DevicesWindow *foo = new DevicesWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@@ -180,54 +181,54 @@ void WindowQt::debugActOpenDevices()
void WindowQt::debugActRun()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->go();
+ m_machine.debugger().console().get_visible_cpu()->debug()->go();
}
void WindowQt::debugActRunAndHide()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->go();
+ m_machine.debugger().console().get_visible_cpu()->debug()->go();
hideAll();
}
void WindowQt::debugActRunToNextCpu()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->go_next_device();
+ m_machine.debugger().console().get_visible_cpu()->debug()->go_next_device();
}
void WindowQt::debugActRunNextInt()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->go_interrupt();
+ m_machine.debugger().console().get_visible_cpu()->debug()->go_interrupt();
}
void WindowQt::debugActRunNextVBlank()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->go_vblank();
+ m_machine.debugger().console().get_visible_cpu()->debug()->go_vblank();
}
void WindowQt::debugActStepInto()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->single_step();
+ m_machine.debugger().console().get_visible_cpu()->debug()->single_step();
}
void WindowQt::debugActStepOver()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->single_step_over();
+ m_machine.debugger().console().get_visible_cpu()->debug()->single_step_over();
}
void WindowQt::debugActStepOut()
{
- m_machine->debugger().console().get_visible_cpu()->debug()->single_step_out();
+ m_machine.debugger().console().get_visible_cpu()->debug()->single_step_out();
}
void WindowQt::debugActSoftReset()
{
- m_machine->schedule_soft_reset();
- m_machine->debugger().console().get_visible_cpu()->debug()->single_step();
+ m_machine.schedule_soft_reset();
+ m_machine.debugger().console().get_visible_cpu()->debug()->single_step();
}
void WindowQt::debugActHardReset()
{
- m_machine->schedule_hard_reset();
+ m_machine.schedule_hard_reset();
}
void WindowQt::debugActClose()
@@ -237,14 +238,14 @@ void WindowQt::debugActClose()
void WindowQt::debugActQuit()
{
- m_machine->schedule_exit();
+ m_machine.schedule_exit();
}
//=========================================================================
// WindowQtConfig
//=========================================================================
-void WindowQtConfig::buildFromQWidget(QWidget* widget)
+void WindowQtConfig::buildFromQWidget(QWidget *widget)
{
m_position.setX(widget->geometry().topLeft().x());
m_position.setY(widget->geometry().topLeft().y());
@@ -253,7 +254,7 @@ void WindowQtConfig::buildFromQWidget(QWidget* widget)
}
-void WindowQtConfig::applyToQWidget(QWidget* widget)
+void WindowQtConfig::applyToQWidget(QWidget *widget)
{
widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y());
}
diff --git a/src/osd/modules/debugger/qt/windowqt.h b/src/osd/modules/debugger/qt/windowqt.h
index 29debc70bc6..15cbe470f2f 100644
--- a/src/osd/modules/debugger/qt/windowqt.h
+++ b/src/osd/modules/debugger/qt/windowqt.h
@@ -1,13 +1,13 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
-#ifndef __DEBUG_QT_WINDOW_QT_H__
-#define __DEBUG_QT_WINDOW_QT_H__
-
-#include <QtWidgets/QMainWindow>
+#ifndef MAME_DEBUGGER_QT_WINDOWQT_H
+#define MAME_DEBUGGER_QT_WINDOWQT_H
#include "config.h"
#include "debugger.h"
+#include <QtWidgets/QMainWindow>
+
//============================================================
// The Qt window that everyone derives from.
@@ -17,7 +17,7 @@ class WindowQt : public QMainWindow
Q_OBJECT
public:
- WindowQt(running_machine* machine, QWidget* parent=nullptr);
+ WindowQt(running_machine &machine, QWidget *parent = nullptr);
virtual ~WindowQt();
// The interface to an all-window refresh
@@ -51,7 +51,7 @@ protected slots:
protected:
- running_machine* m_machine;
+ running_machine &m_machine;
static bool s_refreshAll;
static bool s_hideAll;
@@ -89,11 +89,11 @@ public:
QPoint m_size;
QPoint m_position;
- virtual void buildFromQWidget(QWidget* widget);
- virtual void applyToQWidget(QWidget* widget);
+ virtual void buildFromQWidget(QWidget *widget);
+ virtual void applyToQWidget(QWidget *widget);
virtual void addToXmlDataNode(util::xml::data_node &node) const;
virtual void recoverFromXmlNode(util::xml::data_node const &node);
};
-#endif
+#endif // MAME_DEBUGGER_QT_WINDOWQT_H