ToolboxDownloadsGridTile.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.Dialogs 1.1
  5. import QtQuick.Window 2.2
  6. import QtQuick.Controls 1.4
  7. import QtQuick.Controls.Styles 1.4
  8. import QtQuick.Layouts 1.3
  9. import UM 1.1 as UM
  10. Item
  11. {
  12. id: base
  13. height: childrenRect.height
  14. Layout.alignment: Qt.AlignTop | Qt.AlignLeft
  15. Rectangle
  16. {
  17. id: highlight
  18. anchors.fill: parent
  19. opacity: 0.0
  20. color: UM.Theme.getColor("primary")
  21. }
  22. Row
  23. {
  24. width: parent.width
  25. height: childrenRect.height
  26. spacing: Math.floor(UM.Theme.getSize("base_unit").width / 2)
  27. Rectangle
  28. {
  29. id: thumbnail
  30. width: UM.Theme.getSize("toolbox_thumbnail_small").width
  31. height: UM.Theme.getSize("toolbox_thumbnail_small").height
  32. color: "white"
  33. border.width: UM.Theme.getSize("default_lining").width
  34. border.color: UM.Theme.getColor("lining")
  35. Image {
  36. anchors.centerIn: parent
  37. width: UM.Theme.getSize("toolbox_thumbnail_small").width - 26
  38. height: UM.Theme.getSize("toolbox_thumbnail_small").height - 26
  39. fillMode: Image.PreserveAspectFit
  40. source: model.icon_url || "../images/logobot.svg"
  41. }
  42. }
  43. Column
  44. {
  45. width: parent.width - thumbnail.width - parent.spacing
  46. spacing: Math.floor(UM.Theme.getSize("base_unit").width / 2)
  47. Label
  48. {
  49. id: name
  50. text: model.name
  51. width: parent.width
  52. wrapMode: Text.WordWrap
  53. color: UM.Theme.getColor("text")
  54. font: UM.Theme.getFont("default_bold")
  55. }
  56. Label
  57. {
  58. id: info
  59. text:
  60. {
  61. if (model.description.length > 50)
  62. {
  63. return model.description.substring(0, 50) + "..."
  64. }
  65. return model.description
  66. }
  67. width: parent.width
  68. wrapMode: Text.WordWrap
  69. color: UM.Theme.getColor("text_medium")
  70. font: UM.Theme.getFont("very_small")
  71. }
  72. }
  73. }
  74. MouseArea
  75. {
  76. anchors.fill: parent
  77. hoverEnabled: true
  78. onEntered:
  79. {
  80. thumbnail.border.color = UM.Theme.getColor("primary")
  81. highlight.opacity = 0.1
  82. }
  83. onExited:
  84. {
  85. thumbnail.border.color = UM.Theme.getColor("lining")
  86. highlight.opacity = 0.0
  87. }
  88. onClicked:
  89. {
  90. console.log(model.icon_url)
  91. if ( toolbox.viewCategory == "material" )
  92. {
  93. toolbox.viewSelection = model.name
  94. toolbox.viewPage = "author"
  95. toolbox.filterModelByProp("packages", "author_name", model.name)
  96. toolbox.filterModelByProp("authors", "name", model.name)
  97. }
  98. else
  99. {
  100. toolbox.viewSelection = model.id
  101. toolbox.viewPage = "detail"
  102. toolbox.filterModelByProp("packages", "id", model.id)
  103. toolbox.filterModelByProp("authors", "name", model.author_name)
  104. }
  105. }
  106. }
  107. }