DropDownHeader.qml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. See comments in DropDownWidget for details.
  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: UM.Theme.getColor("secondary")
  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("ChevronSingleDown")
  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. signal clicked()
  27. MouseArea
  28. {
  29. anchors.fill: parent
  30. hoverEnabled: true
  31. onEntered: base.hovered = true
  32. onExited: base.hovered = false
  33. onClicked: base.clicked()
  34. }
  35. Label
  36. {
  37. id: title
  38. anchors.left: parent.left
  39. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  40. anchors.verticalCenter: parent.verticalCenter
  41. verticalAlignment: Text.AlignVCenter
  42. text: base.title
  43. font: UM.Theme.getFont("medium")
  44. renderType: Text.NativeRendering
  45. color: base.hovered ? UM.Theme.getColor("small_button_text_hover") : UM.Theme.getColor("small_button_text")
  46. }
  47. UM.RecolorImage
  48. {
  49. id: rightIcon
  50. anchors.right: parent.right
  51. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  52. anchors.verticalCenter: parent.verticalCenter
  53. width: UM.Theme.getSize("message_close").width
  54. height: UM.Theme.getSize("message_close").height
  55. color: base.hovered ? UM.Theme.getColor("small_button_text_hover") : UM.Theme.getColor("small_button_text")
  56. source: base.rightIconSource
  57. }
  58. }