ToolboxDownloadsShowcaseTile.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 UM 1.1 as UM
  7. Item
  8. {
  9. width: UM.Theme.getSize("toolbox_thumbnail_large").width
  10. height: childrenRect.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. anchors.centerIn: parent
  36. width: UM.Theme.getSize("toolbox_thumbnail_large").width - 2 * UM.Theme.getSize("default_margin").width
  37. height: UM.Theme.getSize("toolbox_thumbnail_large").height - 2 * UM.Theme.getSize("default_margin").height
  38. fillMode: Image.PreserveAspectFit
  39. source: model.icon_url || "../images/logobot.svg"
  40. }
  41. }
  42. Label
  43. {
  44. text: model.name
  45. anchors
  46. {
  47. bottom: parent.bottom
  48. horizontalCenter: parent.horizontalCenter
  49. }
  50. verticalAlignment: Text.AlignVCenter
  51. horizontalAlignment: Text.AlignHCenter
  52. height: UM.Theme.getSize("toolbox_heading_label").height
  53. width: parent.width
  54. wrapMode: Text.WordWrap
  55. color: UM.Theme.getColor("text")
  56. font: UM.Theme.getFont("medium_bold")
  57. }
  58. MouseArea
  59. {
  60. anchors.fill: parent
  61. hoverEnabled: true
  62. onEntered:
  63. {
  64. thumbnail.border.color = UM.Theme.getColor("primary")
  65. highlight.opacity = 0.1
  66. }
  67. onExited:
  68. {
  69. thumbnail.border.color = UM.Theme.getColor("lining")
  70. highlight.opacity = 0.0
  71. }
  72. onClicked:
  73. {
  74. base.selection = model
  75. switch(toolbox.viewCategory)
  76. {
  77. case "material":
  78. toolbox.viewPage = "author"
  79. toolbox.filterModelByProp("packages", "author_name", model.name)
  80. break
  81. default:
  82. toolbox.viewPage = "detail"
  83. toolbox.filterModelByProp("packages", "id", model.id)
  84. break
  85. }
  86. }
  87. }
  88. }