MonitorPrintJobPreview.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 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. Rectangle
  15. {
  16. anchors.fill: parent
  17. color: printJob ? "transparent" : UM.Theme.getColor("monitor_skeleton_loading")
  18. radius: 8 // TODO: Theme!
  19. Image
  20. {
  21. id: previewImage
  22. anchors.fill: parent
  23. opacity:
  24. {
  25. if (printJob && (printJob.state == "error" || printJob.configurationChanges.length > 0 || !printJob.isActive))
  26. {
  27. return 0.5
  28. }
  29. return 1.0
  30. }
  31. source: printJob ? printJob.previewImageUrl : ""
  32. }
  33. }
  34. UM.RecolorImage
  35. {
  36. id: ultiBotImage
  37. anchors.centerIn: printJobPreview
  38. color: UM.Theme.getColor("monitor_placeholder_image")
  39. height: printJobPreview.height
  40. source: "../svg/ultibot.svg"
  41. sourceSize
  42. {
  43. height: height
  44. width: width
  45. }
  46. /* Since print jobs ALWAYS have an image url, we have to check if that image URL errors or
  47. not in order to determine if we show the placeholder (ultibot) image instead. */
  48. visible: printJob && previewImage.status == Image.Error
  49. width: printJobPreview.width
  50. }
  51. UM.RecolorImage
  52. {
  53. id: overlayIcon
  54. anchors.centerIn: printJobPreview
  55. color: UM.Theme.getColor("monitor_image_overlay")
  56. height: 0.5 * printJobPreview.height
  57. source:
  58. {
  59. if (!printJob)
  60. {
  61. return ""
  62. }
  63. if (printJob.configurationChanges.length > 0)
  64. {
  65. return "../svg/Warning.svg"
  66. }
  67. switch(printJob.state)
  68. {
  69. case "error":
  70. return "../svg/CancelCircle.svg"
  71. case "wait_cleanup":
  72. return printJob.timeTotal > printJob.timeElapsed ? "../svg/CancelCircle.svg" : ""
  73. case "pausing":
  74. return "../svg/PauseCircle.svg"
  75. case "paused":
  76. return "../svg/PauseCircle.svg"
  77. case "resuming":
  78. return "../svg/PauseCircle.svg"
  79. default:
  80. return ""
  81. }
  82. return ""
  83. }
  84. sourceSize
  85. {
  86. height: height
  87. width: width
  88. }
  89. visible: source != ""
  90. width: 0.5 * printJobPreview.width
  91. }
  92. }