PrintMonitor.qml 5.3 KB

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