ExtruderIcon.qml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 QtQuick.Controls 2.2
  5. import UM 1.2 as UM
  6. Item
  7. {
  8. id: extruderIconItem
  9. implicitWidth: UM.Theme.getSize("extruder_icon").width
  10. implicitHeight: UM.Theme.getSize("extruder_icon").height
  11. property bool checked: true
  12. property color materialColor
  13. property alias textColor: extruderNumberText.color
  14. property bool extruderEnabled: true
  15. property alias iconSize: mainIcon.sourceSize
  16. property string iconVariant: "medium"
  17. Item
  18. {
  19. opacity: extruderEnabled ? 1 : UM.Theme.getColor("extruder_disabled").a
  20. anchors.fill: parent
  21. layer.enabled: true // Prevent weird opacity effects.
  22. UM.RecolorImage
  23. {
  24. anchors.fill: parent
  25. sourceSize: mainIcon.sourceSize
  26. source: UM.Theme.getIcon("ExtruderColor", iconVariant)
  27. color: materialColor
  28. }
  29. UM.RecolorImage
  30. {
  31. id: mainIcon
  32. anchors.fill: parent
  33. sourceSize: UM.Theme.getSize("extruder_icon")
  34. source: UM.Theme.getIcon("Extruder", iconVariant)
  35. color: extruderNumberText.color
  36. }
  37. Label
  38. {
  39. id: extruderNumberText
  40. anchors.centerIn: parent
  41. text: index + 1
  42. font: UM.Theme.getFont("small_emphasis")
  43. color: UM.Theme.getColor("text")
  44. width: contentWidth
  45. height: contentHeight
  46. renderType: Text.NativeRendering
  47. horizontalAlignment: Text.AlignHCenter
  48. verticalAlignment: Text.AlignVCenter
  49. }
  50. }
  51. }