PrinterVideoStream.qml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. Button
  21. {
  22. id: backButton
  23. anchors.bottom: cameraImage.top
  24. anchors.bottomMargin: UM.Theme.getSize("default_margin").width
  25. anchors.right: cameraImage.right
  26. // TODO: Hardcoded sizes
  27. width: 20 * screenScaleFactor
  28. height: 20 * screenScaleFactor
  29. onClicked: OutputDevice.setActiveCamera(null)
  30. style: ButtonStyle
  31. {
  32. label: Item
  33. {
  34. UM.RecolorImage
  35. {
  36. anchors.verticalCenter: parent.verticalCenter
  37. anchors.horizontalCenter: parent.horizontalCenter
  38. width: control.width
  39. height: control.height
  40. sourceSize.width: width
  41. sourceSize.height: width
  42. source: UM.Theme.getIcon("cross1")
  43. }
  44. }
  45. background: Item {}
  46. }
  47. }
  48. Image
  49. {
  50. id: cameraImage
  51. width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth)
  52. height: Math.round((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width)
  53. anchors.horizontalCenter: parent.horizontalCenter
  54. anchors.verticalCenter: parent.verticalCenter
  55. z: 1
  56. onVisibleChanged:
  57. {
  58. if(visible)
  59. {
  60. if(camera != null)
  61. {
  62. camera.start()
  63. }
  64. } else
  65. {
  66. if(camera != null)
  67. {
  68. camera.stop()
  69. }
  70. }
  71. }
  72. source:
  73. {
  74. if(camera != null && camera.latestImage != null)
  75. {
  76. return camera.latestImage;
  77. }
  78. return "";
  79. }
  80. }
  81. MouseArea
  82. {
  83. anchors.fill: cameraImage
  84. onClicked:
  85. {
  86. OutputDevice.setActiveCamera(null)
  87. }
  88. z: 1
  89. }
  90. }