ToolboxDownloadsShowcaseTile.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 UM 1.1 as UM
  7. Item
  8. {
  9. width: UM.Theme.getSize("toolbox_thumbnail_large").width
  10. height: thumbnail.height + packageName.height
  11. Rectangle
  12. {
  13. id: highlight
  14. anchors.fill: parent
  15. opacity: 0.0
  16. color: UM.Theme.getColor("primary")
  17. }
  18. Rectangle
  19. {
  20. id: thumbnail
  21. color: "white"
  22. width: UM.Theme.getSize("toolbox_thumbnail_large").width
  23. height: UM.Theme.getSize("toolbox_thumbnail_large").height
  24. border
  25. {
  26. width: UM.Theme.getSize("default_lining").width
  27. color: UM.Theme.getColor("lining")
  28. }
  29. anchors
  30. {
  31. top: parent.top
  32. horizontalCenter: parent.horizontalCenter
  33. }
  34. Image
  35. {
  36. anchors.centerIn: parent
  37. width: UM.Theme.getSize("toolbox_thumbnail_large").width - 2 * UM.Theme.getSize("default_margin").width
  38. height: UM.Theme.getSize("toolbox_thumbnail_large").height - 2 * UM.Theme.getSize("default_margin").height
  39. fillMode: Image.PreserveAspectFit
  40. source: model.icon_url || "../images/logobot.svg"
  41. mipmap: true
  42. }
  43. }
  44. Label
  45. {
  46. id: packageName
  47. text: model.name
  48. anchors
  49. {
  50. top: thumbnail.bottom
  51. horizontalCenter: parent.horizontalCenter
  52. }
  53. verticalAlignment: Text.AlignVCenter
  54. horizontalAlignment: Text.AlignHCenter
  55. height: UM.Theme.getSize("toolbox_heading_label").height
  56. width: parent.width
  57. wrapMode: Text.WordWrap
  58. color: UM.Theme.getColor("text")
  59. font: UM.Theme.getFont("medium_bold")
  60. }
  61. MouseArea
  62. {
  63. anchors.fill: parent
  64. hoverEnabled: true
  65. onEntered:
  66. {
  67. thumbnail.border.color = UM.Theme.getColor("primary")
  68. highlight.opacity = 0.1
  69. }
  70. onExited:
  71. {
  72. thumbnail.border.color = UM.Theme.getColor("lining")
  73. highlight.opacity = 0.0
  74. }
  75. onClicked:
  76. {
  77. base.selection = model
  78. switch(toolbox.viewCategory)
  79. {
  80. case "material":
  81. toolbox.viewPage = "author"
  82. toolbox.filterModelByProp("packages", "author_name", model.name)
  83. break
  84. default:
  85. toolbox.viewPage = "detail"
  86. toolbox.filterModelByProp("packages", "id", model.id)
  87. break
  88. }
  89. }
  90. }
  91. }