-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Revamp Preferences, implement Minimalist Mode and Qt widget gallery to test GUI changes #2289
Conversation
Your branch doesn't build for me. The dialog looks handy though.
When it comes to changing the theme, my idea is that the selector in "Tools" > "Preferences" could allow the user to choose between not only "system", "dark" and "light", but also other presets. Also, system currently doesn't do anything so I'd like to fix that. |
@tatsumoto-ren Matthias has not changed anything that would cause that error. It seems the error is caused by a recent change to git's behaviour. From the repo root, if you run |
@kleinerpirat I get an error on startup, and had to run the following first:
If those three options are mutually exclusive, I think we should probably be storing them in a single key instead of three separate booleans, eg meta.get("widget_style") would return "anki" | "fusion" | "native" or 0 | 1 | 2. Rest of the PR looks good; I can see how this would be helpful for debugging styling issues moving forward. |
Yeah, I think a single key will be the more elegant implementation, although it's less intuitive to the user. |
@dae thanks for the tip. After running the second command, i was able to build successfully. The For testing it would be handy if the table widget had a few rows with some text in them. Earlier I ran into a problem with text being unreadable when using a custom table widget in 2.1.55. Since Anki doesn't pick up my GTK theme currently, I don't see much difference between "fusion" and "native". When testing custom Qtwidgets, I'd really like this menu to appear globally under "tools" > "preferences" too. I'm sure addon devs would agree. |
The choices change based on platform. On Mac, "Anki" is mostly native widgets, with "Fusion" being the less-native styling that was used in dark mode in old releases, and I presume we don't need a separate native option. System Qt themes are not a concern on Windows either, so presumably we'd only need 2 options - or even just 1? The push for access to the old fusion theme seems to have come from macOS users IIRC, so perhaps we don't even need a setting on Windows? @kleinerpirat would it make sense to expose this as a dropdown in the prefs screen, with 2 options on Mac, 3 on Linux, and either hide it on Windows, or have 2 options? That removes any confusion about manually changing enum settings. I'd originally hoped to keep the macOS fusion option hidden in the debug console, but AnKing went and promoted it to his followers, so any hope of keeping that obscure rapidly went out the door :-) |
A little update on what I'm working on: The Preferences screen will be revamped a bit. I intend to make more use of
|
Thanks for working on this. I think we'll probably want to include the UI language there too, and move that page to the first tab. |
and make former large radius a bit smaller.
Also: - create additional and missing widget styles and tweak existing ones - use single profile entry to set widget styles and reduce choices to Anki and Native
UpdateStyles
PreferencesThe preferences are reordered quite a bit now.
Minimalist ModeThis mode removes the body class .sample-element {
// common definitions
padding: 1rem;
font-weight: bold;
.fancy & {
// extra definitions omitted in minimalist mode
border-radius: var(--border-radius-medium);
filter: drop-shadow(0 0 0.75rem var(--border-focus));
}
} The mode also unsets |
qt/aqt/main.py
Outdated
@@ -1068,9 +1068,9 @@ def setupStyle(self) -> None: | |||
if is_lin: | |||
# On Linux, the check requires invoking an external binary, | |||
# which we don't want to be doing frequently | |||
interval_secs = 300 | |||
interval_secs = 10 |
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.
300s seemed overkill. I don't know how much of a performance impact invoking the external binary has, but I didn't notice anything when I set it to 2
on my Gnome system. 5
or 10
would also suffice to achieve a relatively smooth transition between system themes.
Automatic theme adjustments are a very nice thing to have, especially if you switch themes regularly via shortcut or with a sunset timer.
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.
Yes, I was probably a little too conservative there :-) They appear to take a few ms at most, so once every 5-10s isn't going to contribute much to global warming/exhaust user's batteries.
Unfortunately the Preferences screen crashes when using Shift+Tab to focus the previous widget. This does not happen in the widget gallery, so I'm positive it can be resolved with some testing. |
It looks like the shift+tab issue exists in the main branch as well, so that doesn't seem to be your fault. Wierd! The preferences screen looks cleaner - those groups do help with things. I do find it a bit strange to have a Reviewer section in Appearance and then a separate Review section in Basic. One idea would be to move the review and scheduler things into a single Review tab, and rename Basic to Editing, with browsing and import/export covered under that tab. WDYT? Regarding the minimal mode, I don't have personal preferences here, so we'll need to see how people react to it. Some possible objections they might raise are that buttons don't have outlines anymore, and that there's no border at the top. @tatsumoto-ren any feedback at this stage? |
I've pushed a fix for the conflicts; will try to return to this later today. |
Well, that was fun. Qt is being really weird here - it seems like
|
Screen.Recording.2023-01-18.at.5.16.18.pm.mov |
So, the question is how to resolve it. The following seems to work for me: diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py
index 9979d70b9..ca8c36c4d 100644
--- a/qt/aqt/theme.py
+++ b/qt/aqt/theme.py
@@ -61,6 +61,7 @@ class ThemeManager:
_icon_size = 128
_dark_mode_available: bool | None = None
_default_style: str | None = None
+ _current_widget_style: AnkiStyles | None = None
def rtl(self) -> bool:
return is_rtl(anki.lang.current_lang)
@@ -218,16 +219,19 @@ class ThemeManager:
return get_linux_dark_mode()
def apply_style_if_system_style_changed(self) -> None:
- theme = aqt.mw.pm.theme()
- if theme != Theme.FOLLOW_SYSTEM:
- return
- if self._determine_night_mode() != self.night_mode:
- self.apply_style()
+ self.apply_style()
def apply_style(self) -> None:
"Apply currently configured style."
app = aqt.mw.app
- self.night_mode = self._determine_night_mode()
+ new_theme = self._determine_night_mode()
+ theme_changed = self.night_mode != new_theme
+ new_style = aqt.mw.pm.get_widget_style()
+ style_changed = self._current_widget_style != new_style
+ if not theme_changed and not style_changed:
+ return
+ self.night_mode = new_theme
+ self._current_widget_style = new_style
if not self._default_style:
self._default_style = app.style().objectName()
self._apply_palette(app) Do you think that would work? Apologies if it seems like an obvious question; I fear I haven't yet fully understood all the issues you're trying to deal with here. Incidentally, I think we could improve on the naming - "style" and "theme" are easily confused. How about something like AnkiStyles->WidgetStyle? |
Do you mean the whole PR? I apologize for my poor documentation. If you want, I can create a comprehensive list of changes.
Sounds good. |
I think I'm ok with the outline of everything, it's just the specific handling of follow_system vs light/dark mode that I don't seem to have fully understood yet. Would the patch I posted above cause problems? If not, would you like me to make that change or would you like to? |
I already did the writeup, so I'll post it anyway: Qt Widget GalleryAdded a button in the debug console to open a dialog filled with all important Qt Widgets. It can be expanded in the future and could do with sample items in New Preferences Layout
Widget Style SettingIntroduced a dropdown to choose the Qt widget style applied to the app.
Minimalist ModeWhen toggled on, this mode regresses the webviews to a style similar to < 2.1.54. Properties that should not be used in this mode:
Toolbar Changes
Miscellaneous
|
I'm getting an error on ./run after 0d945cf:
Edit: to be more precise, it seems to be caused by cf45cbf. |
The write-up will come in handy when writing a summary for the beta anyway :-) Hmm, that error is strange - https://crates.io/crates/async-compression is available on crates.io. What does 'cargo --version' print? |
It prints |
Presumably it prints 1.65 if you run it inside Anki's source folder? Presumably Cargo.lock hasn't been modified since checking out the latest commit? If you remove out/ and build again, does that make a difference? If not, how about if you remove ~/.cargo/registry/index? |
Deleting out/ and build didn't fix the issue, but removing Prior to the error, something had gone wrong on a build due to low system storage space. Perhaps that caused this glitch in the matrix. Thanks for the help! |
Co-Authored-By: Damien Elmes <dae@users.noreply.github.com>
I applied your changes and it seems to work well. Regarding the Qt5 text issue: It seems a bit random, because I got different issues than you. Dark theme displays fine, but Light looks like this: It seems to be isolated to the Distractions group in the preferences, so it's likely just a dirty |
that caused an error when opening the widget gallery on Qt5.
Now I can't reproduce it anymore 👀 |
to prevent error in Qt5. Credit: https://stackoverflow.com/a/65425151
This is looking in pretty good shape now on Mac/Linux. Are you happy for me to merge it, or was there anything you wanted to do first? A couple of points that will need addressing, but can be done in a follow-up PR:
|
also exclude native option from dropdown just in case.
I hid it now. We might get requests from Windows users who'd like to set Anki to Fusion, though. I guess we'll have to see. For now I'd be very happy if you could merge this in. |
This adds a gallery similar to this one to the debug dialog.
It allows users to change the styling approach across the application via a dropdown and see the effects immediately on various Qt widgets.
There are three choices:
If the "Force Style" box is checked, the style will be kept across profiles.
@tatsumoto-ren I don't know how much of the GTK theme Anki should pick up. Please tell me if the "Native/Fusion" options are working for you. The UI looks the same as on 2.1.49 for me. Missing styles for the "Anki" option will be added in future PRs.