PrintMonitor.qml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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"
  109. watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
  110. storeIndex: 0
  111. property var resolve: Cura.MachineManager.activeStack != Cura.MachineManager.activeMachine ? properties.resolve : "None"
  112. }
  113. UM.SettingPropertyProvider
  114. {
  115. id: machineExtruderCount
  116. containerStack: Cura.MachineManager.activeMachine
  117. key: "machine_extruder_count"
  118. watchedProperties: ["value"]
  119. }
  120. ManualPrinterControl
  121. {
  122. printerModel: activePrinter
  123. visible: activePrinter != null ? activePrinter.canControlManually : false
  124. }
  125. MonitorSection
  126. {
  127. label: catalog.i18nc("@label", "Active print")
  128. width: base.width
  129. visible: activePrinter != null
  130. }
  131. MonitorItem
  132. {
  133. label: catalog.i18nc("@label", "Job Name")
  134. value: activePrintJob != null ? activePrintJob.name : ""
  135. width: base.width
  136. visible: activePrinter != null
  137. }
  138. MonitorItem
  139. {
  140. label: catalog.i18nc("@label", "Printing Time")
  141. value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal) : ""
  142. width: base.width
  143. visible: activePrinter != null
  144. }
  145. MonitorItem
  146. {
  147. label: catalog.i18nc("@label", "Estimated time left")
  148. value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal - activePrintJob.timeElapsed) : ""
  149. visible:
  150. {
  151. if(activePrintJob == null)
  152. {
  153. return false
  154. }
  155. return (activePrintJob.state == "printing" ||
  156. activePrintJob.state == "resuming" ||
  157. activePrintJob.state == "pausing" ||
  158. activePrintJob.state == "paused")
  159. }
  160. width: base.width
  161. }
  162. }
  163. PrintSetupTooltip
  164. {
  165. id: tooltip
  166. }
  167. }