MonitorPrintJobProgressBar.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright (c) 2018 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: 18 * screenScaleFactor // TODO: Theme!
  20. UM.ProgressBar
  21. {
  22. id: progressBar
  23. anchors
  24. {
  25. verticalCenter: parent.verticalCenter
  26. }
  27. value: printJob ? printJob.progress : 0
  28. }
  29. Label
  30. {
  31. id: percentLabel
  32. anchors
  33. {
  34. left: progressBar.right
  35. leftMargin: 18 * screenScaleFactor // TODO: Theme!
  36. }
  37. text: printJob ? Math.round(printJob.progress * 100) + "%" : "0%"
  38. color: printJob && printJob.isActive ? UM.Theme.getColor("monitor_text_primary") : UM.Theme.getColor("monitor_text_disabled")
  39. width: contentWidth
  40. font: UM.Theme.getFont("medium") // 14pt, regular
  41. // FIXED-LINE-HEIGHT:
  42. height: 18 * screenScaleFactor // TODO: Theme!
  43. verticalAlignment: Text.AlignVCenter
  44. }
  45. Label
  46. {
  47. id: statusLabel
  48. anchors
  49. {
  50. left: percentLabel.right
  51. leftMargin: 18 * screenScaleFactor // TODO: Theme!
  52. }
  53. color: UM.Theme.getColor("monitor_text_primary")
  54. font: UM.Theme.getFont("medium") // 14pt, regular
  55. text:
  56. {
  57. if (!printJob)
  58. {
  59. return ""
  60. }
  61. switch (printJob.state)
  62. {
  63. case "wait_cleanup":
  64. if (printJob.timeTotal > printJob.timeElapsed)
  65. {
  66. return catalog.i18nc("@label:status", "Aborted")
  67. }
  68. return catalog.i18nc("@label:status", "Finished")
  69. case "finished":
  70. return catalog.i18nc("@label:status", "Finished")
  71. case "sent_to_printer":
  72. return catalog.i18nc("@label:status", "Preparing...")
  73. case "pre_print":
  74. return catalog.i18nc("@label:status", "Preparing...")
  75. case "aborting": // NOTE: Doesn't exist but maybe should someday
  76. return catalog.i18nc("@label:status", "Aborting...")
  77. case "aborted": // NOTE: Unused, see above
  78. return catalog.i18nc("@label:status", "Aborted")
  79. case "pausing":
  80. return catalog.i18nc("@label:status", "Pausing...")
  81. case "paused":
  82. return catalog.i18nc("@label:status", "Paused")
  83. case "resuming":
  84. return catalog.i18nc("@label:status", "Resuming...")
  85. case "queued":
  86. return catalog.i18nc("@label:status", "Action required")
  87. default:
  88. return catalog.i18nc("@label:status", "Finishes %1 at %2".arg(OutputDevice.getDateCompleted( printJob.timeRemaining )).arg(OutputDevice.getTimeCompleted( printJob.timeRemaining )))
  89. }
  90. }
  91. width: contentWidth
  92. // FIXED-LINE-HEIGHT:
  93. height: 18 * screenScaleFactor // TODO: Theme!
  94. verticalAlignment: Text.AlignVCenter
  95. }
  96. }