Skip to content

use app-model for file menu#4865

Merged
DragaDoncila merged 174 commits intonapari:mainfrom
tlambert03:appmodel-file-menu
Sep 13, 2023
Merged

use app-model for file menu#4865
DragaDoncila merged 174 commits intonapari:mainfrom
tlambert03:appmodel-file-menu

Conversation

@tlambert03
Copy link
Copy Markdown
Contributor

@tlambert03 tlambert03 commented Jul 26, 2022

Migrate file menubar to app-model. Changes include:

  • moved preference dialog functions to qt_main_window.py
  • Separated building samples menu for npe1 and npe2 so npe1 part can be easily removed later
  • Fixed enablement of the 'save selected' menu items, so it's not enabled if there's no layers selected
  • Added cache_clear to _initialize_plugins and init_qactions in make_napari_viewer because the lru_cache persisted
  • Update enablement/visible status with context of all app-model menu bars even though only file menu has items that use context dependent enablement, for future proofness in case we or a plugin contribution adds something that does

@lucyleeow
Copy link
Copy Markdown
Contributor

CI failures here seem to be spurious: "Error: The operation was canceled."

Copy link
Copy Markdown
Contributor

@DragaDoncila DragaDoncila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pulled this down again and tested with pyqt5, pyqt6, pyside5 and pyside6 and it's all working as expected. Thank you for all your work on this @lucyleeow, particularly pulling out the context keys into a separate PR. Would you mind updating the description so that it's ready for merge? Important things to mention I think would be:

  • moved preference dialog stuff to qt_main_window
  • separated registering of npe1 plugins for easy removal
  • updated the context key for selected layers so it's not enabled if there's no layers selected (different from main right?)
  • maybe a quick note about the autouse fixtures

melissawm pushed a commit to melissawm/napari-docs that referenced this pull request Sep 6, 2023
# Description
This is a CI change that removes `qtgallery` in favor of a
napari-specific scraper. It's not that different but gives us a little
more control and is not much code.

This seems to fix the error seen in "Build PR Docs" for
napari/napari#4865 and also speeds up the docs
build quite a bit (~11 min instead of ~25 min).

I'm no Qt expert but suspect the main improvements here are related to
adding `napari.Viewer.close_all()` (which maybe belongs in the reset fn)
and calling `processEvents()` one more time after this.

The main drawback right now is that this doesn't capture non-Viewer
windows, but this could probably be added if needed.

## Type of change
- [x] Fixes or improves workflow, documentation build or deployment

# References
closes #174 (maybe?)
fixes errors in docs build for
napari/napari#4865

## 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
@lucyleeow
Copy link
Copy Markdown
Contributor

Thanks @DragaDoncila, done!

@DragaDoncila
Copy link
Copy Markdown
Contributor

Starting the 24 hour merge clock on this one folks!

@DragaDoncila DragaDoncila added the ready to merge Last chance for comments! Will be merged in ~24h label Sep 13, 2023
@DragaDoncila DragaDoncila merged commit aee692d into napari:main Sep 13, 2023
@Czaki Czaki removed the ready to merge Last chance for comments! Will be merged in ~24h label Sep 13, 2023
kne42 added a commit to kne42/napari that referenced this pull request Sep 19, 2023
* main: (26 commits)
  Fix some typing in napari.components (napari#6203)
  Use class name for object that does not have qt name (napari#6222)
  test: [Automatic] Constraints upgrades: `hypothesis`, `magicgui`, `psygnal`, `tensorstore`, `tifffile`, `tqdm`, `virtualenv` (napari#6143)
  Replace more np.all( ... = ...) with np.array_equal (napari#6213)
  remove np.all(... == ...) in test_surface.py (napari#6218)
  Ensure pandas Series is initialized with a list as data (napari#6226)
  Stop using temporary directory for store array for paint test (napari#6191)
  Bugfix: ensure thumbnail represents canvas when multiscale (napari#6200)
  cleanup np.all(... == ...) from test_points.py (napari#6217)
  [pre-commit.ci] pre-commit autoupdate (napari#6221)
  use app-model for file menu (napari#4865)
  Add tests to cover slicing behavior when changing layers and data (napari#4819)
  [pre-commit.ci] pre-commit autoupdate (napari#6128)
  Add test coverage for async slicing of labels (napari#5325)
  Add collision check when set colors for labels layer (napari#6193)
  Update "toggle ndview" text (napari#6192)
  Prevent layer controls buttons changing layout while taking screenshots with flash effect on (napari#6194)
  Fix typing in napari.utils.perf (napari#6132)
  Add GUI test coverage for changes to Labels.show_selected_label (napari#5372)
  Fix types in 'napari.utils.colormaps.categorical_colormap' (napari#6154)
  ...
DragaDoncila pushed a commit that referenced this pull request Sep 20, 2023
Reference:
#4865 (comment)

Move `test_file_menu.py` to new app model location, as `file_menu` no
longer exists in `napari/_qt/menus` and this folder is scheduled to be
removed as we move to app model.

Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
DragaDoncila pushed a commit that referenced this pull request Sep 27, 2023
# References and relevant issues
Clean up of missed items from #4865

# Description

* use `:` instead of `.` between words in command ID, to make consistent
with all other commands which all use `:` (and fix tests)
* replace `&` with `&&` in full menu title, not just the sample display
name
Czaki pushed a commit that referenced this pull request Oct 25, 2023
# Description
This is a CI change that removes `qtgallery` in favor of a
napari-specific scraper. It's not that different but gives us a little
more control and is not much code.

This seems to fix the error seen in "Build PR Docs" for
#4865 and also speeds up the docs
build quite a bit (~11 min instead of ~25 min).

I'm no Qt expert but suspect the main improvements here are related to
adding `napari.Viewer.close_all()` (which maybe belongs in the reset fn)
and calling `processEvents()` one more time after this.

The main drawback right now is that this doesn't capture non-Viewer
windows, but this could probably be added if needed.

## Type of change
- [x] Fixes or improves workflow, documentation build or deployment

# References
closes #174 (maybe?)
fixes errors in docs build for
#4865

## 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
@tlambert03 tlambert03 deleted the appmodel-file-menu branch October 28, 2023 00:04
jni pushed a commit that referenced this pull request Aug 9, 2024
# References and relevant issues

closes #7165

# Description

Correctly handles `stack` parameter in `_open_files_dialog`. This was
due to a bad refactor in #4865

I noticed that we don't test any of the `QtViewer` `open_files...` or
`open_folder...` methods. (Some are tested with the file menu but none
of these seem to be tested in isolation?)
I've added a new test file for these but only added a test for this
instance. Maybe additional tests can be added in a follow up PR, in
order to get this fix in quicker?
snorkelopstesting4-web pushed a commit to snorkel-marlin-repos/napari_napari_pr_4865_04cdc43f-8d5d-4379-9be4-6f952515fcd3 that referenced this pull request Oct 22, 2025
Original PR #4865 by tlambert03
Original: napari/napari#4865
snorkelopstesting3-bot added a commit to snorkel-marlin-repos/napari_napari_pr_4865_04cdc43f-8d5d-4379-9be4-6f952515fcd3 that referenced this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement qt Relates to qt tests Something related to our tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants