napari-micromanager icon indicating copy to clipboard operation
napari-micromanager copied to clipboard

feat: restore the last napari-micromanager layout at startup

Open fdrgsp opened this issue 2 years ago • 1 comments

with this PR, when we save the state of the QMainWindow in a json file so that when we re-open napari-micromanager again the saved layout is restored.

the json file has two keys:

  • layout_state: where the state of the napari QMainWindow is stored using the saveState() method (the state is base64 encoded to be able to save it to the json file)
  • pymmcore_widgets where the names of the docked pymmcore_widgets are stored. The "pymmcore_widgets" key is crucial in our layout saving process. It stores the names of all active pymmcore_widgets at the time of saving. Before restoring the layout, we must recreate these widgets. If not, they won't be included in the restored layout (this is because the pymmcore-widgets are not created at the startup but only when the user clicks on their QPushButton ).

The json file is saved in the appdirs.user_data_dir path in a folder named napari_micromanager.

This PR also adds a ScrollableWidget to house the pymmcore_widgets. This allows for easy docking of widgets either above or below others, ensuring they remain within the monitor's display area and do not overflow off-screen.

fdrgsp avatar Feb 28 '24 03:02 fdrgsp

Codecov Report

Attention: Patch coverage is 90.00000% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 79.23%. Comparing base (4c625fa) to head (bb95a68).

Files Patch % Lines
src/napari_micromanager/_gui_objects/_toolbar.py 89.83% 6 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
+ Coverage   78.24%   79.23%   +0.99%     
==========================================
  Files          13       13              
  Lines         625      684      +59     
==========================================
+ Hits          489      542      +53     
- Misses        136      142       +6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 29 '24 19:02 codecov[bot]