Debugger: Destroy and re-create the debugger on theme change

This commit is contained in:
Ty Lamontagne 2024-10-06 15:01:58 -04:00 committed by Ty
parent bba85dc08f
commit 924326460c
1 changed files with 28 additions and 0 deletions

View File

@ -1723,8 +1723,36 @@ void MainWindow::onCreateMemoryCardOpenRequested()
void MainWindow::updateTheme()
{
// The debugger hates theme changes.
// We have unfortunately to destroy it and recreate it.
const bool debugger_is_open = m_debugger_window ? m_debugger_window->isVisible() : false;
const QSize debugger_size = m_debugger_window ? m_debugger_window->size() : QSize();
const QPoint debugger_pos = m_debugger_window ? m_debugger_window->pos() : QPoint();
if (m_debugger_window)
{
if (QMessageBox::question(this, tr("Theme Change"),
tr("Changing the theme will close the debugger window. Any unsaved data will be lost. Do you want to continue?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
{
return;
}
}
QtHost::UpdateApplicationTheme();
reloadThemeSpecificImages();
if (m_debugger_window)
{
m_debugger_window->deleteLater();
m_debugger_window = nullptr;
getDebuggerWindow(); // populates m_debugger_window
m_debugger_window->resize(debugger_size);
m_debugger_window->move(debugger_pos);
if (debugger_is_open)
{
m_debugger_window->show();
}
}
}
void MainWindow::reloadThemeSpecificImages()