Skip to content

Commit cac6669

Browse files
chaoticgdF0bes
authored andcommitted
Debugger: Respond to OS colour scheme changes
1 parent 7db487a commit cac6669

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

pcsx2-qt/Debugger/DebuggerWindow.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ int DebuggerWindow::fontSize()
238238

239239
void DebuggerWindow::updateTheme()
240240
{
241+
// Detect recursive StyleChange events caused by updating the stylesheet.
242+
if (m_is_updating_theme)
243+
return;
244+
245+
m_is_updating_theme = true;
246+
241247
// TODO: Migrate away from stylesheets to improve performance.
242248
setStyleSheet(QString("font-size: %1pt;").arg(m_font_size));
243249

@@ -248,6 +254,8 @@ void DebuggerWindow::updateTheme()
248254
setStyleSheet(QString());
249255

250256
dockManager().updateTheme();
257+
258+
m_is_updating_theme = false;
251259
}
252260

253261
void DebuggerWindow::saveWindowGeometry()
@@ -535,6 +543,12 @@ void DebuggerWindow::onStepOut()
535543
this->repaint();
536544
}
537545

546+
void DebuggerWindow::changeEvent(QEvent* event)
547+
{
548+
if (event->type() == QEvent::PaletteChange || event->type() == QEvent::StyleChange)
549+
updateTheme();
550+
}
551+
538552
void DebuggerWindow::closeEvent(QCloseEvent* event)
539553
{
540554
dockManager().saveCurrentLayout();

pcsx2-qt/Debugger/DebuggerWindow.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public slots:
6060
void onVMActuallyPaused();
6161

6262
protected:
63-
void closeEvent(QCloseEvent* event);
63+
void changeEvent(QEvent* event) override;
64+
void closeEvent(QCloseEvent* event) override;
6465

6566
private:
6667
DebugInterface* currentCPU();
@@ -75,6 +76,8 @@ public slots:
7576
int m_font_size;
7677
static const constexpr int MINIMUM_FONT_SIZE = 5;
7778
static const constexpr int MAXIMUM_FONT_SIZE = 30;
79+
80+
bool m_is_updating_theme = false;
7881
};
7982

8083
extern DebuggerWindow* g_debugger_window;

pcsx2-qt/MainWindow.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,9 +1796,6 @@ void MainWindow::updateTheme()
17961796
{
17971797
QtHost::UpdateApplicationTheme();
17981798
reloadThemeSpecificImages();
1799-
1800-
if (g_debugger_window)
1801-
g_debugger_window->updateTheme();
18021799
}
18031800

18041801
void MainWindow::reloadThemeSpecificImages()

0 commit comments

Comments
 (0)