PrintMonitor.qml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. Item
  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. property var extrudersModel: CuraApplication.getExtrudersModel()
  49. OutputDeviceHeader
  50. {
  51. outputDevice: connectedDevice
  52. }
  53. Rectangle
  54. {
  55. color: UM.Theme.getColor("wide_lining")
  56. width: parent.width
  57. height: childrenRect.height
  58. Flow
  59. {
  60. id: extrudersGrid
  61. spacing: UM.Theme.getSize("thick_lining").width
  62. width: parent.width
  63. Repeater
  64. {
  65. id: extrudersRepeater
  66. model: activePrinter != null ? activePrinter.extruders : null
  67. ExtruderBox
  68. {
  69. color: UM.Theme.getColor("main_background")
  70. width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : Math.round(extrudersGrid.width / 2 - UM.Theme.getSize("thick_lining").width / 2)
  71. extruderModel: modelData
  72. }
  73. }
  74. }
  75. }
  76. Rectangle
  77. {
  78. color: UM.Theme.getColor("wide_lining")
  79. width: parent.width
  80. height: UM.Theme.getSize("thick_lining").width
  81. }
  82. HeatedBedBox
  83. {
  84. visible:
  85. {
  86. if(activePrinter != null && activePrinter.bedTemperature != -1)
  87. {
  88. return true
  89. }
  90. return false
  91. }
  92. printerModel: activePrinter
  93. }
  94. UM.SettingPropertyProvider
  95. {
  96. id: bedTemperature
  97. containerStack: Cura.MachineManager.activeMachine
  98. key: "material_bed_temperature"
  99. watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
  100. storeIndex: 0
  101. property var resolve: Cura.MachineManager.activeStack != Cura.MachineManager.activeMachine ? properties.resolve : "None"
  102. }
  103. UM.SettingPropertyProvider
  104. {
  105. id: machineExtruderCount
  106. containerStack: Cura.MachineManager.activeMachine
  107. key: "machine_extruder_count"
  108. watchedProperties: ["value"]
  109. }
  110. ManualPrinterControl
  111. {
  112. printerModel: activePrinter
  113. visible: activePrinter != null ? activePrinter.canControlManually : false
  114. }
  115. MonitorSection
  116. {
  117. label: catalog.i18nc("@label", "Active print")
  118. width: base.width
  119. visible: activePrinter != null
  120. }
  121. MonitorItem
  122. {
  123. label: catalog.i18nc("@label", "Job Name")
  124. value: activePrintJob != null ? activePrintJob.name : ""
  125. width: base.width
  126. visible: activePrinter != null
  127. }
  128. MonitorItem
  129. {
  130. label: catalog.i18nc("@label", "Printing Time")
  131. value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal) : ""
  132. width: base.width
  133. visible: activePrinter != null
  134. }
  135. MonitorItem
  136. {
  137. label: catalog.i18nc("@label", "Estimated time left")
  138. value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal - activePrintJob.timeElapsed) : ""
  139. visible:
  140. {
  141. if(activePrintJob == null)
  142. {
  143. return false
  144. }
  145. return (activePrintJob.state == "printing" ||
  146. activePrintJob.state == "resuming" ||
  147. activePrintJob.state == "pausing" ||
  148. activePrintJob.state == "paused")
  149. }
  150. width: base.width
  151. }
  152. }
  153. }