diff --git a/cura/MachineAction.py b/cura/MachineAction.py index bc7b17af85..37f09b4efa 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -73,14 +73,8 @@ class MachineAction(QObject, PluginObject): ## Protected helper to create a view object based on provided QML. def _createViewFromQML(self): - path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url)) - self._component = QQmlComponent(Application.getInstance()._engine, path) - self._context = QQmlContext(Application.getInstance()._engine.rootContext()) - self._context.setContextProperty("manager", self) - self._view = self._component.create(self._context) - if self._view is None: - Logger.log("c", "QQmlComponent status %s", self._component.status()) - Logger.log("c", "QQmlComponent error string %s", self._component.errorString()) + path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url) + self._view = Application.getInstance().createQmlComponent(path, {"manager": self}) @pyqtProperty(QObject, constant = True) def displayItem(self): diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 151771b25d..95fef78081 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -256,14 +256,8 @@ class WorkspaceDialog(QObject): return self._result def _createViewFromQML(self): - path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("3MFReader"), self._qml_url)) - self._component = QQmlComponent(Application.getInstance()._engine, path) - self._context = QQmlContext(Application.getInstance()._engine.rootContext()) - self._context.setContextProperty("manager", self) - self._view = self._component.create(self._context) - if self._view is None: - Logger.log("c", "QQmlComponent status %s", self._component.status()) - Logger.log("c", "QQmlComponent error string %s", self._component.errorString()) + path = os.path.join(PluginRegistry.getInstance().getPluginPath("3MFReader"), self._qml_url) + self._view = Application.getInstance().createQmlComponent(path, {"manager": self}) def show(self): # Emit signal so the right thread actually shows the view. diff --git a/plugins/ChangeLogPlugin/ChangeLog.py b/plugins/ChangeLogPlugin/ChangeLog.py index a80779da50..22218bfaeb 100644 --- a/plugins/ChangeLogPlugin/ChangeLog.py +++ b/plugins/ChangeLogPlugin/ChangeLog.py @@ -106,9 +106,5 @@ class ChangeLog(Extension, QObject,): self._changelog_window.hide() def createChangelogWindow(self): - path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "ChangeLog.qml")) - - component = QQmlComponent(Application.getInstance()._engine, path) - self._changelog_context = QQmlContext(Application.getInstance()._engine.rootContext()) - self._changelog_context.setContextProperty("manager", self) - self._changelog_window = component.create(self._changelog_context) + path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "ChangeLog.qml") + self._changelog_window = Application.getInstance().createQmlComponent(path, {"manager": self}) diff --git a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py index fe9095a08b..6167356c4b 100644 --- a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py +++ b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py @@ -91,12 +91,8 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension): # This will create the view if its not already created. def spawnFirmwareInterface(self, serial_port): if self._firmware_view is None: - path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "FirmwareUpdateWindow.qml")) - component = QQmlComponent(Application.getInstance()._engine, path) - - self._firmware_context = QQmlContext(Application.getInstance()._engine.rootContext()) - self._firmware_context.setContextProperty("manager", self) - self._firmware_view = component.create(self._firmware_context) + path = os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "FirmwareUpdateWindow.qml") + self._firmware_view = Application.getInstance().createQmlComponent(path, {"manager": self}) self._firmware_view.show() diff --git a/plugins/UserAgreementPlugin/UserAgreement.py b/plugins/UserAgreementPlugin/UserAgreement.py index f472b6fb13..da225a63b4 100644 --- a/plugins/UserAgreementPlugin/UserAgreement.py +++ b/plugins/UserAgreementPlugin/UserAgreement.py @@ -45,9 +45,5 @@ class UserAgreement(QObject, Extension): CuraApplication.getInstance().setNeedToShowUserAgreement(False) def createUserAgreementWindow(self): - path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "UserAgreement.qml")) - - component = QQmlComponent(Application.getInstance()._engine, path) - self._user_agreement_context = QQmlContext(Application.getInstance()._engine.rootContext()) - self._user_agreement_context.setContextProperty("manager", self) - self._user_agreement_window = component.create(self._user_agreement_context) + path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "UserAgreement.qml") + self._user_agreement_window = Application.getInstance().createQmlComponent(path, {"manager": self})