Repository: napari/napari

Issue:
Dock Widgets are hidden when restoring minimized napari
## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->
From https://forum.image.sc/t/dock-widgets-closing-when-minimizing-napari/59353/3

> When I am minimizing the napari window my dock widgets from plugins close as well and I have to reopen them again. Is this happening to anyone else and is this intended?
> napari 0.4.12
> CentOs Linux 8

> Huh, I can reproduce this on macOS.
> What’s funny is when I bring the window back, I briefly see the plugin widget, but then it poofs.
> A bit annoying for sure.
> But, at least on my end, anything I type into fields/etc is preserved when restoring the plugin window.

> Definitely a bug and not intended behaviour. Could you please create an issue at [Issues · napari/napari · GitHub 4](https://github.com/napari/napari/issues), [@Croxa](https://forum.image.sc/u/croxa)? Thank you!

Dock Widgets closing when minimizing napari

## To Reproduce

Steps to reproduce the behavior:

1. Have napari open with a plugin dock widget active.
2. minimize napari
3. un-minimize napari
4. dock widget is no longer visible or active in the toolbar

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior

Expect napari not to deactivate/hide dock widget plugins upon OS minimize/un-minimize operations.

## Environment

I have experienced identical behavior on both ubuntu linux and windows 10 using latest napari(4.17). An account from the linked imagescboard above says it also occurred with their macos.

Here is one such machine:

```
napari: 0.4.17
Platform: Windows-10-10.0.19044-SP0
Python: 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
Qt: 5.15.2
PyQt5: 5.15.7
NumPy: 1.24.1
SciPy: 1.10.0
Dask: 2022.12.1
VisPy: 0.11.0
magicgui: 0.6.1
superqt: 0.3.8
in-n-out: 0.1.6
app-model: 0.1.1
npe2: 0.6.1

OpenGL:
- GL version: 4.6.0 NVIDIA 516.94
- MAX_TEXTURE_SIZE: 32768


Screens:
- screen 1: resolution 1920x1080, scale 1.0
```

## Additional context
NA



Discussion:
I try to reproduce this bug (on ubuntu 22.04 with gnome) and can not. 

Could you provide more details? 

* Used window manager
* If there some data loaded? Which types (images, layers, shapes)
* If it happens for any plugins or only for a specific one? 
 
I can reproduce in 0.4.17 and main on macOS 13.1 arm64 using for example napari-animation plugin (but also cellpose). Doesn't matter if I have some layers open or not.
After un-minimizing napari the widget is missing, but returning it via the plugin menu keeps any settings that were entered.

Edit: just in case it matters: pyside 6.4.2 (main) and pyqt5 (0.4.17) both show this.
Strange. 
PartSeg widgets are not disappearing but napari-animation are. 

PartSeg is still npe1, napari-animations is npe2. 
There may be some additional differences. But, as it looks easy to reproduce, it looks that it may be easy to fix. 


Resolving patch:
diff --git a/napari/_qt/widgets/qt_viewer_dock_widget.py b/napari/_qt/widgets/qt_viewer_dock_widget.py
--- a/napari/_qt/widgets/qt_viewer_dock_widget.py
+++ b/napari/_qt/widgets/qt_viewer_dock_widget.py
@@ -272,7 +272,6 @@ def _on_visibility_changed(self, visible):
 
                 viewer.window.plugins_menu.actions()[idx].setChecked(visible)
 
-            self.setVisible(visible)
             # AttributeError: This error happens when the plugins menu is not yet built.
             # ValueError: This error is when the action is from the windows menu.
 


Test patch: