MonitorPrintJobProgressBar.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.3
  4. import UM 1.5 as UM
  5. /**
  6. * NOTE: For most labels, a fixed height with vertical alignment is used to make
  7. * layouts more deterministic (like the fixed-size textboxes used in original
  8. * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
  9. * with '// FIXED-LINE-HEIGHT:'.
  10. */
  11. Item
  12. {
  13. id: base
  14. // The print job which all other information is derived from
  15. property var printJob: null
  16. width: childrenRect.width
  17. height: percentLabel.height
  18. UM.ProgressBar
  19. {
  20. id: progressBar
  21. anchors
  22. {
  23. verticalCenter: parent.verticalCenter
  24. left: parent.left
  25. }
  26. value: printJob ? printJob.progress : 0
  27. width: UM.Theme.getSize("monitor_progress_bar").width
  28. }
  29. UM.Label
  30. {
  31. id: percentLabel
  32. anchors
  33. {
  34. left: progressBar.right
  35. leftMargin: UM.Theme.getSize("default_margin").width
  36. }
  37. text: printJob ? Math.round(printJob.progress * 100) + "%" : "0%"
  38. color: printJob && printJob.isActive ? UM.Theme.getColor("text") : UM.Theme.getColor("monitor_text_disabled")
  39. width: contentWidth
  40. wrapMode: Text.NoWrap
  41. }
  42. UM.Label
  43. {
  44. id: statusLabel
  45. anchors
  46. {
  47. left: percentLabel.right
  48. leftMargin: UM.Theme.getSize("default_margin").width
  49. }
  50. wrapMode: Text.NoWrap
  51. text:
  52. {
  53. if (!printJob)
  54. {
  55. return "";
  56. }
  57. switch (printJob.state)
  58. {
  59. case "wait_cleanup":
  60. // This hack was removed previously. Then we found out that we don't get back 'aborted_wait_cleanup'
  61. // for the UM2+C it seems. Will communicate this to other teams, in the mean time, put this back.
  62. if (printJob.timeTotal > printJob.timeElapsed)
  63. {
  64. return catalog.i18nc("@label:status", "Aborted");
  65. }
  66. return catalog.i18nc("@label:status", "Finished");
  67. case "finished":
  68. return catalog.i18nc("@label:status", "Finished");
  69. case "sent_to_printer":
  70. return catalog.i18nc("@label:status", "Preparing...");
  71. case "pre_print":
  72. return catalog.i18nc("@label:status", "Preparing...");
  73. case "aborting": // NOTE: Doesn't exist but maybe should someday
  74. return catalog.i18nc("@label:status", "Aborting...");
  75. case "aborted": // NOTE: Unused, see above
  76. return catalog.i18nc("@label:status", "Aborted");
  77. case "aborted_post_print":
  78. return catalog.i18nc("@label:status", "Aborted");
  79. case "aborted_wait_user_action":
  80. return catalog.i18nc("@label:status", "Aborted");
  81. case "aborted_wait_cleanup":
  82. return catalog.i18nc("@label:status", "Aborted");
  83. case "failed":
  84. return catalog.i18nc("@label:status", "Failed");
  85. case "failed_post_print":
  86. return catalog.i18nc("@label:status", "Failed");
  87. case "failed_wait_user_action":
  88. return catalog.i18nc("@label:status", "Failed");
  89. case "failed_wait_cleanup":
  90. return catalog.i18nc("@label:status", "Failed");
  91. case "pausing":
  92. return catalog.i18nc("@label:status", "Pausing...");
  93. case "paused":
  94. return catalog.i18nc("@label:status", "Paused");
  95. case "resuming":
  96. return catalog.i18nc("@label:status", "Resuming...");
  97. case "queued":
  98. return catalog.i18nc("@label:status", "Action required");
  99. default:
  100. return catalog.i18nc("@label:status", "Finishes %1 at %2").arg(OutputDevice.getDateCompleted(printJob.timeRemaining)).arg(OutputDevice.getTimeCompleted(printJob.timeRemaining));
  101. }
  102. }
  103. width: contentWidth
  104. }
  105. }