-
-
Notifications
You must be signed in to change notification settings - Fork 443
Implement command palette widget #5483
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
Conversation
Active commands should always be first. You should not need to scroll through deactivate one to find the active one. |
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 awesome Hanjin, thanks for getting it off the ground!
I left a couple of general comments to aid my own understanding. Otherwise I have a few early concerns about the code:
- I notice we've added the command palette as a new
ViewerModel
argument and I suspect we probably don't want to do that, as I see the command palette as something purely internal - I don't imagine a user creating a viewer with a different command palette. But maybe that's just me 😆 In general I see the command palette as a widget layer on top ofapp-model
's commands rather than needing a new model - I suspect we don't want the command palette to live in
components
if it has any GUI/Qt related code, which it looks like it does. I'm not sure where the best location would be but again, I would expect most of the code to be purely providing a GUI interface forapp-model
's commands - We may want the widget itself to be contributed to
napari/superqt
, or even depend on yours if you plan on maintaining it separately fromnapari
?
I'm not the best at answering these kinds of code structure/where to put things questions. Maybe @Czaki has suggestions in that vein?
|
||
|
||
@inspect.signature | ||
def register_without_func( |
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.
When would we have a func
less command? What would this be useful for?
title: str | None, | ||
desc: str | None = None, | ||
tooltip: str | None = None, | ||
when: Callable[..., bool] = None, |
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 will need to double check this but for some reason I remember app-model
commands having both when
and enablement
clauses and I feel like when
is whether is shows up in the menu at all and enablement
is whether it's greyed out or not. In which case we'd probably be wanting enablement
here? Again I need to check on this though.
... | ||
|
||
@overload | ||
def register( |
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.
Why is it that both CommandPalette
and CommandGroup
have the same overloaded register
methods? Are you ever registered with one but not the other? Can the CommandGroup
not just be an additional attribute of the Command
?
@hanjinliu we spoke a little bit about this in community meeting today and other core devs share my concerns about the "widgetiness" of the changes to |
Thank you for the review & discussion! Yes, I was also thinking of refactoring napari independent part into other repository. |
@jni thank you for summing up the to-dos.
I think these can be done in the future by specifying the
I already fixed this. I'll push soon.
As far as I tested locally, it seems to me that this |
Do you want to commit that to see if it passes CI while still working? |
Ok, let's see! |
This is pretty fun! For anyone trying to figure out how to use it, it's
|
Omg all green 😭 |
yeah probably those are not routed through app model. We should improve that! Having the command palette will be massive positive pressure to get the migration done. I agree that opening samples with this absolutely rocks. |
Whoop whoop! 🥳 |
I keep meaning to come back to this PR and just say how awesome it is. Any time I'm not on main right now I miss this command palette. Agreed that it's so nice already even just for loading Samples, but I really look forward to the usability this unlocks in the future! |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/upcoming-napari-0-6-0-release/108954/1 |
Just posting a video here so I can link to it 😂 command-palette.mp4 |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: |
Description
This PR implements a command palette widget.
Still work-in-progress, but here's the list of required functinalities and how much of them this PR has done (See #5430).
→ fuzzy matching is not implemented yet. Just match by
__contains__
for now.→ Contexts are auto-generated from the command ID (e.g. "napari:layer:XYZ" → "napari > layer > XYZ")
→ Currently, only those commands registered in the
app-model
way are available (so some commands such as "Open Files ..." are not available).→ Not yet, but current implementation is already prepared for it.
→ The "when" parameters of commands are evaluated and unavaliable ones are grayed out.
Type of change
References
#5430
How has this been tested?
as there are small differences between the two Qt bindings.
Final checklist:
trans.
to make them localizable.For more information see our translations guide.