MenuItem.qml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.3
  5. import UM 1.5 as UM
  6. //
  7. // MenuItem with Cura styling.
  8. //
  9. UM.MenuItem
  10. {
  11. id: menuItem
  12. implicitHeight: UM.Theme.getSize("menu").height + UM.Theme.getSize("narrow_margin").height
  13. implicitWidth: UM.Theme.getSize("menu").width
  14. property bool overrideShowArrow: false
  15. arrow: UM.ColorImage
  16. {
  17. visible: menuItem.subMenu || overrideShowArrow
  18. height: UM.Theme.getSize("default_arrow").height
  19. width: height
  20. anchors.verticalCenter: parent.verticalCenter
  21. anchors.right: parent.right
  22. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  23. source: UM.Theme.getIcon("ChevronSingleRight")
  24. color: UM.Theme.getColor("setting_control_text")
  25. }
  26. indicator: UM.ColorImage
  27. {
  28. id: check
  29. visible: menuItem.checkable && menuItem.checked
  30. height: UM.Theme.getSize("default_arrow").height
  31. width: height
  32. anchors.verticalCenter: parent.verticalCenter
  33. anchors.left: parent.left
  34. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  35. source: UM.Theme.getIcon("Check", "low")
  36. color: UM.Theme.getColor("setting_control_text")
  37. }
  38. background: Rectangle
  39. {
  40. x: UM.Theme.getSize("default_lining").width
  41. y: UM.Theme.getSize("default_lining").width
  42. width: menuItem.width - 2 * UM.Theme.getSize("default_lining").width
  43. height: menuItem.height - 2 * UM.Theme.getSize("default_lining").height
  44. color: menuItem.highlighted ? UM.Theme.getColor("background_2"): UM.Theme.getColor("background_1")
  45. }
  46. }