Dock to emit closed signal when closed. Temporary DockArea windows call close method of all docks when they are closed.
This commit is contained in:
parent
b700a1ad3d
commit
76dbdafacc
@ -7,6 +7,7 @@ from ..python2_3 import asUnicode
|
|||||||
class Dock(QtGui.QWidget, DockDrop):
|
class Dock(QtGui.QWidget, DockDrop):
|
||||||
|
|
||||||
sigStretchChanged = QtCore.Signal()
|
sigStretchChanged = QtCore.Signal()
|
||||||
|
sigClosed = QtCore.Signal(object)
|
||||||
|
|
||||||
def __init__(self, name, area=None, size=(10, 10), widget=None, hideTitle=False, autoOrientation=True, closable=False):
|
def __init__(self, name, area=None, size=(10, 10), widget=None, hideTitle=False, autoOrientation=True, closable=False):
|
||||||
QtGui.QWidget.__init__(self)
|
QtGui.QWidget.__init__(self)
|
||||||
@ -224,6 +225,7 @@ class Dock(QtGui.QWidget, DockDrop):
|
|||||||
self.label.setParent(None)
|
self.label.setParent(None)
|
||||||
self._container.apoptose()
|
self._container.apoptose()
|
||||||
self._container = None
|
self._container = None
|
||||||
|
self.sigClosed.emit(self)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Dock %s %s>" % (self.name(), self.stretch())
|
return "<Dock %s %s>" % (self.name(), self.stretch())
|
||||||
|
@ -172,8 +172,7 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
|
|||||||
if self.home is None:
|
if self.home is None:
|
||||||
area = DockArea(temporary=True, home=self)
|
area = DockArea(temporary=True, home=self)
|
||||||
self.tempAreas.append(area)
|
self.tempAreas.append(area)
|
||||||
win = QtGui.QMainWindow()
|
win = TempAreaWindow(area)
|
||||||
win.setCentralWidget(area)
|
|
||||||
area.win = win
|
area.win = win
|
||||||
win.show()
|
win.show()
|
||||||
else:
|
else:
|
||||||
@ -302,6 +301,11 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
|
|||||||
if self.temporary:
|
if self.temporary:
|
||||||
self.home.removeTempArea(self)
|
self.home.removeTempArea(self)
|
||||||
#self.close()
|
#self.close()
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
docks = self.findAll()[1]
|
||||||
|
for dock in docks.values():
|
||||||
|
dock.close()
|
||||||
|
|
||||||
## PySide bug: We need to explicitly redefine these methods
|
## PySide bug: We need to explicitly redefine these methods
|
||||||
## or else drag/drop events will not be delivered.
|
## or else drag/drop events will not be delivered.
|
||||||
@ -317,5 +321,12 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
|
|||||||
def dropEvent(self, *args):
|
def dropEvent(self, *args):
|
||||||
DockDrop.dropEvent(self, *args)
|
DockDrop.dropEvent(self, *args)
|
||||||
|
|
||||||
|
|
||||||
|
class TempAreaWindow(QtGui.QMainWindow):
|
||||||
|
def __init__(self, area, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.setCentralWidget(area)
|
||||||
|
|
||||||
|
def closeEvent(self, *args, **kwargs):
|
||||||
|
self.centralWidget().clear()
|
||||||
|
super().closeEvent(*args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user