PrintMonitor.qml 5.3 KB

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