ToolboxDownloadsGridTile.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.3
  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. Item
  9. {
  10. height: childrenRect.height
  11. Layout.alignment: Qt.AlignTop | Qt.AlignLeft
  12. Rectangle
  13. {
  14. id: highlight
  15. anchors.fill: parent
  16. opacity: 0.0
  17. color: UM.Theme.getColor("primary")
  18. }
  19. Row
  20. {
  21. width: parent.width
  22. height: childrenRect.height
  23. spacing: Math.floor(UM.Theme.getSize("narrow_margin").width)
  24. Rectangle
  25. {
  26. id: thumbnail
  27. width: UM.Theme.getSize("toolbox_thumbnail_small").width
  28. height: UM.Theme.getSize("toolbox_thumbnail_small").height
  29. color: "white"
  30. border.width: UM.Theme.getSize("default_lining").width
  31. border.color: UM.Theme.getColor("lining")
  32. Image
  33. {
  34. anchors.centerIn: parent
  35. width: UM.Theme.getSize("toolbox_thumbnail_small").width - UM.Theme.getSize("wide_margin").width
  36. height: UM.Theme.getSize("toolbox_thumbnail_small").height - UM.Theme.getSize("wide_margin").width
  37. fillMode: Image.PreserveAspectFit
  38. source: model.icon_url || "../images/logobot.svg"
  39. mipmap: true
  40. }
  41. }
  42. Column
  43. {
  44. width: parent.width - thumbnail.width - parent.spacing
  45. spacing: Math.floor(UM.Theme.getSize("narrow_margin").width)
  46. Label
  47. {
  48. id: name
  49. text: model.name
  50. width: parent.width
  51. wrapMode: Text.WordWrap
  52. color: UM.Theme.getColor("text")
  53. font: UM.Theme.getFont("default_bold")
  54. }
  55. Label
  56. {
  57. id: info
  58. text: model.description
  59. maximumLineCount: 2
  60. elide: Text.ElideRight
  61. width: parent.width
  62. wrapMode: Text.WordWrap
  63. color: UM.Theme.getColor("text_medium")
  64. font: UM.Theme.getFont("very_small")
  65. }
  66. }
  67. }
  68. MouseArea
  69. {
  70. anchors.fill: parent
  71. hoverEnabled: true
  72. onEntered:
  73. {
  74. thumbnail.border.color = UM.Theme.getColor("primary")
  75. highlight.opacity = 0.1
  76. }
  77. onExited:
  78. {
  79. thumbnail.border.color = UM.Theme.getColor("lining")
  80. highlight.opacity = 0.0
  81. }
  82. onClicked:
  83. {
  84. base.selection = model
  85. switch(toolbox.viewCategory)
  86. {
  87. case "material":
  88. toolbox.viewPage = "author"
  89. toolbox.filterModelByProp("packages", "author_id", model.id)
  90. break
  91. default:
  92. toolbox.viewPage = "detail"
  93. toolbox.filterModelByProp("packages", "id", model.id)
  94. break
  95. }
  96. }
  97. }
  98. }