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

Bugfix: improve layout of Preferences > Shortcuts tables #5679

Merged
merged 25 commits into from
Jun 1, 2023

Conversation

psobolewskiPhD
Copy link
Member

@psobolewskiPhD psobolewskiPhD commented Mar 28, 2023

Description

Closes #5671

This PR adjusts the layout of the tables used for editing shortcuts such that long action descriptions can be read in their entirety. Briefly:

  1. it changes the column widths, to give the text more room
  2. as a result of 1, it left aligns the action descriptions so they are visually closer to the keybindings
  3. it enables wrapping of long action descriptions
  4. as a result of 3, it adjusts the row height and padding

Here's the new look: Viewer
image

versus main without this PR:
image

Notice how Show/hide IPython ... action has the full description readable, because it's line wrapped. Also, in my opinion the overall layout is more readable and pleasing.
Open to suggestions though!

New look Labels (main is shown in the issue):
image

Note: the new widths of the keybind columns are set to be sufficient for Ctrl-Alt-Meta- with a bit extra left-over.

Type of change

  • Bug-fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

References

Closes #5671
Some discussion of the table is also here #5018
this was the PR that implemented the second keybinding column.

How has this been tested?

  • example: the test suite for my feature covers cases x, y, and z
  • example: all tests pass with my change
  • example: I check if my changes works with both PySide and PyQt backends
    as there are small differences between the two Qt bindings.

Final checklist:

  • My PR is the minimum possible work for the desired functionality
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • If I included new strings, I have used trans. to make them localizable.
    For more information see our translations guide.

@github-actions github-actions bot added the qt Relates to qt label Mar 28, 2023
@Carreau
Copy link
Contributor

Carreau commented Mar 28, 2023

That will likely conflict with #5604 and #5064, but +1

@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Merging #5679 (99c0463) into main (bd69fd2) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #5679   +/-   ##
=======================================
  Coverage   90.01%   90.02%           
=======================================
  Files         618      618           
  Lines       52827    52831    +4     
=======================================
+ Hits        47553    47561    +8     
+ Misses       5274     5270    -4     
Impacted Files Coverage Δ
napari/components/_viewer_key_bindings.py 97.33% <ø> (ø)
napari/_qt/widgets/qt_keyboard_settings.py 70.80% <100.00%> (+0.39%) ⬆️

... and 3 files with indirect coverage changes

@Czaki Czaki mentioned this pull request Apr 5, 2023
9 tasks
Czaki added a commit that referenced this pull request Apr 13, 2023
# Description
<!-- What does this pull request (PR) do? Why is it necessary? -->
<!-- Tell us about your new feature, improvement, or fix! -->
<!-- If your change includes user interface changes, please add an
image, or an animation "An image is worth a thousand words!" -->
<!-- You can use https://www.cockos.com/licecap/ or similar to create
animations -->

Improvements in settings generation when settings have only one field.
Also, update name show on top of group to use `title` instead of class
name


This PR:

