Skip to content

Commit ef267d3

Browse files
Update where app-model actions/providers/processors live in codebase (#416)
# References and relevant issues Relates to napari/napari#6848 Depends on napari/napari#6743 # Description Updates the info on where actions live in the napari codebase. --------- Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
1 parent 7125f16 commit ef267d3

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

docs/developers/architecture/app_model.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,20 @@ This is because command id's may currently only be registered once, and associat
127127

128128
### `Action`s in napari
129129

130-
In napari, non-Qt `Action`s are defined in
131-
[`napari/_app_model/actions`](https://github.com/napari/napari/tree/main/napari/_app_model/actions)
132-
while Qt `Action`s are defined in
133-
[`napari/_qt/_qapp_model/qactions`](https://github.com/napari/napari/tree/main/napari/_qt/_qapp_model/qactions).
130+
In napari, menu bar actions are defined in
131+
[`napari/_qt/_qapp_model/qactions`](https://github.com/napari/napari/tree/main/napari/_qt/_qapp_model/qactions),
132+
with one file per menu.
133+
While not all menu bar actions strictly require Qt, they are defined for the purpose
134+
of living in a menu and are thus considered 'GUI' actions.
135+
This also ensures that there is only one file defining both actions and their
136+
submenus.
137+
Note if we move to supporting more GUI backends, we may want to move these out of
138+
`_qt/` to a shared `gui/` folder, depending on implementation.
139+
140+
The layer context menu actions do not require a GUI (they only require the `layerlist`)
141+
and thus live in
142+
[`napari/_app_model/actions`](https://github.com/napari/napari/tree/main/napari/_app_model/actions).
143+
134144
Non-Qt `Action`s get registered with `app` during
135145
initialization of the napari `app`, in `NapariApplication`'s
136146
{meth}`~napari._app_model._app.NapariApplication.__init__`. Qt `Action`s
@@ -455,18 +465,17 @@ ways will not work:
455465

456466
### Providers and processors in napari
457467

458-
Non-Qt providers and processors are defined in
459-
[`napari/_app_model/injection`](https://github.com/napari/napari/tree/main/napari/_app_model/injection).
460-
Qt providers and processors are defined in
468+
Currently there are only GUI related providers and processors.
469+
They are defined in
461470
[`napari/_qt/_qapp_model/injection`](https://github.com/napari/napari/tree/main/napari/_qt/_qapp_model/injection).
471+
They are registered in {func}`~napari._qt._qapp_model.qactions.init_qactions`,
472+
which gets called during initialization of `_QtMainWindow`. This is the same as
473+
[registration of `Action`s](app-model-actions-napari).
462474

463-
Non-Qt providers and processors are registered in the `app` `Store` during
475+
In future we intend to have non-GUI providers that will supply layer objects.
476+
They would be registered in the `app` `Store` during
464477
initialization of the napari `app`, in `NapariApplication`'s
465478
{meth}`~napari._app_model._app.NapariApplication.__init__`.
466-
Qt providers and processors are registered in
467-
{func}`~napari._qt._qapp_model.qactions.init_qactions`, which gets called during
468-
initialization of `_QtMainWindow`. This is the same as
469-
[registration of `Action`s](app-model-actions-napari).
470479

471480
(app-model-testing)=
472481

0 commit comments

Comments
 (0)