Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toggle night mode in clayout #1251

Merged
merged 4 commits into from Jun 24, 2021
Merged

Conversation

hikaru-y
Copy link
Contributor

Fixes #1166.

Regarding emulation of day mode (especially on non-Linux platforms):

Taking into account the possibility that the background color is not set in the .card styling, I think we need to set the background color of the <body> element to the QPalette.Window color value of the system default palette in order to emulate it correctly. However, on Windows (and probably on macOS as well), once the fusion QStyle is applied to enable night mode, the palette retrieved by standardPalette() will be different from that in day mode.

On Windows:

QPalette_Window_day_mode
QPalette_Window_night_mode

This is probably because the default QStyle on Windows and macOS is not fusion. So in this PR, the system default palette is stored in theme_manager.default_palette before the fusion style is applied, so that the QPalette.Window color value in day mode can be used in night mode on any platform.

Once a QStyle different from the system default is applied, the system default palette can no longer be retrieved with standardPalette().
including the following changes:
- rename "_getWindowColor" to "get_window_bg_color" to follow PEP8
- add "night_mode" argument to "get_window_bg_color"
- make it possible to get the correct colors regardless of the current theme
required to emulate day mode in clayout
if background-color is not set in .card styling
@dae
Copy link
Member

dae commented Jun 24, 2021

Sounds like a good approach - thanks Hikaru!

@dae dae merged commit 99375fd into ankitects:main Jun 24, 2021
@hikaru-y hikaru-y deleted the fix-toggle-night-mode branch March 25, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants