PrinterVideoStream.qml 1.7 KB

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