コード例 #1
0
    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()
コード例 #2
0
ファイル: editorapp.py プロジェクト: qtx0213/mcedit2
    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()
コード例 #3
0
ファイル: error_dialog.py プロジェクト: mcedit/mcedit2
    def copyToPastebin(self):
        import Pastebin
        api_dev_key = '0a9ae46e71b44c10184212e4674912c5'
        url = None

        progressText = self.tr("Uploading to pastebin...")
        dialog = MCEProgressDialog(progressText,
                                         None, 0, 0, self)
        dialog.setLabelText(progressText)
        dialog.setWindowTitle(progressText)
        dialog.setStatusTip(progressText)

        dialog.show()
        QtGui.qApp.processEvents()
        try:
            url = Pastebin.paste(api_dev_key, self.errorText,
                                 paste_expire_date="1M")
        except Exception as e:
            log.warn("Failed to upload to pastebin!", exc_info=1)
            self.copyToPastebinLabel.setText(self.tr("Failed to upload to pastebin: ") + str(e))
            if e.message.startswith("https://pastebin.com"):
                url = e.message
        finally:
            dialog.hide()

        if url:
            self.pastebinURLBox.setText(url)
            QtGui.QApplication.clipboard().setText(url)
            self.copyToPastebinLabel.setText(self.tr("Pastebin URL copied to clipboard!"))
コード例 #4
0
ファイル: error_dialog.py プロジェクト: wcpe/mcedit2
    def copyToPastebin(self):
        import Pastebin
        api_dev_key = '0a9ae46e71b44c10184212e4674912c5'
        url = None

        progressText = self.tr("Uploading to pastebin...")
        dialog = MCEProgressDialog(progressText, None, 0, 0, self)
        dialog.setLabelText(progressText)
        dialog.setWindowTitle(progressText)
        dialog.setStatusTip(progressText)

        dialog.show()
        QtGui.qApp.processEvents()
        try:
            url = Pastebin.paste(api_dev_key,
                                 self.errorText,
                                 paste_expire_date="1M")
        except Exception as e:
            log.warn("Failed to upload to pastebin!", exc_info=1)
            self.copyToPastebinLabel.setText(
                self.tr("Failed to upload to pastebin: ") + str(e))
            if e.message.startswith("https://pastebin.com"):
                url = e.message
        finally:
            dialog.hide()

        if url:
            self.pastebinURLBox.setText(url)
            QtGui.QApplication.clipboard().setText(url)
            self.copyToPastebinLabel.setText(
                self.tr("Pastebin URL copied to clipboard!"))