ToolboxDownloadsGrid.qml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import QtQuick.Layouts 1.3
  7. import UM 1.1 as UM
  8. Column
  9. {
  10. // HACK: GridLayouts don't render to the correct height with odd numbers of
  11. // items, so if odd, add some extra space.
  12. height: grid.model.items.length % 2 == 0 ? childrenRect.height : childrenRect.height + 3 * UM.Theme.getSize("wide_margin").height
  13. width: parent.width
  14. spacing: UM.Theme.getSize("default_margin").height
  15. Label
  16. {
  17. id: heading
  18. text: toolbox.viewCategory == "material" ? catalog.i18nc("@label", "Maker Choices") : catalog.i18nc("@label", "Community Plugins")
  19. width: parent.width
  20. color: UM.Theme.getColor("text_medium")
  21. font: UM.Theme.getFont("medium")
  22. }
  23. GridLayout
  24. {
  25. id: grid
  26. property var model: toolbox.viewCategory == "material" ? toolbox.authorsModel : toolbox.packagesModel
  27. width: parent.width
  28. columns: 2
  29. columnSpacing: UM.Theme.getSize("default_margin").height
  30. rowSpacing: UM.Theme.getSize("default_margin").width
  31. Repeater
  32. {
  33. model: grid.model
  34. delegate: ToolboxDownloadsGridTile
  35. {
  36. Layout.preferredWidth: (grid.width - (grid.columns - 1) * grid.columnSpacing) / grid.columns
  37. }
  38. }
  39. }
  40. }