ToolboxDownloadsGridTile.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. 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 - 26
  36. height: UM.Theme.getSize("toolbox_thumbnail_small").height - 26
  37. fillMode: Image.PreserveAspectFit
  38. source: model.icon_url || "../images/logobot.svg"
  39. }
  40. }
  41. Column
  42. {
  43. width: parent.width - thumbnail.width - parent.spacing
  44. spacing: Math.floor(UM.Theme.getSize("narrow_margin").width)
  45. Label
  46. {
  47. id: name
  48. text: model.name
  49. width: parent.width
  50. wrapMode: Text.WordWrap
  51. color: UM.Theme.getColor("text")
  52. font: UM.Theme.getFont("default_bold")
  53. }
  54. Label
  55. {
  56. id: info
  57. text:
  58. {
  59. if (model.description.length > 50)
  60. {
  61. return model.description.substring(0, 50) + "..."
  62. }
  63. return model.description
  64. }
  65. width: parent.width
  66. wrapMode: Text.WordWrap
  67. color: UM.Theme.getColor("text_medium")
  68. font: UM.Theme.getFont("very_small")
  69. }
  70. }
  71. }
  72. MouseArea
  73. {
  74. anchors.fill: parent
  75. hoverEnabled: true
  76. onEntered:
  77. {
  78. thumbnail.border.color = UM.Theme.getColor("primary")
  79. highlight.opacity = 0.1
  80. }
  81. onExited:
  82. {
  83. thumbnail.border.color = UM.Theme.getColor("lining")
  84. highlight.opacity = 0.0
  85. }
  86. onClicked:
  87. {
  88. base.selection = model
  89. switch(toolbox.viewCategory)
  90. {
  91. case "material":
  92. toolbox.viewPage = "author"
  93. toolbox.filterModelByProp("packages", "author_id", model.id)
  94. break
  95. default:
  96. toolbox.viewPage = "detail"
  97. toolbox.filterModelByProp("packages", "id", model.id)
  98. break
  99. }
  100. }
  101. }
  102. }