MonitorItem.qml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import UM 1.3 as UM
  5. import Cura 1.0 as Cura
  6. Component {
  7. Item {
  8. height: maximumHeight;
  9. width: maximumWidth;
  10. Cura.NetworkMJPGImage {
  11. id: cameraImage;
  12. anchors {
  13. horizontalCenter: parent.horizontalCenter;
  14. verticalCenter: parent.verticalCenter;
  15. }
  16. Component.onCompleted: {
  17. if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.cameraUrl != null) {
  18. cameraImage.start();
  19. }
  20. }
  21. height: Math.floor((imageHeight === 0 ? 600 * screenScaleFactor : imageHeight) * width / imageWidth);
  22. onVisibleChanged: {
  23. if (visible) {
  24. if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.cameraUrl != null) {
  25. cameraImage.start();
  26. }
  27. } else {
  28. if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.cameraUrl != null) {
  29. cameraImage.stop();
  30. }
  31. }
  32. }
  33. source: {
  34. if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.cameraUrl != null) {
  35. return OutputDevice.activePrinter.cameraUrl;
  36. }
  37. }
  38. width: Math.min(imageWidth === 0 ? 800 * screenScaleFactor : imageWidth, maximumWidth);
  39. z: 1;
  40. }
  41. }
  42. }