PrinterVideoStream.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.4
  3. import QtQuick.Controls.Styles 1.4
  4. import UM 1.3 as UM
  5. Item
  6. {
  7. property var camera: null
  8. Rectangle
  9. {
  10. anchors.fill:parent
  11. color: UM.Theme.getColor("viewport_overlay")
  12. opacity: 0.5
  13. }
  14. MouseArea
  15. {
  16. anchors.fill: parent
  17. onClicked: OutputDevice.setActiveCamera(null)
  18. z: 0
  19. }
  20. CameraButton
  21. {
  22. id: closeCameraButton
  23. iconSource: UM.Theme.getIcon("cross1")
  24. anchors
  25. {
  26. top: cameraImage.top
  27. topMargin: UM.Theme.getSize("default_margin").height
  28. right: cameraImage.right
  29. rightMargin: UM.Theme.getSize("default_margin").width
  30. }
  31. z: 999
  32. }
  33. // Button
  34. // {
  35. // id: backButton
  36. // // TODO: Hardcoded sizes
  37. // width: 20 * screenScaleFactor
  38. // height: 20 * screenScaleFactor
  39. // onClicked: OutputDevice.setActiveCamera(null)
  40. // style: ButtonStyle
  41. // {
  42. // label: Item
  43. // {
  44. // UM.RecolorImage
  45. // {
  46. // anchors.verticalCenter: parent.verticalCenter
  47. // anchors.horizontalCenter: parent.horizontalCenter
  48. // width: control.width
  49. // height: control.height
  50. // sourceSize.width: width
  51. // sourceSize.height: width
  52. // source: UM.Theme.getIcon("cross1")
  53. // }
  54. // }
  55. // background: Item {}
  56. // }
  57. // }
  58. Image
  59. {
  60. id: cameraImage
  61. width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth)
  62. height: Math.round((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width)
  63. anchors.horizontalCenter: parent.horizontalCenter
  64. anchors.verticalCenter: parent.verticalCenter
  65. z: 1
  66. onVisibleChanged:
  67. {
  68. if(visible)
  69. {
  70. if(camera != null)
  71. {
  72. camera.start()
  73. }
  74. } else
  75. {
  76. if(camera != null)
  77. {
  78. camera.stop()
  79. }
  80. }
  81. }
  82. source:
  83. {
  84. if(camera != null && camera.latestImage != null)
  85. {
  86. return camera.latestImage;
  87. }
  88. return "";
  89. }
  90. }
  91. MouseArea
  92. {
  93. anchors.fill: cameraImage
  94. onClicked:
  95. {
  96. OutputDevice.setActiveCamera(null)
  97. }
  98. z: 1
  99. }
  100. }