-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Hide or Destroy dock widgets #3331
Conversation
love it! will have a look soon |
@tlambert03 I'm glad to hear this response. :) I still need to do a little more work on it. Got some direction from @goanpeca on some trouble I was having with it, so will make a few changes and request a review from you soon! |
Codecov Report
@@ Coverage Diff @@
## main #3331 +/- ##
==========================================
+ Coverage 82.65% 82.68% +0.03%
==========================================
Files 549 549
Lines 45690 45691 +1
==========================================
+ Hits 37763 37780 +17
+ Misses 7927 7911 -16
Continue to review full report at Codecov.
|
@tlambert03 I am ready for your review. One of the last things I did was to only include a "hide" dock widget option for every non-plugin dock widget. For the console, layer list, etc., it seemed a bit complicated if that widget was destroyed and then recreated if a user selected it from the menu. I decided to leave that for another time if that is wanted. This means, though, that those dock widgets have an "eye" symbol and not and 'x'. Let me know if this is OK, or if should use different symbols. cc @goanpeca |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the functionality is great. I really want us to be "killing" plugin dock widgets more readily, and this accomplishes that, so happy to have this go in (once tests have been added that assert that when you close a plugin dock widget, it does indeed get destroyed, and it gets removed from window._dock_widgets, and stuff)
I feel like the code itself is starting to get a little messy ... we're starting to spread and mix together the logic for various concerns (plugin widgets, builtin dock widgets, etc...), and methods are getting longer and harder to test. everywhere that comments "check to see if this is a plugin" should ideally be in a section that knows it it's a plugin widget. (remember, all of these widgets were added at one point with either add_dock_widget
or add_plugin_dock_widget
... so that information was known at one point in the function chain... )
I'm fine with this going in as is, but it would be a good target for a future refactor
napari/_qt/qt_main_window.py
Outdated
if dock_widget.isVisible(): | ||
dock_widget.hide() | ||
else: | ||
dock_widget.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you comment on this? it feels weird to me that someone would ever call add_plugin_dock_widget(...)
and the result would be to hide the widget (even if it already existed). i.e. add_plugin_dock_widget
is not a "toggle dock widget" method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was something I added when I was trying to get the behavior to work properly when a widget was undocked and then you toggled the widget from the menu. Right now, it will call add_plugin_dock_widget
when an action is toggled. I suppose I should change that?
napari/_qt/qt_main_window.py
Outdated
self.window_menu.addAction(action) | ||
|
||
def _toggle_dock_visibility(self, dock_widget=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't see where this is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks to be left over from an old idea. thanks for catching this.
@@ -59,6 +59,9 @@ class QtViewerDockWidget(QDockWidget): | |||
them distribute across the vertical space). By default, True. | |||
""" | |||
|
|||
closed = Signal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really don't like creating new signals and involving other widgets (here the QMainWindow) in the business of "managing" other widgets if it's at all possible to have that other widget manage itself. In this case, it looks like you're creating new signals so that you can check and uncheck the menu action when this gets hidden and shown... but don't you already have a handle to that action below (around line 275)? do we need the main window to do this?
) | ||
else: | ||
add_close = False | ||
except AttributeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what causes the attribute error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail on start up. I think QtCustomTitleBar
is called for the layer list and layer controls before the plugins menu is created.
thanks @tlambert03 ! I will make some changes based on your comments. I want to get it right, so I'm happy to work on it some more. I may ask for help if I can't get something to work. |
quick update---I've addressed some of the comments above, but still need to add some tests. Also, I think I should re-work this part of code:
I am treating |
correct. i know we probably need the concept of "toggle" somewhere in there, but the actual |
@tlambert03 I'm ready for you to take a look again! thank you! |
87bdc0f
to
6f83301
Compare
6f83301
to
50ce25b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @ppwadhwa, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good stuff!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work
# Description <!-- What does this pull request (PR) do? Why is it necessary? --> <!-- Tell us about your new feature, improvement, or fix! --> <!-- If your change includes user interface changes, please add an image, or an animation "An image is worth a thousand words!" --> <!-- You can use https://www.cockos.com/licecap/ or similar to create animations --> It removes the `setVisible` call triggered during minimalization of napari window ## Type of change <!-- Please delete options that are not relevant. --> - [x] 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 <!-- What resources, documentation, and guides were used in the creation of this PR? --> <!-- If this is a bug-fix or otherwise resolves an issue, reference it here with "closes #(issue)" --> closes #5576 # How has this been tested? <!-- Please describe the tests that you ran to verify your changes. --> - [ ] 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](https://napari.org/developers/translations.html). @ppwadhwa You add this in #3331. Maybe I missed some use case and this need to be called in some scenarios. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# Description <!-- What does this pull request (PR) do? Why is it necessary? --> <!-- Tell us about your new feature, improvement, or fix! --> <!-- If your change includes user interface changes, please add an image, or an animation "An image is worth a thousand words!" --> <!-- You can use https://www.cockos.com/licecap/ or similar to create animations --> It removes the `setVisible` call triggered during minimalization of napari window ## Type of change <!-- Please delete options that are not relevant. --> - [x] 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 <!-- What resources, documentation, and guides were used in the creation of this PR? --> <!-- If this is a bug-fix or otherwise resolves an issue, reference it here with "closes #(issue)" --> closes #5576 # How has this been tested? <!-- Please describe the tests that you ran to verify your changes. --> - [ ] 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](https://napari.org/developers/translations.html). @ppwadhwa You add this in #3331. Maybe I missed some use case and this need to be called in some scenarios. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# Description <!-- What does this pull request (PR) do? Why is it necessary? --> <!-- Tell us about your new feature, improvement, or fix! --> <!-- If your change includes user interface changes, please add an image, or an animation "An image is worth a thousand words!" --> <!-- You can use https://www.cockos.com/licecap/ or similar to create animations --> It removes the `setVisible` call triggered during minimalization of napari window ## Type of change <!-- Please delete options that are not relevant. --> - [x] 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 <!-- What resources, documentation, and guides were used in the creation of this PR? --> <!-- If this is a bug-fix or otherwise resolves an issue, reference it here with "closes #(issue)" --> closes #5576 # How has this been tested? <!-- Please describe the tests that you ran to verify your changes. --> - [ ] 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](https://napari.org/developers/translations.html). @ppwadhwa You add this in #3331. Maybe I missed some use case and this need to be called in some scenarios. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# Description <!-- What does this pull request (PR) do? Why is it necessary? --> <!-- Tell us about your new feature, improvement, or fix! --> <!-- If your change includes user interface changes, please add an image, or an animation "An image is worth a thousand words!" --> <!-- You can use https://www.cockos.com/licecap/ or similar to create animations --> It removes the `setVisible` call triggered during minimalization of napari window ## Type of change <!-- Please delete options that are not relevant. --> - [x] 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 <!-- What resources, documentation, and guides were used in the creation of this PR? --> <!-- If this is a bug-fix or otherwise resolves an issue, reference it here with "closes #(issue)" --> closes #5576 # How has this been tested? <!-- Please describe the tests that you ran to verify your changes. --> - [ ] 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](https://napari.org/developers/translations.html). @ppwadhwa You add this in #3331. Maybe I missed some use case and this need to be called in some scenarios. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# Description <!-- What does this pull request (PR) do? Why is it necessary? --> <!-- Tell us about your new feature, improvement, or fix! --> <!-- If your change includes user interface changes, please add an image, or an animation "An image is worth a thousand words!" --> <!-- You can use https://www.cockos.com/licecap/ or similar to create animations --> It removes the `setVisible` call triggered during minimalization of napari window ## Type of change <!-- Please delete options that are not relevant. --> - [x] 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 <!-- What resources, documentation, and guides were used in the creation of this PR? --> <!-- If this is a bug-fix or otherwise resolves an issue, reference it here with "closes #(issue)" --> closes #5576 # How has this been tested? <!-- Please describe the tests that you ran to verify your changes. --> - [ ] 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](https://napari.org/developers/translations.html). @ppwadhwa You add this in #3331. Maybe I missed some use case and this need to be called in some scenarios. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# Description <!-- What does this pull request (PR) do? Why is it necessary? --> <!-- Tell us about your new feature, improvement, or fix! --> <!-- If your change includes user interface changes, please add an image, or an animation "An image is worth a thousand words!" --> <!-- You can use https://www.cockos.com/licecap/ or similar to create animations --> It removes the `setVisible` call triggered during minimalization of napari window ## Type of change <!-- Please delete options that are not relevant. --> - [x] 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 <!-- What resources, documentation, and guides were used in the creation of this PR? --> <!-- If this is a bug-fix or otherwise resolves an issue, reference it here with "closes #(issue)" --> closes #5576 # How has this been tested? <!-- Please describe the tests that you ran to verify your changes. --> - [ ] 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](https://napari.org/developers/translations.html). @ppwadhwa You add this in #3331. Maybe I missed some use case and this need to be called in some scenarios. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This PR adds the options to hide or destroy a dock widget from the title bar.
See #3101
Screen.Recording.2021-09-03.at.1.21.22.AM.mov