def setWorkspace(self, name): if name == self.__active: return LOGGER.debug("Set workspace: %r", name) self.saveState(close=True) self.__panels.clear() self.__active = name self.btn.setText(name) for s in (self.__settings, self.__default_settings): if s is not None: s.deleteLater() conf_name = self.__getWorkspaceConfName(name) self.__settings = util.getSettings(conf_name, parent=self) LOGGER.debug("Openning new QSettings file: %r", self.__settings.fileName()) panels = self.__settings.value("main::openPanels") if panels: for name, ptype in panels: try: p = self.createPanel(ptype, name) except Exception, e: err = traceback.format_exc(3) LOGGER.error("Error creating panel %r (%r): %s", name, ptype, err) self.parent().setUpdatesEnabled(False) QtCore.QTimer.singleShot(0, self.restoreState)
def __initDefaultWorkspaces(self): for space in self.DEFAULTS: name = self.__getWorkspaceConfName(space) settings = util.getSettings(name) if not settings.contains("main::windowState"): src_name = os.path.join(DEFAULTS_DIR, '%s.ini' % name) if not os.path.exists(src_name): LOGGER.warn("Could not locate default layout file: %r", src_name) continue src = QtCore.QSettings(src_name, QtCore.QSettings.IniFormat) for key in self._DEFAULT_KEYS: settings.setValue(key, src.value(key)) settings.sync() settings.deleteLater()