![obraz](https://user-images.githubusercontent.com/3826210/230038230-f65c26d9-29b9-4725-9626-a54d558ad9a4.png)

Current main:


![obraz](https://user-images.githubusercontent.com/3826210/230038392-f77d9ecf-260c-46db-82d2-e5eec26d9804.png)


# References
<!-- What resources, documentation, and guides were used in the creation
of this PR? -->

This PR is inspired by #5679 showed on community meeting

## Type of change
<!-- Please delete options that are not relevant. -->
- [ ] Refactor 

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [ ] example: the test suite for my feature covers cases x, y, and z
- [ ] example: all tests pass with my change
- [ ] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [ ] My PR is the minimum possible work for the desired functionality
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] If I included new strings, I have used `trans.` to make them
localizable.
For more information see our [translations
guide](https://napari.org/developers/translations.html).
@Czaki
Copy link
Collaborator

Czaki commented Apr 14, 2023

As #5696 is merged, could you update the branch and post new screenshots?

@psobolewskiPhD
Copy link
Member Author

As #5696 is merged, could you update the branch and post new screenshots?

Yes, sorry was traveling. I will get on this this weekend.

@psobolewskiPhD psobolewskiPhD force-pushed the bugfix/spacing_keybind_settings branch from 06c5980 to 66ed7d2 Compare April 15, 2023 14:41
@psobolewskiPhD
Copy link
Member Author

I think it will be impossible to satisfy pyside6, pyqt6 and pyqt5 all the way back to 5.12.3
I think pyqt5 5.13 is needed for the alignment flags to work.
So either need some logic to check Qt version or bump minimum requirements...

@Czaki
Copy link
Collaborator

Czaki commented Apr 15, 2023

Maybe add napari._qt._compat and import the alignment flag from _compat?

But also 0.5.0 may be enough to bump Qt requirements.

@Czaki
Copy link
Collaborator

Czaki commented May 12, 2023

Could you update the screenshots in the description?

@psobolewskiPhD
Copy link
Member Author

psobolewskiPhD commented May 25, 2023

Coming back to this, I sort of hated the right justify after all.
I ended up using non-breaking spaces in the Viewer action names and changing the columns to be a bit more balanced.
Then left justify everything (including headers)

(I updated the screenshots in OP)

@jni
Copy link
Member

jni commented May 26, 2023

@psobolewskiPhD I might call this an enhancement more than a bugfix?

@Czaki Czaki added the ready to merge Last chance for comments! Will be merged in ~24h label May 26, 2023
@psobolewskiPhD
Copy link
Member Author

psobolewskiPhD commented May 27, 2023

@jni I guess? depends on how you look at the truncated action names.
🤷‍♂️
But sure, we can call it enhancement and move it to the 0.5.0 milestone.

@psobolewskiPhD psobolewskiPhD added enhancement and removed maintenance PR with maintance changes, pr-party-update-async labels May 27, 2023
@psobolewskiPhD psobolewskiPhD modified the milestones: 0.4.18, 0.5.0 May 27, 2023
@Czaki
Copy link
Collaborator

Czaki commented May 28, 2023

Why move to 0.5.0? It is not breaking change, so it is worth trying to backport it.

@psobolewskiPhD
Copy link
Member Author

I was going off @jni comment, thought he was meaning to move it to 0.5.0 because it's not a bug fix?

@Czaki Czaki modified the milestones: 0.5.0, 0.4.18 Jun 1, 2023
@Czaki Czaki merged commit 894c03c into napari:main Jun 1, 2023
32 checks passed
@Czaki Czaki removed the ready to merge Last chance for comments! Will be merged in ~24h label Jun 1, 2023
dstansby pushed a commit to dstansby/napari that referenced this pull request Jun 2, 2023
# Description
Closes napari#5671

This PR adjusts the layout of the tables used for editing shortcuts such
that long action descriptions can be read in their entirety. Briefly:
1) it changes the column widths, to give the text more room
2) as a result of 1, it left aligns the action descriptions so they are
visually closer to the keybindings
3) it enables wrapping of long action descriptions
4) as a result of 3, it adjusts the row height and padding

Here's the new look: Viewer
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/cfa97346-efeb-425b-b767-00e10da9f71d">

versus `main` without this PR:
<img width="1198" alt="image"
src="https://user-images.githubusercontent.com/76622105/228291024-39ca5495-75ef-4017-99c4-0ee4bf4238bf.png">

Notice how `Show/hide IPython ...` action has the full description
readable, because it's line wrapped. Also, in my opinion the overall
layout is more readable and pleasing.
Open to suggestions though!

New look Labels (main is shown in the issue):
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/3de31dc3-a28a-48ac-b1a8-0be85b1555d7">

Note: the new widths of the keybind columns are set to be sufficient for
Ctrl-Alt-Meta-<Letter> with a bit extra left-over.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes napari#5671
Some discussion of the table is also here
napari#5018
this was the PR that implemented the second keybinding column.

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [x] example: all tests pass with my change

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@Czaki Czaki mentioned this pull request Jun 7, 2023
Czaki added a commit that referenced this pull request Jun 19, 2023
…5854)

# Fixes/Closes

Closes #5853

# Description
In `qt_keyboard_settings.py` the use of
`item.setFlags(Qt.ItemFlag.NoItemFlags)`

https://github.com/napari/napari/blob/0dfb37b474490b4d9829c4fa93cb3d648b4b186d/napari/_qt/widgets/qt_keyboard_settings.py#L233
results in these items being `disabled` so as a consequence of
#5745 these table items get the
reduced opacity leading to reduced contrast.
This PR instead uses (❤️ @Czaki ):
`item.setFlags(Qt.ItemFlag.ItemIsEnabled)`
to ensure these items are `enabled` so that the opacity change does not
affect them.

# References
Noted by @Czaki here
#5679 (comment)

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
- [x] example: all tests pass with my change
- [x] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Czaki added a commit that referenced this pull request Jun 19, 2023
# Description
Closes #5671

