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 QIcon
00032
00033 from .dock_widget import DockWidget
00034 from .dockable_main_window import DockableMainWindow
00035
00036
00037 class DockWidgetContainer(DockWidget):
00038
00039 """`DockWidget` containing a main window acting as a container for other dock widgets."""
00040
00041 def __init__(self, container_manager, serial_number):
00042 super(DockWidgetContainer, self).__init__(container_manager)
00043 self._serial_number = serial_number
00044 self._settings = None
00045
00046 self.main_window = DockableMainWindow()
00047 self.setWidget(self.main_window)
00048 self.setWindowIcon(QIcon.fromTheme('folder'))
00049
00050 def serial_number(self):
00051 return self._serial_number
00052
00053 def setObjectName(self, name):
00054 super(DockWidget, self).setObjectName(name)
00055 self.main_window.setObjectName(name + '__MainWindow')
00056
00057 def save_settings(self, settings):
00058 mw_settings = settings.get_settings('mainwindow')
00059 self._save_geometry(mw_settings)
00060 self._save_state(mw_settings)
00061 super(DockWidgetContainer, self).save_settings(settings)
00062
00063 def _save_geometry(self, settings):
00064
00065
00066 maximized = self.isMaximized()
00067 if maximized:
00068 self.showNormal()
00069 settings.set_value('geometry', self.main_window.saveGeometry())
00070 if maximized:
00071 self.showMaximized()
00072
00073 def _save_state(self, settings):
00074 if self._settings is not None:
00075 self._settings.set_value('state', self.main_window.saveState())
00076
00077 def restore_settings(self, settings):
00078 super(DockWidgetContainer, self).restore_settings(settings)
00079 mw_settings = settings.get_settings('mainwindow')
00080 self._settings = mw_settings
00081
00082 self._restore_geometry(mw_settings)
00083
00084 def _restore_geometry(self, settings):
00085 if settings.contains('geometry'):
00086 self.main_window.restoreGeometry(settings.value('geometry'))
00087
00088 def restore_state(self):
00089 if self._settings.contains('state'):
00090 self.main_window.restoreState(self._settings.value('state'))