PrintMonitor.qml 5.2 KB

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