PrintMonitor.qml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Layouts 1.1
  5. import QtQuick.Controls 2.15
  6. import UM 1.5 as UM
  7. import Cura 1.0 as Cura
  8. import "PrinterOutput"
  9. ScrollView
  10. {
  11. id: base
  12. width: parent.width
  13. height: parent.height
  14. contentHeight: printMonitor.height
  15. ScrollBar.vertical: UM.ScrollBar
  16. {
  17. id: scrollbar
  18. parent: base.parent
  19. anchors
  20. {
  21. right: parent.right
  22. top: parent.top
  23. bottom: parent.bottom
  24. }
  25. }
  26. clip: true
  27. function showTooltip(item, position, text)
  28. {
  29. tooltip.text = text;
  30. position = item.mapToItem(base, position.x - UM.Theme.getSize("default_arrow").width, position.y);
  31. tooltip.show(position);
  32. }
  33. function hideTooltip()
  34. {
  35. tooltip.hide();
  36. }
  37. function strPadLeft(string, pad, length) {
  38. return (new Array(length + 1).join(pad) + string).slice(-length);
  39. }
  40. function getPrettyTime(time)
  41. {
  42. var hours = Math.floor(time / 3600)
  43. time -= hours * 3600
  44. var minutes = Math.floor(time / 60);
  45. time -= minutes * 60
  46. var seconds = Math.floor(time);
  47. var finalTime = strPadLeft(hours, "0", 2) + ":" + strPadLeft(minutes, "0", 2) + ":" + strPadLeft(seconds, "0", 2);
  48. return finalTime;
  49. }
  50. property var connectedDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
  51. property var activePrinter: connectedDevice != null ? connectedDevice.activePrinter : null
  52. property var activePrintJob: activePrinter != null ? activePrinter.activePrintJob: null
  53. Column
  54. {
  55. id: printMonitor
  56. UM.I18nCatalog { id: catalog; name: "cura" }
  57. width: parent.width - scrollbar.width
  58. property var extrudersModel: CuraApplication.getExtrudersModel()
  59. OutputDeviceHeader
  60. {
  61. outputDevice: connectedDevice
  62. }
  63. Rectangle
  64. {
  65. color: UM.Theme.getColor("wide_lining")
  66. width: parent.width
  67. height: childrenRect.height
  68. Flow
  69. {
  70. id: extrudersGrid
  71. spacing: UM.Theme.getSize("thick_lining").width
  72. width: parent.width
  73. Repeater
  74. {
  75. id: extrudersRepeater
  76. model: activePrinter != null ? activePrinter.extruders : null
  77. ExtruderBox
  78. {
  79. color: UM.Theme.getColor("main_background")
  80. width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : Math.round(extrudersGrid.width / 2 - UM.Theme.getSize("thick_lining").width / 2)
  81. extruderModel: modelData
  82. }
  83. }
  84. }
  85. }
  86. Rectangle
  87. {
  88. color: UM.Theme.getColor("wide_lining")
  89. width: parent.width
  90. height: UM.Theme.getSize("thick_lining").width
  91. }
  92. HeatedBedBox
  93. {
  94. visible:
  95. {
  96. if(activePrinter != null && activePrinter.bedTemperature != -1)
  97. {
  98. return true
  99. }
  100. return false
  101. }
  102. printerModel: activePrinter
  103. }
  104. UM.SettingPropertyProvider
  105. {
  106. id: bedTemperature
  107. containerStack: Cura.MachineManager.activeMachine
  108. key: "material_bed_temperature_layer_0"
  109. watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
  110. storeIndex: 0
  111. }
  112. UM.SettingPropertyProvider
  113. {
  114. id: machineExtruderCount
  115. containerStack: Cura.MachineManager.activeMachine
  116. key: "machine_extruder_count"
  117. watchedProperties: ["value"]
  118. }
  119. ManualPrinterControl
  120. {
  121. printerModel: activePrinter
  122. visible: activePrinter != null ? activePrinter.canControlManually : false
  123. }
  124. MonitorSection
  125. {
  126. label: catalog.i18nc("@label", "Active print")
  127. width: base.width
  128. visible: activePrinter != null
  129. }
  130. MonitorItem
  131. {
  132. label: catalog.i18nc("@label", "Job Name")
  133. value: activePrintJob != null ? activePrintJob.name : ""
  134. width: base.width
  135. visible: activePrinter != null
  136. }
  137. MonitorItem
  138. {
  139. label: catalog.i18nc("@label", "Printing Time")
  140. value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal) : ""
  141. width: base.width
  142. visible: activePrinter != null
  143. }
  144. MonitorItem
  145. {
  146. label: catalog.i18nc("@label", "Estimated time left")
  147. value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal - activePrintJob.timeElapsed) : ""
  148. visible:
  149. {
  150. if(activePrintJob == null)
  151. {
  152. return false
  153. }
  154. return (activePrintJob.state == "printing" ||
  155. activePrintJob.state == "resuming" ||
  156. activePrintJob.state == "pausing" ||
  157. activePrintJob.state == "paused")
  158. }
  159. width: base.width
  160. }
  161. }
  162. PrintSetupTooltip
  163. {
  164. id: tooltip
  165. }
  166. }