Make dockarea.restoreState behavior for extrra docks be configurable

This commit is contained in:
Luke Campagnola 2017-09-03 20:14:50 -07:00
parent b6f9516678
commit e8128fa5e2
1 changed files with 10 additions and 4 deletions

View File

@ -208,7 +208,7 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
childs.append(self.childState(obj.widget(i)))
return (obj.type(), childs, obj.saveState())
def restoreState(self, state, missing='error'):
def restoreState(self, state, missing='error', extra='bottom'):
"""
Restore Dock configuration as generated by saveState.
@ -218,6 +218,10 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
By default, docks that are described in *state* but do not exist
in the dock area will cause an exception to be raised. This behavior
can be changed by setting *missing* to 'ignore' or 'create'.
Extra docks that are in the dockarea but that are not mentioned in
*state* will be added to the bottom of the dockarea, unless otherwise
specified by the *extra* argument.
"""
## 1) make dict of all docks and list of existing containers
@ -238,9 +242,11 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
## 4) Add any remaining docks to a float
for d in docks.values():
a = self.addTempArea()
a.addDock(d, 'below')
# self.moveDock(d, 'below', None)
if extra == 'float':
a = self.addTempArea()
a.addDock(d, 'below')
else:
self.moveDock(d, extra, None)
#print "\nKill old containers:"
## 5) kill old containers