-
-
Notifications
You must be signed in to change notification settings - Fork 419
PICARD-2300: Add qt's stylehints to theme.py for a consistent exp. across platforms #2693
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
PICARD-2300: Add qt's stylehints to theme.py for a consistent exp. across platforms #2693
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks fine to me.
It appears that this will change the choices available for the theme setting on Linux systems. As such, the documentation should be updated -- specifically the "User interface color theme" section on the User Interface Options page. I'll add a sub-task ticket so that this isn't forgotten (see PICARD-3103).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so great! The code looks fine to me overall. Some minor comments, otherwise I'd just like to test this live before merging.
@knguyen1 PR looks good to me, please resolve conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this on Linux on Gnome. Unfortunately the style hint setColorScheme
does not seem to have an effect there. It uses whatever I have set system wide.
That also means the "Light" and "Dark" theme settings in Picard don't have the desired effect.
apply_dark_theme_to_palette
is only run, if the setting is on UiTheme.DEFAULT
. Also apply_dark_theme_to_palette
doesn't change the palette, if style hint support is detected. So setting the style to "Dark" does not run.
On the opposite if the system theme is already dark, but I set the Picard setting to LIGHT
we currently have no way to do this. As the style hint again has no effect, but we also have no logic of explicitly setting a light palette, the app stays dark.
Is anyone currently able to test under a different Linux setup, e.g. Plasma desktop?
UPDATE: QtGui.QGuiApplication.styleHints().colorScheme()
works fine to report the system scheme. When querying this on start it correctly reports Dark or Light, depening on what system theme is set (and the UI appears in this scheme accordingly). But a call to QtGui.QGuiApplication.styleHints().setColorScheme()
has not effect. Even colorScheme()
reports the original value still. On Windows changing the style this way works fine.
I found QTBUG-132929. But it claims to be solved in Qt 6.8, while In was testing with 6.9.1.
a2d2576
to
9288e8f
Compare
bc63e32
to
113bf43
Compare
Failing linting step from the GitHub outage. I filed an issue astral-sh/ruff-action#198 |
@knguyen1 @zas How shall we proceed here? In general I think this is looking good, and we definitely should move forward with the new APIs provides by Qt6. We will have even some potential to further simplify the code in the future with less differences between platforms, I think. But this PR is overall a good starting point. Just my comment above shows that Linux stays complicated. As I wrote it does not work for me on my Gnome setup. I currently don't have my KDE Neon VM available to run, so I haven't checked there. Do you guys have done some better results on Linux? |
@phw It's working for me on I suspect you needed to have apt list --installed | grep -i 'qt5\|qt6'
libqt5core5t64/noble,now 5.15.13+dfsg-1ubuntu1 amd64 [installed,automatic]
libqt5dbus5t64/noble,now 5.15.13+dfsg-1ubuntu1 amd64 [installed,automatic]
...
python3-pyqt5.sip/noble,now 12.13.0-1build3 amd64 [installed,automatic]
python3-pyqt5/noble,now 5.15.10+dfsg-1build6 amd64 [installed,automatic]
qt5-gtk-platformtheme/noble,now 5.15.13+dfsg-1ubuntu1 amd64 [installed,automatic] Install with Maybe file a bug with |
On Linux Mint 22 + Cinnamon, if I switch theme to Light, while having a dark theme, save, restart Picard, it stays on dark theme, no way to force it to Light. So it doesn't look to work for me. I'll do more testing later. Also since it changes option values we need an upgrade hook (I think). |
Can you try after installing |
I have been trying with the PyQt6 / Qt6 from PyPI only. I'm on Ubuntu 24.04, and the Qt6 package provided there is too old (6.4). We have 6.5 defined as minimum, and the Anyway, that might as well be the reason. We had the experience already in the past that the PyPI version did not integrate that well with the platform, while the distribution packages provided a much better experience. On Qt5 e.g. you could install qgnomeplatform for a better integration. Maybe also the Anyway, if it generally works this is already much of an improvement. A lot of Qt6 is still progressing. I'd vote for getting this PR merged and improve as needed. UPDATE: Weirdly it works fine for me today with PyQt6 from PyPI. I'm not aware that anything changed since my last attempt, but theme overrides in Picard work both when I have the light and dark theme configured in Gnome settings. |
No change. Though it seems it sets theme to Light, it doesn't actually switch to light theme.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of suggested changes in knguyen1#1
@knguyen1 sorry, I pushed my changes from my PR accidentally directly to your branch with my latest commit. Please double check, we can undo stuff if it turns out to be a problem. |
There's a leftover in the current branch:
|
Haha, no problem. I'm about to go to the airport for a trip. But will check when possible... |
What about In regard to the PR, I'm of the opinion that if the code on our part is technically correct, it's the qt api's fault and we should file a bug with QTBUG. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the current state in this PR. I'd appreciate some review of my specific changes, but otherwise this did currently work for me and the usage of the APIs as it is makes sense.
I assume the situation on Linux to stay a bit difficult for a while. We already made the experience that the various Qt 6 versions have different issues, and distributions like e.g. Ubuntu 24.04 unfortunately ship older versions. But yes, if we have specific error case we should report it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Added Qt6 style hints support to theme system and made appearance menu consistent across all platforms by enabling DEFAULT, LIGHT, and DARK themes everywhere except Haiku.
Problem
The theme system was inconsistent across platforms - Linux only had DEFAULT and SYSTEM themes while Windows/macOS had DEFAULT, LIGHT, and DARK. Qt6's style hints provide a better way to handle dark themes with automatic fallback to manual color application.
Solution
Added new style hints methods to
BaseTheme
:_get_style_hints()
: Gets QGuiApplication.styleHints()_set_color_scheme()
: Sets color scheme using style hints_apply_dark_palette_colors()
: Manual dark color application_apply_dark_theme_to_palette()
: Uses Qt color scheme or manual fallbackUpdated
AVAILABLE_UI_THEMES
to include DEFAULT, LIGHT, and DARK on all platforms except Haiku, making the appearance menu consistent.Enhanced setup logic to use Qt's built-in color scheme when available, with automatic fallback to manual color application.
Action
Additional actions required: