DropDownWidget.qml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. Item
  8. {
  9. UM.I18nCatalog { id: catalog; name: "cura" }
  10. id: base
  11. implicitWidth: 200
  12. height: header.contentShown ? childrenRect.height : header.height
  13. property var contentComponent: null
  14. property alias title: header.title
  15. property alias contentShown: header.contentShown
  16. DropDownHeader
  17. {
  18. id: header
  19. anchors.top: parent.top
  20. anchors.left: parent.left
  21. anchors.right: parent.right
  22. height: UM.Theme.getSize("expandable_component_content_header").height
  23. rightIconSource: contentShown ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right")
  24. }
  25. Cura.RoundedRectangle
  26. {
  27. id: contentRectangle
  28. anchors.top: header.bottom
  29. anchors.horizontalCenter: header.horizontalCenter
  30. width: header.width
  31. height: childrenRect.height
  32. border.width: UM.Theme.getSize("default_lining").width
  33. border.color: UM.Theme.getColor("lining")
  34. color: "white"
  35. radius: UM.Theme.getSize("default_radius").width
  36. visible: base.contentShown
  37. cornerSide: Cura.RoundedRectangle.Direction.Down
  38. Loader
  39. {
  40. id: contentLoader
  41. anchors.top: parent.top
  42. anchors.left: parent.left
  43. anchors.right: parent.right
  44. height: childrenRect.height
  45. anchors.margins: 1
  46. sourceComponent: base.contentComponent != null ? base.contentComponent : emptyComponent
  47. }
  48. // This is the empty component/placeholder that will be shown when the widget gets expanded.
  49. // It contains a text line "Empty"
  50. Component
  51. {
  52. id: emptyComponent
  53. Label
  54. {
  55. text: catalog.i18nc("@label", "Empty")
  56. height: UM.Theme.getSize("action_button").height
  57. horizontalAlignment: Text.AlignHCenter
  58. verticalAlignment: Text.AlignVCenter
  59. font: UM.Theme.getFont("medium")
  60. renderType: Text.NativeRendering
  61. }
  62. }
  63. }
  64. }