-
Notifications
You must be signed in to change notification settings - Fork 15
feat: Update of shortcuts on menu rebuild #258
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #258 +/- ##
=======================================
Coverage 99.78% 99.79%
=======================================
Files 31 31
Lines 1893 1911 +18
=======================================
+ Hits 1889 1907 +18
Misses 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@tlambert03 pyside2 failures are related to the drop of pyside2 support by pytest-qt. |
can you pick whatever method you want then to fix it? either drop the napari tests, or fix it some other way |
Half is fixed in #259. For reusable workflows, I think that I may made similar PR to napari itself. |
# References and relevant issues pyapp-kit/app-model#258 (comment) followup #8067 # Description The `pytest-qt` in version 4.5.0 dropped the support for PySide2. In #8067 I've fixed it on our side, but tests of critical for us pyapp-kit projects are broken. This PR fixes their test that uses https://github.com/pyapp-kit/workflows/blob/main/.github/workflows/test-dependents.yml
"test.update.keybinding.tooltip", | ||
KeyBindingRule(primary=KeyCode.KeyL, source=KeyBindingSource.USER), | ||
) | ||
q_action._update_keybinding() |
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 a little surprised to see this private method called directly in tests.
Whose job is it ultimately to be calling _update_keybinding()
?
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.
Currently it is called on a rebuild of the menu. app model is not evented. I do not yet identified other places.
But maybe it should be a public method?
if kb := self._app.keybindings.get_keybinding(self._command_id): | ||
self.setShortcut(QKeyBindingSequence(kb.keybinding)) | ||
self._keybinding_tooltip = f"({kb.keybinding.to_text()})" |
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 code is more or less the same as what's happening in the init at line 52. Can we maybe avoid that duplication by having this be the one place where that logic is held, and call it in init?
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 problem is with tooltip. If we call this method from line 52, then, for QCommandRuleAction
, the self._tooltip
will be undefined on call of _update_keybinding
I think that we may fix this using metaclass and add __post_init__
where _update_keybinding
will be called.
Co-authored-by: Talley Lambert <talley.lambert@gmail.com>
Co-authored-by: Talley Lambert <talley.lambert@gmail.com>
This PR adds updating of shortcuts on menu rebuild.
This is required for full migration of the napari into app model