MonitorPrintJobProgressBar.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 QtQuick.Controls.Styles 1.3
  5. import QtQuick.Controls 1.4
  6. import UM 1.3 as UM
  7. /**
  8. * NOTE: For most labels, a fixed height with vertical alignment is used to make
  9. * layouts more deterministic (like the fixed-size textboxes used in original
  10. * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
  11. * with '// FIXED-LINE-HEIGHT:'.
  12. */
  13. Item
  14. {
  15. id: base
  16. // The print job which all other information is dervied from
  17. property var printJob: null
  18. width: childrenRect.width
  19. height: UM.Theme.getSize("monitor_text_line").height
  20. UM.ProgressBar
  21. {
  22. id: progressBar
  23. anchors
  24. {
  25. verticalCenter: parent.verticalCenter
  26. left: parent.left
  27. }
  28. value: printJob ? printJob.progress : 0
  29. width: UM.Theme.getSize("monitor_progress_bar").width
  30. }
  31. Label
  32. {
  33. id: percentLabel
  34. anchors
  35. {
  36. left: progressBar.right
  37. leftMargin: UM.Theme.getSize("monitor_margin").width
  38. verticalCenter: parent.verticalCenter
  39. }
  40. text: printJob ? Math.round(printJob.progress * 100) + "%" : "0%"
  41. color: printJob && printJob.isActive ? UM.Theme.getColor("text") : UM.Theme.getColor("monitor_text_disabled")
  42. width: contentWidth
  43. font: UM.Theme.getFont("default") // 12pt, regular
  44. // FIXED-LINE-HEIGHT:
  45. height: UM.Theme.getSize("monitor_text_line").height
  46. verticalAlignment: Text.AlignVCenter
  47. renderType: Text.NativeRendering
  48. }
  49. Label
  50. {
  51. id: statusLabel
  52. anchors
  53. {
  54. left: percentLabel.right
  55. leftMargin: UM.Theme.getSize("monitor_margin").width
  56. verticalCenter: parent.verticalCenter
  57. }
  58. color: UM.Theme.getColor("text")
  59. font: UM.Theme.getFont("default")
  60. text:
  61. {
  62. if (!printJob)
  63. {
  64. return "";
  65. }
  66. switch (printJob.state)
  67. {
  68. case "wait_cleanup":
  69. if (printJob.timeTotal > printJob.timeElapsed)
  70. {
  71. return catalog.i18nc("@label:status", "Aborted");
  72. }
  73. return catalog.i18nc("@label:status", "Finished");
  74. case "finished":
  75. return catalog.i18nc("@label:status", "Finished");
  76. case "sent_to_printer":
  77. return catalog.i18nc("@label:status", "Preparing...");
  78. case "pre_print":
  79. return catalog.i18nc("@label:status", "Preparing...");
  80. case "aborting": // NOTE: Doesn't exist but maybe should someday
  81. return catalog.i18nc("@label:status", "Aborting...");
  82. case "aborted": // NOTE: Unused, see above
  83. return catalog.i18nc("@label:status", "Aborted");
  84. case "pausing":
  85. return catalog.i18nc("@label:status", "Pausing...");
  86. case "paused":
  87. return catalog.i18nc("@label:status", "Paused");
  88. case "resuming":
  89. return catalog.i18nc("@label:status", "Resuming...");
  90. case "queued":
  91. return catalog.i18nc("@label:status", "Action required");
  92. default:
  93. return catalog.i18nc("@label:status", "Finishes %1 at %2".arg(OutputDevice.getDateCompleted(printJob.timeRemaining)).arg(OutputDevice.getTimeCompleted(printJob.timeRemaining)));
  94. }
  95. }
  96. width: contentWidth
  97. // FIXED-LINE-HEIGHT:
  98. height: UM.Theme.getSize("monitor_text_line").height
  99. verticalAlignment: Text.AlignVCenter
  100. renderType: Text.NativeRendering
  101. }
  102. }