DropDownHeader.qml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.3 as UM
  6. import Cura 1.1 as Cura
  7. import ".."
  8. //
  9. // This is DropDown Header bar of the expandable drop down list.
  10. //
  11. Cura.RoundedRectangle
  12. {
  13. UM.I18nCatalog { id: catalog; name: "cura" }
  14. id: base
  15. border.width: UM.Theme.getSize("default_lining").width
  16. border.color: UM.Theme.getColor("lining")
  17. color: hovered ? UM.Theme.getColor("secondary_button_hover") : UM.Theme.getColor("secondary_button")
  18. radius: UM.Theme.getSize("default_radius").width
  19. cornerSide: contentShown ? Cura.RoundedRectangle.Direction.Up : Cura.RoundedRectangle.Direction.All
  20. property string title: ""
  21. property url rightIconSource: UM.Theme.getIcon("arrow_bottom")
  22. // If the tab is under hovering state
  23. property bool hovered: false
  24. // If the content is shown
  25. property bool contentShown: false
  26. MouseArea
  27. {
  28. anchors.fill: parent
  29. hoverEnabled: true
  30. onEntered: base.hovered = true
  31. onExited: base.hovered = false
  32. onClicked: base.contentShown = !base.contentShown
  33. }
  34. Label
  35. {
  36. id: title
  37. anchors.left: parent.left
  38. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  39. anchors.verticalCenter: parent.verticalCenter
  40. verticalAlignment: Text.AlignVCenter
  41. text: base.title
  42. font: UM.Theme.getFont("medium")
  43. renderType: Text.NativeRendering
  44. color: base.hovered ? UM.Theme.getColor("small_button_text_hover") : UM.Theme.getColor("small_button_text")
  45. }
  46. UM.RecolorImage
  47. {
  48. id: rightIcon
  49. anchors.right: parent.right
  50. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  51. anchors.verticalCenter: parent.verticalCenter
  52. width: UM.Theme.getSize("message_close").width
  53. height: UM.Theme.getSize("message_close").height
  54. color: base.hovered ? UM.Theme.getColor("small_button_text_hover") : UM.Theme.getColor("small_button_text")
  55. source: base.rightIconSource
  56. }
  57. }