MonitorPrintJobProgressBar.qml 4.3 KB

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