Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restore the last napari-micromanager layout at startup #317

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

fdrgsp
Copy link
Contributor

@fdrgsp fdrgsp commented Feb 28, 2024

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.

Copy link

codecov bot commented Feb 29, 2024

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 ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fdrgsp fdrgsp requested a review from tlambert03 March 8, 2024 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant