PrinterVideoStream.qml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. Item {
  7. property var cameraUrl: "";
  8. Rectangle {
  9. anchors.fill:parent;
  10. color: UM.Theme.getColor("viewport_overlay");
  11. opacity: 0.5;
  12. }
  13. MouseArea {
  14. anchors.fill: parent;
  15. onClicked: OutputDevice.setActiveCameraUrl("");
  16. z: 0;
  17. }
  18. CameraButton {
  19. id: closeCameraButton;
  20. anchors {
  21. right: cameraImage.right
  22. rightMargin: UM.Theme.getSize("default_margin").width
  23. top: cameraImage.top
  24. topMargin: UM.Theme.getSize("default_margin").height
  25. }
  26. iconSource: UM.Theme.getIcon("Cancel");
  27. z: 999;
  28. }
  29. Cura.NetworkMJPGImage {
  30. id: cameraImage
  31. anchors.horizontalCenter: parent.horizontalCenter;
  32. anchors.verticalCenter: parent.verticalCenter;
  33. height: Math.round((imageHeight === 0 ? 600 * screenScaleFactor : imageHeight) * width / imageWidth);
  34. onVisibleChanged: {
  35. if (visible) {
  36. if (cameraUrl != "") {
  37. start();
  38. }
  39. } else {
  40. if (cameraUrl != "") {
  41. stop();
  42. }
  43. }
  44. }
  45. source: cameraUrl
  46. width: Math.min(imageWidth === 0 ? 800 * screenScaleFactor : imageWidth, maximumWidth);
  47. z: 1
  48. }
  49. MouseArea {
  50. anchors.fill: cameraImage;
  51. onClicked: {
  52. OutputDevice.setActiveCameraUrl("");
  53. }
  54. z: 1;
  55. }
  56. }