MonitorPrintJobPreview.qml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.0
  5. import UM 1.3 as UM
  6. // TODO: Documentation!
  7. Item
  8. {
  9. id: printJobPreview
  10. property var printJob: null
  11. property var size: 256
  12. width: size
  13. height: size
  14. // Actual content
  15. Image
  16. {
  17. id: previewImage
  18. anchors.fill: parent
  19. opacity: printJob && printJob.state == "error" ? 0.5 : 1.0
  20. source: printJob ? printJob.previewImageUrl : ""
  21. visible: printJob
  22. }
  23. UM.RecolorImage
  24. {
  25. id: ultiBotImage
  26. anchors.centerIn: printJobPreview
  27. color: UM.Theme.getColor("monitor_placeholder_image")
  28. height: printJobPreview.height
  29. source: "../svg/ultibot.svg"
  30. sourceSize
  31. {
  32. height: height
  33. width: width
  34. }
  35. /* Since print jobs ALWAYS have an image url, we have to check if that image URL errors or
  36. not in order to determine if we show the placeholder (ultibot) image instead. */
  37. visible: printJob && previewImage.status == Image.Error
  38. width: printJobPreview.width
  39. }
  40. UM.RecolorImage
  41. {
  42. id: statusImage
  43. anchors.centerIn: printJobPreview
  44. color: UM.Theme.getColor("monitor_image_overlay")
  45. height: 0.5 * printJobPreview.height
  46. source: printJob && printJob.state == "error" ? "../svg/aborted-icon.svg" : ""
  47. sourceSize
  48. {
  49. height: height
  50. width: width
  51. }
  52. visible: source != ""
  53. width: 0.5 * printJobPreview.width
  54. }
  55. }