This PR adjusts the layout of the tables used for editing shortcuts such
that long action descriptions can be read in their entirety. Briefly:
1) it changes the column widths, to give the text more room
2) as a result of 1, it left aligns the action descriptions so they are
visually closer to the keybindings
3) it enables wrapping of long action descriptions
4) as a result of 3, it adjusts the row height and padding

Here's the new look: Viewer
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/cfa97346-efeb-425b-b767-00e10da9f71d">

versus `main` without this PR:
<img width="1198" alt="image"
src="https://user-images.githubusercontent.com/76622105/228291024-39ca5495-75ef-4017-99c4-0ee4bf4238bf.png">

Notice how `Show/hide IPython ...` action has the full description
readable, because it's line wrapped. Also, in my opinion the overall
layout is more readable and pleasing.
Open to suggestions though!

New look Labels (main is shown in the issue):
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/3de31dc3-a28a-48ac-b1a8-0be85b1555d7">

Note: the new widths of the keybind columns are set to be sufficient for
Ctrl-Alt-Meta-<Letter> with a bit extra left-over.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5671
Some discussion of the table is also here
#5018
this was the PR that implemented the second keybinding column.

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [x] example: all tests pass with my change

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
…5854)

# Fixes/Closes

Closes #5853

# Description
In `qt_keyboard_settings.py` the use of
`item.setFlags(Qt.ItemFlag.NoItemFlags)`

https://github.com/napari/napari/blob/0dfb37b474490b4d9829c4fa93cb3d648b4b186d/napari/_qt/widgets/qt_keyboard_settings.py#L233
results in these items being `disabled` so as a consequence of
#5745 these table items get the
reduced opacity leading to reduced contrast.
This PR instead uses (❤️ @Czaki ):
`item.setFlags(Qt.ItemFlag.ItemIsEnabled)`
to ensure these items are `enabled` so that the opacity change does not
affect them.

# References
Noted by @Czaki here
#5679 (comment)

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
- [x] example: all tests pass with my change
- [x] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
# Description
Closes #5671

This PR adjusts the layout of the tables used for editing shortcuts such
that long action descriptions can be read in their entirety. Briefly:
1) it changes the column widths, to give the text more room
2) as a result of 1, it left aligns the action descriptions so they are
visually closer to the keybindings
3) it enables wrapping of long action descriptions
4) as a result of 3, it adjusts the row height and padding

Here's the new look: Viewer
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/cfa97346-efeb-425b-b767-00e10da9f71d">

versus `main` without this PR:
<img width="1198" alt="image"
src="https://user-images.githubusercontent.com/76622105/228291024-39ca5495-75ef-4017-99c4-0ee4bf4238bf.png">

Notice how `Show/hide IPython ...` action has the full description
readable, because it's line wrapped. Also, in my opinion the overall
layout is more readable and pleasing.
Open to suggestions though!

New look Labels (main is shown in the issue):
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/3de31dc3-a28a-48ac-b1a8-0be85b1555d7">

Note: the new widths of the keybind columns are set to be sufficient for
Ctrl-Alt-Meta-<Letter> with a bit extra left-over.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5671
Some discussion of the table is also here
#5018
this was the PR that implemented the second keybinding column.

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [x] example: all tests pass with my change

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
…5854)

# Fixes/Closes

Closes #5853

# Description
In `qt_keyboard_settings.py` the use of
`item.setFlags(Qt.ItemFlag.NoItemFlags)`

https://github.com/napari/napari/blob/0dfb37b474490b4d9829c4fa93cb3d648b4b186d/napari/_qt/widgets/qt_keyboard_settings.py#L233
results in these items being `disabled` so as a consequence of
#5745 these table items get the
reduced opacity leading to reduced contrast.
This PR instead uses (❤️ @Czaki ):
`item.setFlags(Qt.ItemFlag.ItemIsEnabled)`
to ensure these items are `enabled` so that the opacity change does not
affect them.

# References
Noted by @Czaki here
#5679 (comment)

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
- [x] example: all tests pass with my change
- [x] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
# Description
Closes #5671

This PR adjusts the layout of the tables used for editing shortcuts such
that long action descriptions can be read in their entirety. Briefly:
1) it changes the column widths, to give the text more room
2) as a result of 1, it left aligns the action descriptions so they are
visually closer to the keybindings
3) it enables wrapping of long action descriptions
4) as a result of 3, it adjusts the row height and padding

