MonitorPrintJobPreview.qml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.ColorImage
  35. {
  36. id: ultiBotImage
  37. anchors.centerIn: printJobPreview
  38. color: UM.Theme.getColor("monitor_placeholder_image")
  39. height: printJobPreview.height
  40. source: Qt.resolvedUrl("../svg/ultibot.svg")
  41. /* Since print jobs ALWAYS have an image url, we have to check if that image URL errors or
  42. not in order to determine if we show the placeholder (ultibot) image instead. */
  43. visible: printJob && previewImage.status == Image.Error
  44. width: printJobPreview.width
  45. }
  46. UM.ColorImage
  47. {
  48. id: overlayIcon
  49. anchors.centerIn: printJobPreview
  50. color: UM.Theme.getColor("monitor_image_overlay")
  51. height: 0.5 * printJobPreview.height
  52. source:
  53. {
  54. if (!printJob)
  55. {
  56. return ""
  57. }
  58. if (printJob.configurationChanges.length > 0)
  59. {
  60. return "../svg/Warning.svg"
  61. }
  62. switch(printJob.state)
  63. {
  64. case "error":
  65. return "../svg/CancelCircle.svg"
  66. case "wait_cleanup":
  67. return printJob.timeTotal > printJob.timeElapsed ? "../svg/CancelCircle.svg" : ""
  68. case "pausing":
  69. return "../svg/PauseCircle.svg"
  70. case "paused":
  71. return "../svg/PauseCircle.svg"
  72. case "resuming":
  73. return "../svg/PauseCircle.svg"
  74. default:
  75. return ""
  76. }
  77. return ""
  78. }
  79. visible: source != ""
  80. width: 0.5 * printJobPreview.width
  81. }
  82. }