From 3116ff829ccc8f0b422b7e7bfd4d04e7f80012a6 Mon Sep 17 00:00:00 2001 From: alekseisasin Date: Tue, 15 Aug 2017 14:45:34 +0200 Subject: [PATCH] Merge pull request #2200 from fieldOfView/fix_monitoritem_size Adapt camera image to available space --- cura/PrinterOutputDevice.py | 3 +++ plugins/UM3NetworkPrinting/MonitorItem.qml | 15 +++++++++++++-- resources/qml/Cura.qml | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index bf013e4b9f..7a0a91068c 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -144,6 +144,9 @@ class PrinterOutputDevice(QObject, OutputDevice): return self._control_item def _createControlViewFromQML(self): + if not self._control_view_qml_path: + return + path = QUrl.fromLocalFile(self._control_view_qml_path) # Because of garbage collection we need to keep this referenced by python. diff --git a/plugins/UM3NetworkPrinting/MonitorItem.qml b/plugins/UM3NetworkPrinting/MonitorItem.qml index d3803ea877..ffa2e8c85d 100644 --- a/plugins/UM3NetworkPrinting/MonitorItem.qml +++ b/plugins/UM3NetworkPrinting/MonitorItem.qml @@ -9,9 +9,20 @@ Component Image { id: cameraImage - width: sourceSize.width - height: sourceSize.height * width / sourceSize.width + property bool proportionalHeight: + { + if(sourceSize.height == 0 || maximumHeight == 0) + { + return true; + } + return (sourceSize.width / sourceSize.height) > (maximumWidth / maximumHeight); + } + property real _width: Math.min(maximumWidth, sourceSize.width) + property real _height: Math.min(maximumHeight, sourceSize.height) + width: proportionalHeight ? _width : sourceSize.width * _height / sourceSize.height + height: !proportionalHeight ? _height : sourceSize.height * _width / sourceSize.width anchors.horizontalCenter: parent.horizontalCenter + onVisibleChanged: { if(visible) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 3aaf63a2fd..85b17e28a2 100755 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -466,6 +466,9 @@ UM.MainWindow anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2 + anchors.verticalCenterOffset: UM.Theme.getSize("sidebar_header").height / 2 + property real maximumWidth: viewportOverlay.width + property real maximumHeight: viewportOverlay.height } UM.MessageStack