ToolboxDownloadsGridTile.qml 3.6 KB

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