Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 from python_qt_binding.QtGui import QMainWindow
00032
00033 from .dock_widget import DockWidget
00034
00035
00036 class DockWidgetContainer(DockWidget):
00037
00038 """`DockWidget` containing a main window acting as a container for other dock widgets."""
00039
00040 def __init__(self, container_manager, serial_number):
00041 super(DockWidgetContainer, self).__init__(container_manager)
00042 self._serial_number = serial_number
00043 self._settings = None
00044
00045 self.main_window = QMainWindow()
00046 self.main_window.setDockNestingEnabled(True)
00047 self.setWidget(self.main_window)
00048
00049 def serial_number(self):
00050 return self._serial_number
00051
00052 def setObjectName(self, name):
00053 super(DockWidget, self).setObjectName(name)
00054 self.main_window.setObjectName(name + '__MainWindow')
00055
00056 def save_settings(self, settings):
00057 mw_settings = settings.get_settings('mainwindow')
00058 self._save_geometry(mw_settings)
00059 self._save_state(mw_settings)
00060 super(DockWidgetContainer, self).save_settings(settings)
00061
00062 def _save_geometry(self, settings):
00063
00064
00065 maximized = self.isMaximized()
00066 if maximized:
00067 self.showNormal()
00068 settings.set_value('geometry', self.main_window.saveGeometry())
00069 if maximized:
00070 self.showMaximized()
00071
00072 def _save_state(self, settings):
00073 if self._settings is not None:
00074 self._settings.set_value('state', self.main_window.saveState())
00075
00076 def restore_settings(self, settings):
00077 super(DockWidgetContainer, self).restore_settings(settings)
00078 mw_settings = settings.get_settings('mainwindow')
00079 self._settings = mw_settings
00080
00081 self._restore_geometry(mw_settings)
00082
00083 def _restore_geometry(self, settings):
00084 if settings.contains('geometry'):
00085 self.main_window.restoreGeometry(settings.value('geometry'))
00086
00087 def restore_state(self):
00088 if self._settings.contains('state'):
00089 self.main_window.restoreState(self._settings.value('state'))