feat: restore the last napari-micromanager layout at startup
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 thenapari QMainWindowis stored using thesaveState()method (the state isbase64encoded to be able to save it to thejsonfile) -
pymmcore_widgetswhere the names of the dockedpymmcore_widgetsare 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 thepymmcore-widgetsare not created at the startup but only when the user clicks on theirQPushButton).
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.
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.