Skip to content

Conversation

@chaoticgd
Copy link
Member

@chaoticgd chaoticgd commented Oct 12, 2025

Description of Changes

Sets the colorScheme property of the qApp->styleHint() object whenever the theme is changed.

We're still using a palette heuristic to figure out if it's a light or dark theme since in some cases qApp->styleHints()->colourScheme() will return the wrong result (I've added comments explaining this in more detail).

This also removes some custom logic for detecting theme changes on macOS because it was conflicting with Qt's platform code (which now handles this automatically) which was causing an infinite loop.

Rationale behind Changes

This lets Qt know that we're using a light or dark theme, which will allow it to do a better job at drawing certain widgets. For example before checkboxes looked like this (with a dark OS theme set):

Screenshot_20251012_202908

After these changes they look like this:

Screenshot_20251012_212331

Suggested Testing Steps

Test on Windows and macOS with the native themes. Try changing between light and dark themes in the settings window, and try changing between light, dark and high contrast themes in the OS.

Did you use AI to help find, test, or implement this issue or feature?

No.

@chaoticgd chaoticgd changed the title Qt: Set QStyleHint colourScheme property properly Qt: Set QStyleHint colorScheme property properly Oct 12, 2025
@chaoticgd chaoticgd force-pushed the colour_scheme branch 2 times, most recently from f33b9bc to 49ee550 Compare October 12, 2025 20:32
@chaoticgd chaoticgd changed the title Qt: Set QStyleHint colorScheme property properly Qt: Set QStyleHints colorScheme property properly Oct 12, 2025
@chaoticgd
Copy link
Member Author

Oh, macOS is still on an old Qt version.

@chaoticgd
Copy link
Member Author

chaoticgd commented Oct 13, 2025

I could add a fallback, but there's been some talk of updating the version of Qt used on macOS, so I'll just leave it for now until some other members of the team decide what to do.

@chaoticgd chaoticgd force-pushed the colour_scheme branch 3 times, most recently from cca43a5 to f792dd3 Compare October 13, 2025 21:42
@chaoticgd
Copy link
Member Author

Added the fallback.

Copy link
Contributor

@kamfretoz kamfretoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on Arch Linux KDE

Image

@JordanTheToaster
Copy link
Member

Appears to make the icons in Classic Windows and Native theme under Windows 10 washed out.

image

@chaoticgd
Copy link
Member Author

chaoticgd commented Oct 15, 2025

Appears to make the icons in Classic Windows and Native theme under Windows 10 washed out.

This should be fixed now. It appears the problem was that some styles (e.g. the Windows Classic/Windows Vista style) just don't obey the new colorScheme property (but it's still reported to the application), so I've used the old palette heuristic to set said property in those cases. I don't love this, but since it's the same as the old behaviour it shouldn't make it worse at least.

@chaoticgd chaoticgd marked this pull request as draft October 18, 2025 02:40
@chaoticgd chaoticgd marked this pull request as ready for review October 18, 2025 17:54
@chaoticgd
Copy link
Member Author

Removed the fallback again now that macOS has been updated. Needs testing again.

Copy link
Member

@JordanTheToaster JordanTheToaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good PR.

Image

Copy link
Contributor

@kamfretoz kamfretoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tasty.
image

Copy link
Contributor

@TheTechnician27 TheTechnician27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ✅ Palette based on whether the window text value is lighter or darker than the window value for the "fusion" theme seems more sensible than an arbitrary 0.5 text value cutoff.
  • ✅ Changes to QtUtils besides that are just a formatting fix and adding a comment for another unrelated option.
  • Color scheme property introduced in Qt 6.5 seems a lot better than trying to roll our own.
  • ✅ Tested, and it fixes the outlines for me like it does for everyone else.
  • ✅ Without an extensive read of the QStyleHints docs, I can't immediately think of a way this can be improved.

Aside: on line 202 of DropIndicators.cpp, it looks like a tab somehow got replaced in this PR with a bunch of spaces by accident.

@chaoticgd
Copy link
Member Author

chaoticgd commented Oct 20, 2025

Looks like this PR has a regression where certain on platforms (e.g. macOS) it breaks live switching of OS themes. I'm unable to reproduce this as I think I don't have access to any environments where this feature worked properly previously.

So it looks like this will be blocked until someone else can get to the bottom of this.

Some wild ideas are:

  • Calling styleHints()->unsetColorScheme.
  • Moving where styleHints()->setColorScheme is called.
  • Respond to the QStyleHints::colorSchemeChanged signal.

@chaoticgd
Copy link
Member Author

chaoticgd commented Oct 20, 2025

I think the problem might be that I'm explicitly settings the colorScheme property rather than unsetting it for the native themes. But I remember that unsetting it makes it return wrong results in some cases, so then it can't be used directly (and Qt uses it directly internally...).

@chaoticgd
Copy link
Member Author

Alright, I've changed how this works: Now I'm only setting the colorScheme property (including to Unknown where that makes sense, rather than Light or Dark), and not reading it, since if it's set to Unknown qApp->styleHints()->colorScheme() can return the wrong value (e.g. in the case of the Windows Classic theme), and if I never set it to Unknown (as I was doing before) we never get notified of OS colour scheme changes.

@chaoticgd chaoticgd force-pushed the colour_scheme branch 2 times, most recently from b2854b4 to b667326 Compare October 20, 2025 19:55
@chaoticgd
Copy link
Member Author

Needs testing again. Sorry about that.

@chaoticgd chaoticgd force-pushed the colour_scheme branch 2 times, most recently from b764e59 to 9a48b63 Compare October 20, 2025 20:06
Copy link
Contributor

@SternXD SternXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dark/light mode switching works again after latest force push

Image

I will say there is this error in System Console when you do switch them I don't think it's a blocker that's why I'm approving should probably be something to fix though eventually.

@TheTechnician27
Copy link
Contributor

image image image image

Lookin' good, Susan.

Copy link
Member

@F0bes F0bes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for documentation sake, and so I remember..... I found that this conflicts with the cocoa theme change code and causes a feedback effect. Just waiting for this PR to remove that code.

@chaoticgd
Copy link
Member Author

Removed the custom macOS theme changing code. Thanks for spotting that!

Copy link
Member

@F0bes F0bes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine on macOS.

@F0bes F0bes merged commit aedc51e into PCSX2:master Oct 24, 2025
12 checks passed
@chaoticgd chaoticgd deleted the colour_scheme branch October 24, 2025 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants