Skip to content

Commit

Permalink
Debugger: Fix an issue where the debugger is always on top of the mai…
Browse files Browse the repository at this point in the history
…n window

Add an optional "always on top" toolbar button as well
  • Loading branch information
F0bes authored and refractionpcsx2 committed Oct 13, 2023
1 parent 56ec842 commit 6e5fbe8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pcsx2-qt/Debugger/DebuggerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ DebuggerWindow::DebuggerWindow(QWidget* parent)
connect(m_ui.actionStepInto, &QAction::triggered, this, &DebuggerWindow::onStepInto);
connect(m_ui.actionStepOver, &QAction::triggered, this, &DebuggerWindow::onStepOver);
connect(m_ui.actionStepOut, &QAction::triggered, this, &DebuggerWindow::onStepOut);
connect(m_ui.actionOnTop, &QAction::triggered, [this] { this->setWindowFlags(this->windowFlags() ^ Qt::WindowStaysOnTopHint); this->show(); });

connect(g_emu_thread, &EmuThread::onVMPaused, this, &DebuggerWindow::onVMStateChanged);
connect(g_emu_thread, &EmuThread::onVMResumed, this, &DebuggerWindow::onVMStateChanged);

onVMStateChanged(); // If we missed a state change while we weren't loaded

// We can't do this in the designer, but we want to right align the actionOnTop action in the toolbar
QWidget* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_ui.toolBar->insertWidget(m_ui.actionOnTop, spacer);

m_cpuWidget_r5900 = new CpuWidget(this, r5900Debug);
m_cpuWidget_r3000 = new CpuWidget(this, r3000Debug);
Expand Down
17 changes: 17 additions & 0 deletions pcsx2-qt/Debugger/DebuggerWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<property name="windowTitle">
<string>PCSX2 Debugger</string>
</property>
<property name="windowIcon">
<iconset>
<normalon>:/icons/AppIcon64.png</normalon>
</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
Expand Down Expand Up @@ -46,6 +51,7 @@
<addaction name="actionStepInto"/>
<addaction name="actionStepOver"/>
<addaction name="actionStepOut"/>
<addaction name="actionOnTop"/>
</widget>
<action name="actionRun">
<property name="icon">
Expand Down Expand Up @@ -88,6 +94,17 @@
<string>Shift+F11</string>
</property>
</action>
<action name="actionOnTop">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Always On Top</string>
</property>
<property name="toolTip">
<string>Show this window on top</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
10 changes: 9 additions & 1 deletion pcsx2-qt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ MainWindow::~MainWindow()
// make sure the game list isn't refreshing, because it's on a separate thread
cancelGameListRefresh();

if (m_debugger_window)
{
m_debugger_window->close();
m_debugger_window->deleteLater();
m_debugger_window = nullptr;
}

// we compare here, since recreate destroys the window later
if (g_main_window == this)
g_main_window = nullptr;
Expand Down Expand Up @@ -2300,7 +2307,8 @@ void MainWindow::doSettings(const char* category /* = nullptr */)
DebuggerWindow* MainWindow::getDebuggerWindow()
{
if (!m_debugger_window)
m_debugger_window = new DebuggerWindow(this);
// Don't pass us (this) as the parent, otherwise the window is always on top of the mainwindow (on windows at least)
m_debugger_window = new DebuggerWindow(nullptr);

return m_debugger_window;
}
Expand Down

0 comments on commit 6e5fbe8

Please sign in to comment.