Merge pull request #657 from edbarnard/floating-dock-close

When a floating Dock window is closed, the dock is now returned home
This commit is contained in:
Luke Campagnola 2018-06-07 18:02:31 -07:00 committed by GitHub
commit a38d2282cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,10 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
""" """
if dock is None: if dock is None:
dock = Dock(**kwds) dock = Dock(**kwds)
# store original area that the dock will return to when un-floated
if not self.temporary:
dock.orig_area = self
## Determine the container to insert this dock into. ## Determine the container to insert this dock into.
@ -371,5 +375,11 @@ class TempAreaWindow(QtGui.QWidget):
self.layout.addWidget(area) self.layout.addWidget(area)
def closeEvent(self, *args): def closeEvent(self, *args):
# restore docks to their original area
docks = self.dockarea.findAll()[1]
for dock in docks.values():
if hasattr(dock, 'orig_area'):
dock.orig_area.addDock(dock, )
# clear dock area, and close remaining docks
self.dockarea.clear() self.dockarea.clear()
QtGui.QWidget.closeEvent(self, *args) QtGui.QWidget.closeEvent(self, *args)