diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index b8a5da6fb9..e23efc0f5a 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -132,7 +132,7 @@ class PrinterOutputDevice(QObject, OutputDevice): return self._monitor_item def _createMonitorViewFromQML(self): - path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._monitor_view_qml_path)) + path = QUrl.fromLocalFile(self._monitor_view_qml_path) # Because of garbage collection we need to keep this referenced by python. self._monitor_component = QQmlComponent(Application.getInstance()._engine, path) diff --git a/plugins/UM3NetworkPrinting/MonitorItem.qml b/plugins/UM3NetworkPrinting/MonitorItem.qml new file mode 100644 index 0000000000..fa7bb84de3 --- /dev/null +++ b/plugins/UM3NetworkPrinting/MonitorItem.qml @@ -0,0 +1,40 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Layouts 1.1 +import QtQuick.Dialogs 1.1 + +import UM 1.3 as UM +import Cura 1.0 as Cura + +Component +{ + Image + { + id: cameraImage + width: sourceSize.width + height: sourceSize.height * width / sourceSize.width + anchors.horizontalCenter: parent.horizontalCenter + //anchors.verticalCenter: parent.verticalCenter + //anchors.horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2 + //visible: base.monitoringPrint + onVisibleChanged: + { + if(visible) + { + OutputDevice.startCamera() + } else + { + OutputDevice.stopCamera() + } + } + source: + { + if(OutputDevice.cameraImage) + { + return OutputDevice.cameraImage; + } + return ""; + } + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index afeaadbb7a..18bf22d18d 100755 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -178,6 +178,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._last_command = "" self._compressing_print = False + self._monitor_view_qml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "MonitorItem.qml") printer_type = self._properties.get(b"machine", b"").decode("utf-8") if printer_type.startswith("9511"): diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 0a48725011..339dac3382 100755 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -400,41 +400,15 @@ UM.MainWindow } } - Image + Loader { - id: cameraImage - width: Math.min(viewportOverlay.width, sourceSize.width) - height: sourceSize.height * width / sourceSize.width + sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem: null + visible: base.monitoringPrint anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2 - visible: base.monitoringPrint - onVisibleChanged: - { - if(Cura.MachineManager.printerOutputDevices.length == 0 ) - { - return; - } - if(visible) - { - Cura.MachineManager.printerOutputDevices[0].startCamera() - } else - { - Cura.MachineManager.printerOutputDevices[0].stopCamera() - } - } - source: - { - if(!base.monitoringPrint) - { - return ""; - } - if(Cura.MachineManager.printerOutputDevices.length > 0 && Cura.MachineManager.printerOutputDevices[0].cameraImage) - { - return Cura.MachineManager.printerOutputDevices[0].cameraImage; - } - return ""; - } + + } UM.MessageStack