Debugger: Respond to OS colour scheme changes
Some checks are pending
🐧 Linux Builds / AppImage (push) Waiting to run
🐧 Linux Builds / Flatpak (push) Waiting to run
🍎 MacOS Builds / Defaults (push) Waiting to run
🖥️ Windows Builds / Lint VS Project Files (push) Waiting to run
🖥️ Windows Builds / SSE4 (push) Blocked by required conditions
🖥️ Windows Builds / AVX2 (push) Blocked by required conditions
🖥️ Windows Builds / CMake (push) Waiting to run

This commit is contained in:
chaoticgd 2025-10-23 00:58:47 +01:00 committed by Ty
parent 7db487a49b
commit cac6669423
3 changed files with 18 additions and 4 deletions

View File

@ -238,6 +238,12 @@ int DebuggerWindow::fontSize()
void DebuggerWindow::updateTheme()
{
// Detect recursive StyleChange events caused by updating the stylesheet.
if (m_is_updating_theme)
return;
m_is_updating_theme = true;
// TODO: Migrate away from stylesheets to improve performance.
setStyleSheet(QString("font-size: %1pt;").arg(m_font_size));
@ -248,6 +254,8 @@ void DebuggerWindow::updateTheme()
setStyleSheet(QString());
dockManager().updateTheme();
m_is_updating_theme = false;
}
void DebuggerWindow::saveWindowGeometry()
@ -535,6 +543,12 @@ void DebuggerWindow::onStepOut()
this->repaint();
}
void DebuggerWindow::changeEvent(QEvent* event)
{
if (event->type() == QEvent::PaletteChange || event->type() == QEvent::StyleChange)
updateTheme();
}
void DebuggerWindow::closeEvent(QCloseEvent* event)
{
dockManager().saveCurrentLayout();

View File

@ -60,7 +60,8 @@ Q_SIGNALS:
void onVMActuallyPaused();
protected:
void closeEvent(QCloseEvent* event);
void changeEvent(QEvent* event) override;
void closeEvent(QCloseEvent* event) override;
private:
DebugInterface* currentCPU();
@ -75,6 +76,8 @@ private:
int m_font_size;
static const constexpr int MINIMUM_FONT_SIZE = 5;
static const constexpr int MAXIMUM_FONT_SIZE = 30;
bool m_is_updating_theme = false;
};
extern DebuggerWindow* g_debugger_window;

View File

@ -1796,9 +1796,6 @@ void MainWindow::updateTheme()
{
QtHost::UpdateApplicationTheme();
reloadThemeSpecificImages();
if (g_debugger_window)
g_debugger_window->updateTheme();
}
void MainWindow::reloadThemeSpecificImages()