PrinterVideoStream.qml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) 2023 UltiMaker
  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 string 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. readonly property real img_scale_factor: {
  34. if (imageWidth > maximumWidth || imageHeight > maximumHeight) {
  35. return Math.min(maximumWidth / imageWidth, maximumHeight / imageHeight);
  36. }
  37. return 1.0;
  38. }
  39. width: imageWidth === 0 ? 800 * screenScaleFactor : imageWidth * img_scale_factor
  40. height: imageHeight === 0 ? 600 * screenScaleFactor : imageHeight * img_scale_factor
  41. onVisibleChanged: {
  42. if (cameraUrl === "") return;
  43. if (visible) {
  44. start();
  45. } else {
  46. stop();
  47. }
  48. }
  49. source: cameraUrl
  50. z: 1
  51. }
  52. MouseArea {
  53. anchors.fill: cameraImage;
  54. onClicked: {
  55. OutputDevice.setActiveCameraUrl("");
  56. }
  57. z: 1;
  58. }
  59. }