def loadFile(self, filename, readonly=False): filename = os.path.normpath(filename) for s in self.sessions: if s.filename == filename: self.tabWidget.setCurrentWidget(s.editorTab) return self.hideWorldList() fileLoadingDialog = MCEProgressDialog(self.tr("Loading world..."), None, 0, 1, self.mainWindow) fileLoadingDialog.setAutoReset(False) fileLoadingDialog.setWindowModality(Qt.WindowModal) fileLoadingDialog.setMinimumDuration(0) fileLoadingDialog.setValue(0) fileLoadingDialog.setWindowTitle(self.tr("Loading world...")) self.processEvents() def callback(current, max, status): fileLoadingDialog.setValue(current) fileLoadingDialog.setMaximum(max) fileLoadingDialog.setLabelText(status) try: configuredBlocks = self.configureBlocksDialog.getConfiguredBlocks() session = EditorSession(filename, configuredBlocks, readonly=readonly, progressCallback=callback) self.undoGroup.addStack(session.undoStack) self.tabWidget.addTab(session.editorTab, session.tabCaption()) self.tabWidget.setCurrentWidget(session.editorTab) self.sessions.append(session) self.addRecentFile(filename) session.loadDone() except Exception as e: log.exception("EditorSession failed to open %s: %r", filename, e) errorTab = QtGui.QWidget() setWidgetError(errorTab, e, "An error occurred while opening %s" % filename) self.tabWidget.addTab(errorTab, "Failed to open %s" % filename) fileLoadingDialog.reset()
def loadFile(self, filename, readonly=False): self.hideWorldList() fileLoadingDialog = MCEProgressDialog(self.tr("Loading world..."), None, 0, 1, self.mainWindow) fileLoadingDialog.setAutoReset(False) fileLoadingDialog.setWindowModality(Qt.WindowModal) fileLoadingDialog.setMinimumDuration(0) fileLoadingDialog.setValue(0) fileLoadingDialog.setWindowTitle(self.tr("Loading world...")) self.processEvents() def callback(current, max, status): fileLoadingDialog.setValue(current) fileLoadingDialog.setMaximum(max) fileLoadingDialog.setLabelText(status) try: configuredBlocks = self.configureBlocksDialog.getConfiguredBlocks() session = EditorSession(filename, configuredBlocks, readonly=readonly, progressCallback=callback) self.undoGroup.addStack(session.undoStack) self.tabWidget.addTab(session.editorTab, session.tabCaption()) self.tabWidget.setCurrentWidget(session.editorTab) self.sessions.append(session) self.addRecentFile(filename) session.loadDone() except Exception as e: log.exception("EditorSession failed to open %s: %r", filename, e) errorTab = QtGui.QWidget() setWidgetError(errorTab, e, "An error occurred while opening %s" % filename) self.tabWidget.addTab(errorTab, "Failed to open %s" % filename) fileLoadingDialog.reset()