From cac8c85489a5b941ce939523c6ccf6d6dfb53f11 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 1 Mar 2019 10:46:41 +0100 Subject: [PATCH] Don't use __file__ Contributes to CL-1274 --- .../src/Cloud/CloudOutputDevice.py | 6 ++++-- .../UM3NetworkPrinting/src/ClusterUM3OutputDevice.py | 10 ++++++++-- .../UM3NetworkPrinting/src/LegacyUM3OutputDevice.py | 5 ++++- .../UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 12 ++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 86c7e1cab6..4d5673effe 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -84,8 +84,10 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice): self._account = api_client.account # We use the Cura Connect monitor tab to get most functionality right away. - self._monitor_view_qml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - "../../resources/qml/MonitorStage.qml") + self._monitor_view_qml_path = os.path.join( + PluginRegistry.getPluginDirectory(), + "UM3NetworkPrinting", "resources", "qml", "MonitorStage.qml" + ) # Trigger the printersChanged signal when the private signal is triggered. self.printersChanged.connect(self._clusterPrintersChanged) diff --git a/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py index 07c968c960..919788f10e 100644 --- a/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py @@ -65,7 +65,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._print_jobs = [] # type: List[UM3PrintJobOutputModel] self._received_print_jobs = False # type: bool - self._monitor_view_qml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/qml/MonitorStage.qml") + self._monitor_view_qml_path = os.path.join( + PluginRegistry.getPluginDirectory(), + "UM3NetworkPrinting", "resources", "qml", "MonitorStage.qml" + ) # Trigger the printersChanged signal when the private signal is triggered self.printersChanged.connect(self._clusterPrintersChanged) @@ -126,7 +129,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): def _spawnPrinterSelectionDialog(self): if self._printer_selection_dialog is None: - path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/qml/PrintWindow.qml") + path = os.path.join( + PluginRegistry.getPluginDirectory(), + "UM3NetworkPrinting", "resources", "qml", "PrintWindow.qml" + ) self._printer_selection_dialog = self._application.createQmlComponent(path, {"OutputDevice": self}) if self._printer_selection_dialog is not None: self._printer_selection_dialog.show() diff --git a/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py index d6e71fd56f..68a4e7d42c 100644 --- a/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py @@ -77,7 +77,10 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): self.setIconName("print") - self._monitor_view_qml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/qml/MonitorItem.qml") + self._monitor_view_qml_path = os.path.join( + PluginRegistry.getPluginDirectory(), + "UM3NetworkPrinting", "resources", "qml", "MonitorItem.qml" + ) self._output_controller = LegacyUM3PrinterOutputController(self) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index aedd29d247..10476d55b4 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -457,8 +457,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._start_cloud_flow_message = Message( text = i18n_catalog.i18nc("@info:status", "Send and monitor print jobs from anywhere using your Ultimaker account."), lifetime = 0, - image_source = QUrl.fromLocalFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", - "resources", "svg", "cloud-flow-start.svg")), + image_source = QUrl.fromLocalFile(os.path.join( + PluginRegistry.getPluginDirectory(), + "UM3NetworkPrinting", "resources", "svg", "cloud-flow-start.svg" + )), image_caption = i18n_catalog.i18nc("@info:status", "Connect to Ultimaker Cloud"), option_text = i18n_catalog.i18nc("@action", "Don't ask me again for this printer."), option_state = False @@ -479,8 +481,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._cloud_flow_complete_message = Message( text = i18n_catalog.i18nc("@info:status", "You can now send and monitor print jobs from anywhere using your Ultimaker account."), lifetime = 30, - image_source = QUrl.fromLocalFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", - "resources", "svg", "cloud-flow-completed.svg")), + image_source = QUrl.fromLocalFile(os.path.join( + PluginRegistry.getPluginDirectory(), + "UM3NetworkPrinting", "resources", "svg", "cloud-flow-completed.svg" + )), image_caption = i18n_catalog.i18nc("@info:status", "Connected!") ) # Don't show the review connection link if we're not on the local network