ExtruderBox.qml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.1
  3. import QtQuick.Controls.Styles 1.1
  4. import QtQuick.Layouts 1.1
  5. import UM 1.2 as UM
  6. import Cura 1.0 as Cura
  7. Item
  8. {
  9. property alias color: background.color
  10. property var extruderModel
  11. property var position: index
  12. //width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : Math.floor(extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2)
  13. implicitWidth: parent.width
  14. implicitHeight: UM.Theme.getSize("sidebar_extruder_box").height
  15. Rectangle
  16. {
  17. id: background
  18. anchors.fill: parent
  19. Label //Extruder name.
  20. {
  21. text: Cura.ExtruderManager.getExtruderName(position) != "" ? Cura.ExtruderManager.getExtruderName(position) : catalog.i18nc("@label", "Extruder")
  22. color: UM.Theme.getColor("text")
  23. font: UM.Theme.getFont("default")
  24. anchors.left: parent.left
  25. anchors.top: parent.top
  26. anchors.margins: UM.Theme.getSize("default_margin").width
  27. }
  28. Label //Target temperature.
  29. {
  30. id: extruderTargetTemperature
  31. text: Math.round(extruderModel.targetHotendTemperature) + "°C"
  32. //text: (connectedPrinter != null && connectedPrinter.hotendIds[index] != null && connectedPrinter.targetHotendTemperatures[index] != null) ? Math.round(connectedPrinter.targetHotendTemperatures[index]) + "°C" : ""
  33. font: UM.Theme.getFont("small")
  34. color: UM.Theme.getColor("text_inactive")
  35. anchors.right: parent.right
  36. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  37. anchors.bottom: extruderTemperature.bottom
  38. MouseArea //For tooltip.
  39. {
  40. id: extruderTargetTemperatureTooltipArea
  41. hoverEnabled: true
  42. anchors.fill: parent
  43. onHoveredChanged:
  44. {
  45. if (containsMouse)
  46. {
  47. base.showTooltip(
  48. base,
  49. {x: 0, y: extruderTargetTemperature.mapToItem(base, 0, Math.floor(-parent.height / 4)).y},
  50. catalog.i18nc("@tooltip", "The target temperature of the hotend. The hotend will heat up or cool down towards this temperature. If this is 0, the hotend heating is turned off.")
  51. );
  52. }
  53. else
  54. {
  55. base.hideTooltip();
  56. }
  57. }
  58. }
  59. }
  60. Label //Temperature indication.
  61. {
  62. id: extruderTemperature
  63. text: Math.round(extruderModel.hotendTemperature) + "°C"
  64. //text: (connectedPrinter != null && connectedPrinter.hotendIds[index] != null && connectedPrinter.hotendTemperatures[index] != null) ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : ""
  65. color: UM.Theme.getColor("text")
  66. font: UM.Theme.getFont("large")
  67. anchors.right: extruderTargetTemperature.left
  68. anchors.top: parent.top
  69. anchors.margins: UM.Theme.getSize("default_margin").width
  70. MouseArea //For tooltip.
  71. {
  72. id: extruderTemperatureTooltipArea
  73. hoverEnabled: true
  74. anchors.fill: parent
  75. onHoveredChanged:
  76. {
  77. if (containsMouse)
  78. {
  79. base.showTooltip(
  80. base,
  81. {x: 0, y: parent.mapToItem(base, 0, Math.floor(-parent.height / 4)).y},
  82. catalog.i18nc("@tooltip", "The current temperature of this extruder.")
  83. );
  84. }
  85. else
  86. {
  87. base.hideTooltip();
  88. }
  89. }
  90. }
  91. }
  92. Rectangle //Material colour indication.
  93. {
  94. id: materialColor
  95. width: Math.floor(materialName.height * 0.75)
  96. height: Math.floor(materialName.height * 0.75)
  97. radius: width / 2
  98. color: extruderModel.activeMaterial ? extruderModel.activeMaterial.color: "#00000000"
  99. border.width: UM.Theme.getSize("default_lining").width
  100. border.color: UM.Theme.getColor("lining")
  101. visible: extruderModel.activeMaterial != null
  102. anchors.left: parent.left
  103. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  104. anchors.verticalCenter: materialName.verticalCenter
  105. MouseArea //For tooltip.
  106. {
  107. id: materialColorTooltipArea
  108. hoverEnabled: true
  109. anchors.fill: parent
  110. onHoveredChanged:
  111. {
  112. if (containsMouse)
  113. {
  114. base.showTooltip(
  115. base,
  116. {x: 0, y: parent.mapToItem(base, 0, -parent.height / 2).y},
  117. catalog.i18nc("@tooltip", "The colour of the material in this extruder.")
  118. );
  119. }
  120. else
  121. {
  122. base.hideTooltip();
  123. }
  124. }
  125. }
  126. }
  127. Label //Material name.
  128. {
  129. id: materialName
  130. text: extruderModel.activeMaterial != null ? extruderModel.activeMaterial.type : ""
  131. font: UM.Theme.getFont("default")
  132. color: UM.Theme.getColor("text")
  133. anchors.left: materialColor.right
  134. anchors.bottom: parent.bottom
  135. anchors.margins: UM.Theme.getSize("default_margin").width
  136. MouseArea //For tooltip.
  137. {
  138. id: materialNameTooltipArea
  139. hoverEnabled: true
  140. anchors.fill: parent
  141. onHoveredChanged:
  142. {
  143. if (containsMouse)
  144. {
  145. base.showTooltip(
  146. base,
  147. {x: 0, y: parent.mapToItem(base, 0, 0).y},
  148. catalog.i18nc("@tooltip", "The material in this extruder.")
  149. );
  150. }
  151. else
  152. {
  153. base.hideTooltip();
  154. }
  155. }
  156. }
  157. }
  158. Label //Variant name.
  159. {
  160. id: variantName
  161. text: extruderModel.hotendID
  162. font: UM.Theme.getFont("default")
  163. color: UM.Theme.getColor("text")
  164. anchors.right: parent.right
  165. anchors.bottom: parent.bottom
  166. anchors.margins: UM.Theme.getSize("default_margin").width
  167. MouseArea //For tooltip.
  168. {
  169. id: variantNameTooltipArea
  170. hoverEnabled: true
  171. anchors.fill: parent
  172. onHoveredChanged:
  173. {
  174. if (containsMouse)
  175. {
  176. base.showTooltip(
  177. base,
  178. {x: 0, y: parent.mapToItem(base, 0, -parent.height / 4).y},
  179. catalog.i18nc("@tooltip", "The nozzle inserted in this extruder.")
  180. );
  181. }
  182. else
  183. {
  184. base.hideTooltip();
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }