PrintMonitor.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. Column
  10. {
  11. id: printMonitor
  12. property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
  13. Cura.ExtrudersModel
  14. {
  15. id: extrudersModel
  16. simpleNames: true
  17. }
  18. Item
  19. {
  20. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  21. height: childrenRect.height + UM.Theme.getSize("default_margin").height
  22. anchors.left: parent.left
  23. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  24. Label
  25. {
  26. text: printerConnected ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.")
  27. color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  28. font: UM.Theme.getFont("default")
  29. wrapMode: Text.WordWrap
  30. width: parent.width
  31. }
  32. }
  33. Loader
  34. {
  35. sourceComponent: monitorSection
  36. property string label: catalog.i18nc("@label", "Temperatures")
  37. }
  38. Repeater
  39. {
  40. model: machineExtruderCount.properties.value
  41. delegate: Loader
  42. {
  43. sourceComponent: monitorItem
  44. property string label: machineExtruderCount.properties.value > 1 ? extrudersModel.getItem(index).name : catalog.i18nc("@label", "Hotend")
  45. property string value: printerConnected ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : ""
  46. }
  47. }
  48. Repeater
  49. {
  50. model: machineHeatedBed.properties.value == "True" ? 1 : 0
  51. delegate: Loader
  52. {
  53. sourceComponent: monitorItem
  54. property string label: catalog.i18nc("@label", "Build plate")
  55. property string value: printerConnected ? Math.round(connectedPrinter.bedTemperature) + "°C" : ""
  56. }
  57. }
  58. Loader
  59. {
  60. sourceComponent: monitorSection
  61. property string label: catalog.i18nc("@label", "Active print")
  62. }
  63. Loader
  64. {
  65. sourceComponent: monitorItem
  66. property string label: catalog.i18nc("@label", "Job Name")
  67. property string value: printerConnected ? connectedPrinter.jobName : ""
  68. }
  69. Loader
  70. {
  71. sourceComponent: monitorItem
  72. property string label: catalog.i18nc("@label", "Printing Time")
  73. property string value: printerConnected ? getPrettyTime(connectedPrinter.timeTotal) : ""
  74. }
  75. Loader
  76. {
  77. sourceComponent: monitorItem
  78. property string label: catalog.i18nc("@label", "Estimated time left")
  79. property string value: printerConnected ? getPrettyTime(connectedPrinter.timeTotal - connectedPrinter.timeElapsed) : ""
  80. }
  81. Component
  82. {
  83. id: monitorItem
  84. Row
  85. {
  86. height: UM.Theme.getSize("setting_control").height
  87. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  88. anchors.left: parent.left
  89. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  90. Label
  91. {
  92. width: parent.width * 0.4
  93. anchors.verticalCenter: parent.verticalCenter
  94. text: label
  95. color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  96. font: UM.Theme.getFont("default")
  97. elide: Text.ElideRight
  98. }
  99. Label
  100. {
  101. width: parent.width * 0.6
  102. anchors.verticalCenter: parent.verticalCenter
  103. text: value
  104. color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  105. font: UM.Theme.getFont("default")
  106. elide: Text.ElideRight
  107. }
  108. }
  109. }
  110. Component
  111. {
  112. id: monitorSection
  113. Rectangle
  114. {
  115. color: UM.Theme.getColor("setting_category")
  116. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  117. height: UM.Theme.getSize("section").height
  118. Label
  119. {
  120. anchors.verticalCenter: parent.verticalCenter
  121. anchors.left: parent.left
  122. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  123. text: label
  124. font: UM.Theme.getFont("setting_category")
  125. color: UM.Theme.getColor("setting_category_text")
  126. }
  127. }
  128. }
  129. }