ExtruderIcon.qml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.11
  4. import UM 1.5 as UM
  5. Item
  6. {
  7. id: extruderIconItem
  8. implicitWidth: UM.Theme.getSize("extruder_icon").width
  9. implicitHeight: UM.Theme.getSize("extruder_icon").height
  10. property bool checked: true
  11. property color materialColor
  12. property alias textColor: extruderNumberText.color
  13. property bool extruderEnabled: true
  14. property var iconSize
  15. property string iconVariant: "medium"
  16. Item
  17. {
  18. opacity: extruderEnabled ? 1 : UM.Theme.getColor("extruder_disabled").a
  19. anchors.fill: parent
  20. layer.enabled: true // Prevent weird opacity effects.
  21. UM.ColorImage
  22. {
  23. anchors.fill: parent
  24. width: mainIcon.width
  25. height: mainIcon.height
  26. source: UM.Theme.getIcon("ExtruderColor", iconVariant)
  27. color: materialColor
  28. }
  29. UM.ColorImage
  30. {
  31. id: mainIcon
  32. anchors.fill: parent
  33. width: UM.Theme.getSize("extruder_icon").width
  34. height: UM.Theme.getSize("extruder_icon").height
  35. source: UM.Theme.getIcon("Extruder", iconVariant)
  36. color: extruderNumberText.color
  37. }
  38. UM.Label
  39. {
  40. id: extruderNumberText
  41. anchors.centerIn: parent
  42. text: index + 1
  43. font: UM.Theme.getFont("small_emphasis")
  44. width: contentWidth
  45. height: contentHeight
  46. horizontalAlignment: Text.AlignHCenter
  47. }
  48. }
  49. }