ToolboxDownloadsShowcaseTile.qml 3.3 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.7
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import QtGraphicalEffects 1.0
  7. import UM 1.1 as UM
  8. Rectangle
  9. {
  10. id: tileBase
  11. width: UM.Theme.getSize("toolbox_thumbnail_large").width + (2 * UM.Theme.getSize("default_lining").width)
  12. height: thumbnail.height + packageNameBackground.height + (2 * UM.Theme.getSize("default_lining").width)
  13. border.width: UM.Theme.getSize("default_lining").width
  14. border.color: UM.Theme.getColor("lining")
  15. color: "transparent"
  16. Rectangle
  17. {
  18. id: thumbnail
  19. color: "white"
  20. width: UM.Theme.getSize("toolbox_thumbnail_large").width
  21. height: UM.Theme.getSize("toolbox_thumbnail_large").height
  22. anchors
  23. {
  24. top: parent.top
  25. horizontalCenter: parent.horizontalCenter
  26. topMargin: UM.Theme.getSize("default_lining").width
  27. }
  28. Image
  29. {
  30. anchors.centerIn: parent
  31. width: UM.Theme.getSize("toolbox_thumbnail_large").width - 2 * UM.Theme.getSize("default_margin").width
  32. height: UM.Theme.getSize("toolbox_thumbnail_large").height - 2 * UM.Theme.getSize("default_margin").height
  33. fillMode: Image.PreserveAspectFit
  34. source: model.icon_url || "../images/logobot.svg"
  35. mipmap: true
  36. }
  37. }
  38. Rectangle
  39. {
  40. id: packageNameBackground
  41. color: UM.Theme.getColor("primary")
  42. anchors
  43. {
  44. top: thumbnail.bottom
  45. horizontalCenter: parent.horizontalCenter
  46. }
  47. height: UM.Theme.getSize("toolbox_heading_label").height
  48. width: parent.width
  49. Label
  50. {
  51. id: packageName
  52. text: model.name
  53. anchors
  54. {
  55. horizontalCenter: parent.horizontalCenter
  56. }
  57. verticalAlignment: Text.AlignVCenter
  58. horizontalAlignment: Text.AlignHCenter
  59. height: UM.Theme.getSize("toolbox_heading_label").height
  60. width: parent.width
  61. wrapMode: Text.WordWrap
  62. color: UM.Theme.getColor("button_text")
  63. font: UM.Theme.getFont("medium_bold")
  64. }
  65. }
  66. MouseArea
  67. {
  68. anchors.fill: parent
  69. hoverEnabled: true
  70. onEntered:
  71. {
  72. packageName.color = UM.Theme.getColor("button_text_hover")
  73. packageNameBackground.color = UM.Theme.getColor("primary_hover")
  74. tileBase.border.color = UM.Theme.getColor("primary_hover")
  75. }
  76. onExited:
  77. {
  78. packageName.color = UM.Theme.getColor("button_text")
  79. packageNameBackground.color = UM.Theme.getColor("primary")
  80. tileBase.border.color = UM.Theme.getColor("lining")
  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_name", model.name)
  90. break
  91. default:
  92. toolbox.viewPage = "detail"
  93. toolbox.filterModelByProp("packages", "id", model.id)
  94. break
  95. }
  96. }
  97. }
  98. }