napari icon indicating copy to clipboard operation
napari copied to clipboard

Use app-model for Window menu

Open lucyleeow opened this issue 2 years ago • 9 comments

Description

Used https://github.com/napari/napari/pull/4826 as template. Note it is intended that #4826, which provides all the base code required for the menu migration, will be merged first.

Likely, I got some parts wrong (especially the callback for the Actions), please let me know and I will change. Also can anyone tell me why the ACTIONS list in napari/_qt/menus/window_menu.py is empty...?

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

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.

lucyleeow avatar Aug 24 '22 10:08 lucyleeow

This is ready for review, I am not 100% I have done the callbacks for the ACTIONS correctly.

lucyleeow avatar Sep 16 '22 05:09 lucyleeow

Click here to download the docs artifacts docs (zip file)

github-actions[bot] avatar Sep 16 '22 05:09 github-actions[bot]

Thanks for the review @Czaki !

But this PR is touching the core of napari, and I see no tests in it

Sorry it has not been clear that this PR is based off of https://github.com/napari/napari/pull/4826, which provides the 'core napari' changes required for the migration (and some tests, which I have not copied over). #4826 should be merged first . I agree that the new callbacks (_toogle_layer_controls and _toggle_console - though I don't see the callbacks being tested in https://github.com/napari/napari/pull/4826 or #4865, suggestion for if it is needed or how best to test it welcome) I added should probably be tested though. Any other tests you suggest?

lucyleeow avatar Sep 17 '22 06:09 lucyleeow

Click here to download the docs artifacts docs (zip file)

github-actions[bot] avatar Sep 17 '22 06:09 github-actions[bot]

@lucyleeow when I pull this branch down I get two sets of actions in the Window menu. Whichever one I click it works, but the checkmarks only toggle on the bottom options. I'm not sure if this is a result of needing #4826 to merge or what, but just wanted to flag it.

image

DragaDoncila avatar Sep 27 '22 00:09 DragaDoncila

Click here to download the docs artifacts docs (zip file)

github-actions[bot] avatar Sep 27 '22 00:09 github-actions[bot]

Thanks for flagging the double up, I honestly have no idea why this would happen.... :sweat:

lucyleeow avatar Sep 28 '22 01:09 lucyleeow

Click here to download the docs artifacts docs (zip file)

github-actions[bot] avatar Sep 28 '22 01:09 github-actions[bot]

I updated the test in my PR to not assert menu existence when there is no action registered, I don't think it makes sense to check for no-action menus anyway: https://github.com/napari/napari/pull/4922

liu-ziyang avatar Oct 20 '22 19:10 liu-ziyang

@potating-potato I think we made the same fix - the failure is due to the lru_cache resulting in init_qactions not running in test_build_qmodel_menu.

In https://github.com/napari/napari/pull/4977/commits/e692f909ae44669a68e69c9b30eea1b3a7dc3f47 I have amended and documented this in the _mock_app fixture.

lucyleeow avatar Oct 21 '22 01:10 lucyleeow

This is ready for review and depending on how we feel about ToggleDockWidgetAction, a test should be added for that. Edit: had added test

lucyleeow avatar Oct 21 '22 06:10 lucyleeow

@Czaki Thank you for taking a look at this! Sorry I really should have put 'WIP' since we are in the middle of trying to fix/understand test failures.

It seems that adding our new test test_dock_widget_toggler causes 2 other tests to fail (see e.g.,: https://github.com/napari/napari/actions/runs/3318166722/jobs/5481807630) - though test_dock_widget_toggler passes. Any thoughts/suggestions welcome!!

lucyleeow avatar Nov 02 '22 23:11 lucyleeow

close in favour of #6905 to avoid bad merging

lucyleeow avatar May 09 '24 03:05 lucyleeow