Skip to content

Commit

Permalink
Debugger: Add support for multiple UI layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticgd committed Feb 6, 2025
1 parent 0081422 commit 4d311a0
Show file tree
Hide file tree
Showing 34 changed files with 2,024 additions and 235 deletions.
17 changes: 15 additions & 2 deletions pcsx2-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ target_sources(pcsx2-qt PRIVATE
Debugger/DisassemblyWidget.cpp
Debugger/DisassemblyWidget.h
Debugger/DisassemblyWidget.ui
Debugger/DockManager.cpp
Debugger/DockManager.h
Debugger/JsonValueWrapper.h
Debugger/RegisterWidget.cpp
Debugger/RegisterWidget.h
Debugger/RegisterWidget.ui
Expand All @@ -189,6 +188,20 @@ target_sources(pcsx2-qt PRIVATE
Debugger/Breakpoints/BreakpointWidget.cpp
Debugger/Breakpoints/BreakpointWidget.h
Debugger/Breakpoints/BreakpointWidget.ui
Debugger/Docking/DockLayout.cpp
Debugger/Docking/DockLayout.h
Debugger/Docking/DockManager.cpp
Debugger/Docking/DockManager.h
Debugger/Docking/DockTables.cpp
Debugger/Docking/DockTables.h
Debugger/Docking/DockViews.cpp
Debugger/Docking/DockViews.h
Debugger/Docking/LayoutEditorDialog.cpp
Debugger/Docking/LayoutEditorDialog.h
Debugger/Docking/LayoutEditorDialog.ui
Debugger/Docking/NoLayoutsWidget.cpp
Debugger/Docking/NoLayoutsWidget.h
Debugger/Docking/NoLayoutsWidget.ui
Debugger/Memory/MemorySearchWidget.cpp
Debugger/Memory/MemorySearchWidget.h
Debugger/Memory/MemorySearchWidget.ui
Expand Down
65 changes: 59 additions & 6 deletions pcsx2-qt/Debugger/DebuggerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,65 @@

#include "DebuggerWidget.h"

#include "JsonValueWrapper.h"

#include "DebugTools/DebugInterface.h"

#include "common/Assertions.h"

DebuggerWidget::DebuggerWidget(DebugInterface* cpu, QWidget* parent)
: QWidget(parent)
, m_cpu(cpu)
DebugInterface& DebuggerWidget::cpu() const
{
if (m_cpu_override.has_value())
return DebugInterface::get(*m_cpu_override);

pxAssertRel(m_cpu, "DebuggerWidget::cpu called on object with null cpu.");
return *m_cpu;
}

DebugInterface& DebuggerWidget::cpu() const
bool DebuggerWidget::setCpu(DebugInterface& new_cpu)
{
BreakPointCpu before = cpu().getCpuType();
m_cpu = &new_cpu;
BreakPointCpu after = cpu().getCpuType();
return before == after;
}

std::optional<BreakPointCpu> DebuggerWidget::cpuOverride() const
{
return m_cpu_override;
}

bool DebuggerWidget::setCpuOverride(std::optional<BreakPointCpu> new_cpu)
{
BreakPointCpu before = cpu().getCpuType();
m_cpu_override = new_cpu;
BreakPointCpu after = cpu().getCpuType();
return before == after;
}

void DebuggerWidget::toJson(JsonValueWrapper& json)
{
rapidjson::Value cpu_name;
if (m_cpu_override)
{
switch (*m_cpu_override)
{
case BREAKPOINT_EE:
cpu_name.SetString("EE");
break;
case BREAKPOINT_IOP:
cpu_name.SetString("IOP");
break;
default:
return;
}
}

json.value().AddMember("target", cpu_name, json.allocator());
}

void DebuggerWidget::fromJson(JsonValueWrapper& json)
{
pxAssertRel(m_cpu, "DebuggerWidget::cpu() called on object that doesn't have a CPU type set.");
return *m_cpu;
}

void DebuggerWidget::applyMonospaceFont()
Expand All @@ -29,3 +76,9 @@ void DebuggerWidget::applyMonospaceFont()
setStyleSheet(QStringLiteral("font: 10pt 'Monospace'"));
#endif
}

DebuggerWidget::DebuggerWidget(DebugInterface* cpu, QWidget* parent)
: QWidget(parent)
, m_cpu(cpu)
{
}
28 changes: 25 additions & 3 deletions pcsx2-qt/Debugger/DebuggerWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,39 @@ inline void not_yet_implemented()
abort();
}

class JsonValueWrapper;

// The base class for the contents of the dock widgets in the debugger.
class DebuggerWidget : public QWidget
{
Q_OBJECT

protected:
DebuggerWidget(DebugInterface* cpu, QWidget* parent = nullptr);

public:
// Get the effective debug interface associated with this particular widget
// if it's set, otherwise return the one associated with the layout that
// contains this widget.
DebugInterface& cpu() const;

// Set the debug interface associated with the layout. If false is returned,
// we have to recreate the object.
bool setCpu(DebugInterface& new_cpu);

// Get the CPU associated with this particular widget.
std::optional<BreakPointCpu> cpuOverride() const;

// Set the CPU associated with the individual dock widget. If false is
// returned, we have to recreate the object.
bool setCpuOverride(std::optional<BreakPointCpu> new_cpu);

virtual void toJson(JsonValueWrapper& json);
virtual void fromJson(JsonValueWrapper& json);

void applyMonospaceFont();

protected:
DebuggerWidget(DebugInterface* cpu, QWidget* parent = nullptr);

private:
DebugInterface* m_cpu;
std::optional<BreakPointCpu> m_cpu_override;
};
8 changes: 8 additions & 0 deletions pcsx2-qt/Debugger/DebuggerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ DebuggerWindow::DebuggerWindow(QWidget* parent)
//QTabBar* tabs = new QTabBar();
//tabs->addTab("Test");
//m_ui.menuBar->layout()->addWidget(tabs);

QMenuBar* menu_bar = menuBar();

setMenuWidget(m_dock_manager.createLayoutSwitcher(menu_bar));

connect(m_ui.menuWindows, &QMenu::aboutToShow, this, [this]() {
m_dock_manager.createWindowsMenu(m_ui.menuWindows);
});
}

DebuggerWindow::~DebuggerWindow() = default;
Expand Down
2 changes: 1 addition & 1 deletion pcsx2-qt/Debugger/DebuggerWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "ui_DebuggerWindow.h"

#include "DockManager.h"
#include "Docking/DockManager.h"

#include <kddockwidgets/MainWindow.h>

Expand Down
6 changes: 0 additions & 6 deletions pcsx2-qt/Debugger/DebuggerWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@
<string>Windows</string>
</property>
</widget>
<widget class="QMenu" name="menuLayouts">
<property name="title">
<string>Layouts</string>
</property>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
Expand All @@ -92,7 +87,6 @@
<addaction name="menuView"/>
<addaction name="menuDebug"/>
<addaction name="menuWindows"/>
<addaction name="menuLayouts"/>
</widget>
<widget class="QToolBar" name="viewToolBar">
<property name="windowTitle">
Expand Down
108 changes: 0 additions & 108 deletions pcsx2-qt/Debugger/DockManager.cpp

This file was deleted.

42 changes: 0 additions & 42 deletions pcsx2-qt/Debugger/DockManager.h

This file was deleted.

Loading

0 comments on commit 4d311a0

Please sign in to comment.