diff --git a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py index 8de18443a7..5597e03d44 100644 --- a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py @@ -22,7 +22,7 @@ from .LegacyUM3PrinterOutputController import LegacyUM3PrinterOutputController from time import time import json - +import os i18n_catalog = i18nCatalog("cura") @@ -72,6 +72,9 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): self.setIconName("print") + self._monitor_view_qml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "MonitorItem.qml") + + self._output_controller = LegacyUM3PrinterOutputController(self) def _onAuthenticationStateChanged(self): diff --git a/plugins/UM3NetworkPrinting/MonitorItem.qml b/plugins/UM3NetworkPrinting/MonitorItem.qml index f69df41dd4..09e427ff6f 100644 --- a/plugins/UM3NetworkPrinting/MonitorItem.qml +++ b/plugins/UM3NetworkPrinting/MonitorItem.qml @@ -9,35 +9,32 @@ Component Image { id: cameraImage - property bool proportionalHeight: - { - if(sourceSize.height == 0 || maximumHeight == 0) - { - return true; - } - return (sourceSize.width / sourceSize.height) > (maximumWidth / maximumHeight); - } - property real _width: Math.floor(Math.min(maximumWidth, sourceSize.width)) - property real _height: Math.floor(Math.min(maximumHeight, sourceSize.height)) - width: proportionalHeight ? _width : Math.floor(sourceSize.width * _height / sourceSize.height) - height: !proportionalHeight ? _height : Math.floor(sourceSize.height * _width / sourceSize.width) + width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth) + height: Math.floor((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width) anchors.horizontalCenter: parent.horizontalCenter - + anchors.verticalCenter: parent.verticalCenter + z: 1 onVisibleChanged: { if(visible) { - OutputDevice.startCamera() + if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null) + { + OutputDevice.activePrinter.camera.start() + } } else { - OutputDevice.stopCamera() + if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null) + { + OutputDevice.activePrinter.camera.stop() + } } } source: { - if(OutputDevice.cameraImage) + if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null && OutputDevice.activePrinter.camera.latestImage) { - return OutputDevice.cameraImage; + return OutputDevice.activePrinter.camera.latestImage; } return ""; }