Here's the new look: Viewer
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/cfa97346-efeb-425b-b767-00e10da9f71d">

versus `main` without this PR:
<img width="1198" alt="image"
src="https://user-images.githubusercontent.com/76622105/228291024-39ca5495-75ef-4017-99c4-0ee4bf4238bf.png">

Notice how `Show/hide IPython ...` action has the full description
readable, because it's line wrapped. Also, in my opinion the overall
layout is more readable and pleasing.
Open to suggestions though!

New look Labels (main is shown in the issue):
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/3de31dc3-a28a-48ac-b1a8-0be85b1555d7">

Note: the new widths of the keybind columns are set to be sufficient for
Ctrl-Alt-Meta-<Letter> with a bit extra left-over.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5671
Some discussion of the table is also here
#5018
this was the PR that implemented the second keybinding column.

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [x] example: all tests pass with my change

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
…5854)

# Fixes/Closes

Closes #5853

# Description
In `qt_keyboard_settings.py` the use of
`item.setFlags(Qt.ItemFlag.NoItemFlags)`

https://github.com/napari/napari/blob/0dfb37b474490b4d9829c4fa93cb3d648b4b186d/napari/_qt/widgets/qt_keyboard_settings.py#L233
results in these items being `disabled` so as a consequence of
#5745 these table items get the
reduced opacity leading to reduced contrast.
This PR instead uses (❤️ @Czaki ):
`item.setFlags(Qt.ItemFlag.ItemIsEnabled)`
to ensure these items are `enabled` so that the opacity change does not
affect them.

# References
Noted by @Czaki here
#5679 (comment)

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
- [x] example: all tests pass with my change
- [x] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
# Description
Closes #5671

This PR adjusts the layout of the tables used for editing shortcuts such
that long action descriptions can be read in their entirety. Briefly:
1) it changes the column widths, to give the text more room
2) as a result of 1, it left aligns the action descriptions so they are
visually closer to the keybindings
3) it enables wrapping of long action descriptions
4) as a result of 3, it adjusts the row height and padding

Here's the new look: Viewer
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/cfa97346-efeb-425b-b767-00e10da9f71d">

versus `main` without this PR:
<img width="1198" alt="image"
src="https://user-images.githubusercontent.com/76622105/228291024-39ca5495-75ef-4017-99c4-0ee4bf4238bf.png">

Notice how `Show/hide IPython ...` action has the full description
readable, because it's line wrapped. Also, in my opinion the overall
layout is more readable and pleasing.
Open to suggestions though!

New look Labels (main is shown in the issue):
<img width="1232" alt="image"
src="https://github.com/napari/napari/assets/76622105/3de31dc3-a28a-48ac-b1a8-0be85b1555d7">

Note: the new widths of the keybind columns are set to be sufficient for
Ctrl-Alt-Meta-<Letter> with a bit extra left-over.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5671
Some discussion of the table is also here
#5018
this was the PR that implemented the second keybinding column.

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [x] example: all tests pass with my change

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki added a commit that referenced this pull request Jun 23, 2023
<!-- What does this pull request (PR) do? Why is it necessary? -->
<!-- Tell us about your new feature, improvement, or fix! -->
<!-- If your change includes user interface changes, please add an
image, or an animation "An image is worth a thousand words!" -->
<!-- You can use https://www.cockos.com/licecap/ or similar to create
animations -->

Improvements in settings generation when settings have only one field.
Also, update name show on top of group to use `title` instead of class
name

This PR:

![obraz](https://user-images.githubusercontent.com/3826210/230038230-f65c26d9-29b9-4725-9626-a54d558ad9a4.png)

Current main:

![obraz](https://user-images.githubusercontent.com/3826210/230038392-f77d9ecf-260c-46db-82d2-e5eec26d9804.png)

<!-- What resources, documentation, and guides were used in the creation
of this PR? -->

This PR is inspired by #5679 showed on community meeting

<!-- Please delete options that are not relevant. -->
- [ ] Refactor

<!-- Please describe the tests that you ran to verify your changes. -->
- [ ] example: the test suite for my feature covers cases x, y, and z
- [ ] example: all tests pass with my change
- [ ] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.

- [ ] My PR is the minimum possible work for the desired functionality
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] If I included new strings, I have used `trans.` to make them
localizable.
For more information see our [translations
guide](https://napari.org/developers/translations.html).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement qt Relates to qt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shortcuts preferences: long action names are elided even though there is space
5 participants