From 2b9f17ab24188ffc1dfd17f825066280fb79f8e7 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Fri, 5 Oct 2018 23:30:42 +0200 Subject: [PATCH] fix more API changes --- CHANGELOG.md | 3 +++ DuetRRFOutputDevice.py | 19 +++++++++++-------- DuetRRFPlugin.py | 10 ++++------ plugin.json | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aadec72..944dfbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog of Cura-DuetRRFPlugin +## v0.0.19: 2018-10-05 + * fix more Cura 3.5 incompatibilities + ## v0.0.18: 2018-10-05 * fix Cura 3.5 incompatibility * bump API code diff --git a/DuetRRFOutputDevice.py b/DuetRRFOutputDevice.py index b055a13..e3a0d78 100644 --- a/DuetRRFOutputDevice.py +++ b/DuetRRFOutputDevice.py @@ -23,6 +23,8 @@ from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") +from cura.CuraApplication import CuraApplication + from enum import Enum class OutputStage(Enum): @@ -119,15 +121,15 @@ def requestWrite(self, node, fileName=None, *args, **kwargs): fileName = "%s.gcode" % Application.getInstance().getPrintInformation().jobName self._fileName = fileName - path = QUrl.fromLocalFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'UploadFilename.qml')) - self._component = QQmlComponent(Application.getInstance()._engine, path) - Logger.log("d", self._name_id + " | Errors:", self._component.errors()) - self._context = QQmlContext(Application.getInstance()._engine.rootContext()) - self._context.setContextProperty("manager", self) - self._dialog = self._component.create(self._context) + path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'UploadFilename.qml') + self._dialog = CuraApplication.getInstance().createQmlComponent(path, {"manager": self}) + if dialog is None: + Logger.log("e", "QQmlComponent status %s", self._component.status()) + Logger.log("e", "QQmlComponent errorString %s", self._component.errorString()) + raise RuntimeError(self._component.errorString()) self._dialog.textChanged.connect(self.onFilenameChanged) self._dialog.accepted.connect(self.onFilenameAccepted) - self._dialog.open() + self._dialog.show() self._dialog.findChild(QObject, "nameField").setProperty('text', self._fileName) self._dialog.findChild(QObject, "nameField").select(0, len(self._fileName) - 6) self._dialog.findChild(QObject, "nameField").setProperty('focus', True) @@ -256,7 +258,8 @@ def onSimulationPrintStarted(self): Logger.log("d", self._name_id + " | Simulation print started for file " + self._fileName) - self.onCheckStatus() + # give it some to start the simulation + QTimer.singleShot(15000, self.onCheckStatus) def onCheckStatus(self): if self._stage != OutputStage.writing: diff --git a/DuetRRFPlugin.py b/DuetRRFPlugin.py index 8dab53c..3af9a30 100644 --- a/DuetRRFPlugin.py +++ b/DuetRRFPlugin.py @@ -8,7 +8,6 @@ from UM.Message import Message from UM.Logger import Logger -from UM.Application import Application from UM.Preferences import Preferences from UM.Extension import Extension from UM.PluginRegistry import PluginRegistry @@ -18,6 +17,8 @@ from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") +from cura.CuraApplication import CuraApplication + class DuetRRFPlugin(QObject, Extension, OutputDevicePlugin): def __init__(self, parent=None): @@ -46,11 +47,8 @@ def stop(self): manager.removeOutputDevice(name + "-upload") def _createDialog(self, qml): - path = QUrl.fromLocalFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), qml)) - self._component = QQmlComponent(Application.getInstance()._engine, path) - self._context = QQmlContext(Application.getInstance()._engine.rootContext()) - self._context.setContextProperty("manager", self) - dialog = self._component.create(self._context) + path = os.path.join(os.path.dirname(os.path.abspath(__file__)), qml) + dialog = CuraApplication.getInstance().createQmlComponent(path, {"manager": self}) if dialog is None: Logger.log("e", "QQmlComponent status %s", self._component.status()) Logger.log("e", "QQmlComponent errorString %s", self._component.errorString()) diff --git a/plugin.json b/plugin.json index b4def27..3ab1248 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "name": "DuetRRF", "author": "Thomas Kriechbaumer", "description": "Upload and Print to DuetWifi / DuetEthernet / Duet Maestro with RepRapFirmware.", - "version": "0.0.18", + "version": "0.0.19", "minimum_cura_version": "3.5", "maximum_cura_version": "3.5", "api": 5