-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Decouple changing viewer.theme from changing theme settings/preferences #5143
Decouple changing viewer.theme from changing theme settings/preferences #5143
Conversation
Click here to download the docs artifacts |
Click here to download the docs artifacts |
Codecov Report
@@ Coverage Diff @@
## main #5143 +/- ##
==========================================
+ Coverage 89.08% 89.10% +0.02%
==========================================
Files 595 596 +1
Lines 50579 50639 +60
==========================================
+ Hits 45058 45123 +65
+ Misses 5521 5516 -5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This PR also addresses the fact that if you use multiple viewers, then changing the theme of one changes them all. Try:
(or from the napari console just the last 2 lines) Edit: let me expand on this: |
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.
Seems good. I wonder if it would be a good idea to use a notification pop-up to indicate what theme is the newly selected?
You mean beyond the visual? Also, in which case? I assume, the keybind toggle? |
Yup to all the questions :) I agree that it might be premature, I mostly thought about it as a way to get around you issue above (I don't love skipping the system theme altogether and forcing people to go in the settings for that "special" case). |
Lines 167 to 174 in 1404af7
It's not actually a different theme. So if you want to toggle between one or the other (or other themes you install) then hitting system is annoying because it frequently does nothing. Edit: extra clarification: with this PR the toggle keybind only changes the theme of the current viewer, the user can always use settings to change to |
Ok; I don't feel strongly about this, so I'll let you and others decide :) |
Click here to download the docs artifacts |
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Click here to download the docs artifacts |
It is a good idea for me. |
ff6ef55
to
59920f8
Compare
I think I messed up the reverting (because of the previous merge?) but I've managed to force things to be before the View menu additions. |
I think removing the menu addition from this one is a good move @psobolewskiPhD. I will review asap, but probably not until tomorrow so if others have already approved, go for the merge. I'll also take a look at adding the menu item, I think it'll be a small change, but just haven't had a chance to play with it yet. |
FYI here's the blending/canvas docs PR: napari/docs#69 |
8cae6a1
to
c19ed4e
Compare
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.
Pulled this down locally and confirmed it all works as expected. Had a quick look at the code and nothing seems out of the ordinary so let's get this in 🎉
* main: Bugfix: Ensure layer._fixed_vertex is set when rotating (napari#5449) Bugfix: Fix test_get_system_theme test for `name` to `id` change (napari#5456) Add correct `enablement` kwarg to `Split Stack` action, `Convert data type` submenu and `Projections` submenu (napari#5437) Add error color to themes and change application close/exit dialogs (napari#5442) Add auto canceling previous test after a new PR commit (napari#5453) Fix theme id reference to get image for 'success_label' style (napari#5447) Decouple changing viewer.theme from changing theme settings/preferences (napari#5143) [pre-commit.ci] pre-commit autoupdate (napari#5422) Configure `fail_on_no_env` for `tox-gh-actions` (napari#5408)
…es (napari#5143) * don't set theme setting on updating theme or keybind * update test for explicit behavior * fix idx logic vs. checking for `system` * improve conciseness Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * use modulo for system check too * Add test for toggle_theme behavior * fix test? * Test toggle_theme is looping all avail themes. * Clarify keybind in settings & docstring * test get_theme and get_system_theme * Use ViewerModel for test * add test to check behavior when theme is system * Break provide_theme_hook into two tests * Use new get_theme for test Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * Fix get_theme, need to pass False * use ViewerModel for `toggle_theme` definition Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * tweak _update_theme per @Czaki * Fix test_canvas_color for system theme * Assert initial theme not the one we toggle to Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Clarify `get_theme` argument Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Refactor per @andy-sweet: make viewer w/theme func * if system, set stylesheet rather than theme * Fix ViewerModel tests per @andy-sweet * Revert "Fix test_canvas_color for system theme" This reverts commit 58effe1. * Fix tests * fix test * back to ViewerModel for toggle_theme Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com>
…es (#5143) * don't set theme setting on updating theme or keybind * update test for explicit behavior * fix idx logic vs. checking for `system` * improve conciseness Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * use modulo for system check too * Add test for toggle_theme behavior * fix test? * Test toggle_theme is looping all avail themes. * Clarify keybind in settings & docstring * test get_theme and get_system_theme * Use ViewerModel for test * add test to check behavior when theme is system * Break provide_theme_hook into two tests * Use new get_theme for test Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * Fix get_theme, need to pass False * use ViewerModel for `toggle_theme` definition Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * tweak _update_theme per @Czaki * Fix test_canvas_color for system theme * Assert initial theme not the one we toggle to Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Clarify `get_theme` argument Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Refactor per @andy-sweet: make viewer w/theme func * if system, set stylesheet rather than theme * Fix ViewerModel tests per @andy-sweet * Revert "Fix test_canvas_color for system theme" This reverts commit 58effe1. * Fix tests * fix test * back to ViewerModel for toggle_theme Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com>
…es (#5143) * don't set theme setting on updating theme or keybind * update test for explicit behavior * fix idx logic vs. checking for `system` * improve conciseness Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * use modulo for system check too * Add test for toggle_theme behavior * fix test? * Test toggle_theme is looping all avail themes. * Clarify keybind in settings & docstring * test get_theme and get_system_theme * Use ViewerModel for test * add test to check behavior when theme is system * Break provide_theme_hook into two tests * Use new get_theme for test Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * Fix get_theme, need to pass False * use ViewerModel for `toggle_theme` definition Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * tweak _update_theme per @Czaki * Fix test_canvas_color for system theme * Assert initial theme not the one we toggle to Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Clarify `get_theme` argument Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Refactor per @andy-sweet: make viewer w/theme func * if system, set stylesheet rather than theme * Fix ViewerModel tests per @andy-sweet * Revert "Fix test_canvas_color for system theme" This reverts commit 58effe1. * Fix tests * fix test * back to ViewerModel for toggle_theme Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com>
…es (#5143) * don't set theme setting on updating theme or keybind * update test for explicit behavior * fix idx logic vs. checking for `system` * improve conciseness Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * use modulo for system check too * Add test for toggle_theme behavior * fix test? * Test toggle_theme is looping all avail themes. * Clarify keybind in settings & docstring * test get_theme and get_system_theme * Use ViewerModel for test * add test to check behavior when theme is system * Break provide_theme_hook into two tests * Use new get_theme for test Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * Fix get_theme, need to pass False * use ViewerModel for `toggle_theme` definition Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * tweak _update_theme per @Czaki * Fix test_canvas_color for system theme * Assert initial theme not the one we toggle to Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Clarify `get_theme` argument Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Refactor per @andy-sweet: make viewer w/theme func * if system, set stylesheet rather than theme * Fix ViewerModel tests per @andy-sweet * Revert "Fix test_canvas_color for system theme" This reverts commit 58effe1. * Fix tests * fix test * back to ViewerModel for toggle_theme Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com>
…es (#5143) * don't set theme setting on updating theme or keybind * update test for explicit behavior * fix idx logic vs. checking for `system` * improve conciseness Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * use modulo for system check too * Add test for toggle_theme behavior * fix test? * Test toggle_theme is looping all avail themes. * Clarify keybind in settings & docstring * test get_theme and get_system_theme * Use ViewerModel for test * add test to check behavior when theme is system * Break provide_theme_hook into two tests * Use new get_theme for test Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * Fix get_theme, need to pass False * use ViewerModel for `toggle_theme` definition Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * tweak _update_theme per @Czaki * Fix test_canvas_color for system theme * Assert initial theme not the one we toggle to Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Clarify `get_theme` argument Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Refactor per @andy-sweet: make viewer w/theme func * if system, set stylesheet rather than theme * Fix ViewerModel tests per @andy-sweet * Revert "Fix test_canvas_color for system theme" This reverts commit 58effe1. * Fix tests * fix test * back to ViewerModel for toggle_theme Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com>
…es (#5143) * don't set theme setting on updating theme or keybind * update test for explicit behavior * fix idx logic vs. checking for `system` * improve conciseness Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * use modulo for system check too * Add test for toggle_theme behavior * fix test? * Test toggle_theme is looping all avail themes. * Clarify keybind in settings & docstring * test get_theme and get_system_theme * Use ViewerModel for test * add test to check behavior when theme is system * Break provide_theme_hook into two tests * Use new get_theme for test Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * Fix get_theme, need to pass False * use ViewerModel for `toggle_theme` definition Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * tweak _update_theme per @Czaki * Fix test_canvas_color for system theme * Assert initial theme not the one we toggle to Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Clarify `get_theme` argument Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Refactor per @andy-sweet: make viewer w/theme func * if system, set stylesheet rather than theme * Fix ViewerModel tests per @andy-sweet * Revert "Fix test_canvas_color for system theme" This reverts commit 58effe1. * Fix tests * fix test * back to ViewerModel for toggle_theme Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com>
…es (#5143) * don't set theme setting on updating theme or keybind * update test for explicit behavior * fix idx logic vs. checking for `system` * improve conciseness Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * use modulo for system check too * Add test for toggle_theme behavior * fix test? * Test toggle_theme is looping all avail themes. * Clarify keybind in settings & docstring * test get_theme and get_system_theme * Use ViewerModel for test * add test to check behavior when theme is system * Break provide_theme_hook into two tests * Use new get_theme for test Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * Fix get_theme, need to pass False * use ViewerModel for `toggle_theme` definition Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> * tweak _update_theme per @Czaki * Fix test_canvas_color for system theme * Assert initial theme not the one we toggle to Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Clarify `get_theme` argument Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com> * Refactor per @andy-sweet: make viewer w/theme func * if system, set stylesheet rather than theme * Fix ViewerModel tests per @andy-sweet * Revert "Fix test_canvas_color for system theme" This reverts commit 58effe1. * Fix tests * fix test * back to ViewerModel for toggle_theme Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com> Co-authored-by: Andy Sweet <andrew.d.sweet@gmail.com>
Description
This PR decouples
viewer.theme
and the Toggle theme keybind (default: shift-command-T) from the settings: when the current viewer theme is changed, the setting is no longer altered. This way, one can change the current viewer theme, but not alter ones preferences.If one wants to alter settings/preferences, then that can and should be done explicitly either using
get_settings().appearance.theme
or using the Preferences GUI.See #5062
Note: the live behavior is really annoying when testing things, because toggling theme requires then fixing preferences when done. It means one can change the
viewer.theme
in examples/scripts without altering the users preferences, see: #4875 (comment)Here's the console output when changing
viewer.theme
(note it's daytime, sosystem == 'light'
)Here's the console output when using the keybind to toggle themes:
You can see that the initial theme is
system
then it's toggled using the keybind a few times, but the setting remainssystem
.Type of change
viewer.theme
will change settings, so no change is needed. The new behavior is consistent with the existing documentation.Depending on point of view, this is either a bug fix or breaking change. I personally think
viewer.theme
and the Toggle theme keybind changing settings is an annoying bug. The fact that the new behavior is consistent with docs also suggests to me that the old behavior was a bug/unintended.References
closes #5062
How has this been tested?
as there are small differences between the two Qt bindings.
As far as I can tell, existing tests are consistent with the new behavior rather than the old behavior.
Final checklist:
trans.
to make them localizable.For more information see our translations guide.