ToolboxDownloadsShowcaseTile.qml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 UM 1.1 as UM
  9. Item
  10. {
  11. width: UM.Theme.getSize("toolbox_thumbnail_large").width
  12. height: UM.Theme.getSize("toolbox_thumbnail_large").width
  13. visible:
  14. {
  15. if (toolbox.viewCategory == "material" && model.packages_count)
  16. {
  17. console.log(model)
  18. return model.packages_count > 0
  19. }
  20. else
  21. {
  22. return true
  23. }
  24. }
  25. Rectangle
  26. {
  27. color: "white"
  28. width: UM.Theme.getSize("toolbox_thumbnail_medium").width
  29. height: UM.Theme.getSize("toolbox_thumbnail_medium").height
  30. border.width: 1
  31. border.color: UM.Theme.getColor("lining")
  32. anchors
  33. {
  34. top: parent.top
  35. horizontalCenter: parent.horizontalCenter
  36. }
  37. Image {
  38. anchors.centerIn: parent
  39. width: UM.Theme.getSize("toolbox_thumbnail_medium").width - 26
  40. height: UM.Theme.getSize("toolbox_thumbnail_medium").height - 26
  41. fillMode: Image.PreserveAspectFit
  42. source: model.icon_url || "../images/logobot.svg"
  43. }
  44. }
  45. Label
  46. {
  47. text: model.name
  48. anchors
  49. {
  50. bottom: parent.bottom
  51. horizontalCenter: parent.horizontalCenter
  52. }
  53. verticalAlignment: Text.AlignVCenter
  54. horizontalAlignment: Text.AlignHCenter
  55. height: UM.Theme.getSize("base_unit").width * 4
  56. width: parent.width
  57. color: UM.Theme.getColor("text")
  58. font: UM.Theme.getFont("medium_bold")
  59. }
  60. MouseArea
  61. {
  62. anchors.fill: parent
  63. onClicked: {
  64. switch(toolbox.viewCategory)
  65. {
  66. case "material":
  67. toolbox.viewSelection = model.name
  68. toolbox.viewPage = "author"
  69. toolbox.filterModelByProp("authors", "name", model.name)
  70. toolbox.filterModelByProp("packages", "author_name", model.name)
  71. break
  72. default:
  73. toolbox.viewSelection = model.id
  74. toolbox.viewPage = "detail"
  75. toolbox.filterModelByProp("authors", "name", model.author_name)
  76. toolbox.filterModelByProp("packages", "id", model.id)
  77. break
  78. }
  79. }
  80. }
  81. }