MonitorItem.qml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import QtQuick 2.2
  2. import UM 1.3 as UM
  3. import Cura 1.0 as Cura
  4. Component
  5. {
  6. Image
  7. {
  8. id: cameraImage
  9. width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth)
  10. height: Math.floor((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width)
  11. anchors.horizontalCenter: parent.horizontalCenter
  12. anchors.verticalCenter: parent.verticalCenter
  13. z: 1
  14. onVisibleChanged:
  15. {
  16. if(visible)
  17. {
  18. if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null)
  19. {
  20. OutputDevice.activePrinter.camera.start()
  21. }
  22. } else
  23. {
  24. if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null)
  25. {
  26. OutputDevice.activePrinter.camera.stop()
  27. }
  28. }
  29. }
  30. source:
  31. {
  32. if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null && OutputDevice.activePrinter.camera.latestImage)
  33. {
  34. return OutputDevice.activePrinter.camera.latestImage;
  35. }
  36. return "";
  37. }
  38. }
  39. }