Another year, another version of macOS is out breaking our Qt. The most significant change this year is the addition of dark mode and accent colors in Qt. A great share of this can be fixed in the system palette.
Accent color changes are notified through NSSystemColorsDidChangeNotification which we are already plugged into in QCocoaTheme for changes in selection color. However, as we will see, the current logic is not enough for getting the proper palette colors.
Dark/light mode changes are not directly notified to the application. It is possible to do KVO on NSApp.effectiveAppearance but reading the proper color values can only be done in specific places. This is (probably) because each NSView can have its appearance set independently.
The AppKit page on dark mode support specifies that the correct NSColor values can only be read from the following NSView methods:
Which means that any palette update must be done while the methods above are being called. This is quite different from what we had in the past with NSSystemColorsDidChangeNotification and introduces a coupling between QNSView and QCocoaTheme.
There are also issues within QMacStyle. Most notably, the native controls we render on the backing store retain their previous appearance even after the system appearance has switched. This is not related to control caching, as disabling it doesn't give the expected results.
Another issue in QMacStyle is that NSBox, which we use to render frames such as in QTabView or QFrame, doesn't draw anymore.