MaterialsBrandSection.qml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Uranium is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import QtQuick.Layouts 1.3
  7. import QtQuick.Dialogs 1.2
  8. import UM 1.2 as UM
  9. import Cura 1.0 as Cura
  10. Rectangle
  11. {
  12. id: brand_section
  13. property var expanded: base.collapsed_brands.indexOf(model.name) > -1
  14. property var types_model: model.material_types
  15. height: childrenRect.height
  16. width: parent.width
  17. Rectangle
  18. {
  19. id: brand_header_background
  20. color: UM.Theme.getColor("favorites_header_bar")
  21. anchors.fill: brand_header
  22. }
  23. Row
  24. {
  25. id: brand_header
  26. width: parent.width
  27. Label
  28. {
  29. id: brand_name
  30. text: model.name
  31. height: UM.Theme.getSize("favorites_row").height
  32. width: parent.width - UM.Theme.getSize("favorites_button").width
  33. verticalAlignment: Text.AlignVCenter
  34. leftPadding: 4
  35. }
  36. Button
  37. {
  38. text: ""
  39. implicitWidth: UM.Theme.getSize("favorites_button").width
  40. implicitHeight: UM.Theme.getSize("favorites_button").height
  41. UM.RecolorImage {
  42. anchors
  43. {
  44. verticalCenter: parent.verticalCenter
  45. horizontalCenter: parent.horizontalCenter
  46. }
  47. width: UM.Theme.getSize("standard_arrow").width
  48. height: UM.Theme.getSize("standard_arrow").height
  49. sourceSize.width: width
  50. sourceSize.height: height
  51. color: "black"
  52. source: brand_section.expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
  53. }
  54. style: ButtonStyle
  55. {
  56. background: Rectangle
  57. {
  58. anchors.fill: parent
  59. color: "transparent"
  60. }
  61. }
  62. }
  63. }
  64. MouseArea
  65. {
  66. anchors.fill: brand_header
  67. onPressed:
  68. {
  69. const i = base.collapsed_brands.indexOf(model.name)
  70. if (i > -1)
  71. {
  72. // Remove it
  73. base.collapsed_brands.splice(i, 1)
  74. brand_section.expanded = false
  75. }
  76. else
  77. {
  78. // Add it
  79. base.collapsed_brands.push(model.name)
  80. brand_section.expanded = true
  81. }
  82. }
  83. }
  84. Column
  85. {
  86. anchors.top: brand_header.bottom
  87. width: parent.width
  88. anchors.left: parent.left
  89. height: brand_section.expanded ? childrenRect.height : 0
  90. visible: brand_section.expanded
  91. Repeater
  92. {
  93. model: types_model
  94. delegate: MaterialsTypeSection {}
  95. }
  96. }
  97. }