PackagePage.qml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.15
  4. import QtQuick.Controls 2.15
  5. import QtQuick.Layouts 1.1
  6. import UM 1.6 as UM
  7. import Cura 1.6 as Cura
  8. Rectangle
  9. {
  10. id: root
  11. property alias packageData: packageCardHeader.packageData
  12. height: childrenRect.height
  13. color: UM.Theme.getColor("main_background")
  14. radius: UM.Theme.getSize("default_radius").width
  15. Column
  16. {
  17. width: parent.width
  18. spacing: 0
  19. Item
  20. {
  21. width: parent.width
  22. height: UM.Theme.getSize("card").height
  23. PackageCardHeader
  24. {
  25. id: packageCardHeader
  26. showUpdateButton: true
  27. showInstallButton: true
  28. showDisableButton: true
  29. anchors.fill: parent
  30. Row
  31. {
  32. id: downloadCount
  33. Layout.preferredWidth: parent.width
  34. Layout.fillHeight: true
  35. // It's not the perfect way to handle this, since a package really can have 0 downloads
  36. // But we re-use the package page for the manage plugins as well. The one user that doesn't see
  37. // the num downloads is an acceptable "sacrifice" to make this easy to fix.
  38. visible: packageData.downloadCount != "0"
  39. UM.ColorImage
  40. {
  41. id: downloadsIcon
  42. width: UM.Theme.getSize("card_tiny_icon").width
  43. height: UM.Theme.getSize("card_tiny_icon").height
  44. source: UM.Theme.getIcon("Download")
  45. color: UM.Theme.getColor("text")
  46. }
  47. Label
  48. {
  49. anchors.verticalCenter: downloadsIcon.verticalCenter
  50. color: UM.Theme.getColor("text")
  51. font: UM.Theme.getFont("default")
  52. text: packageData.downloadCount
  53. }
  54. }
  55. }
  56. }
  57. Column
  58. {
  59. id: extendedDescription
  60. width: parent.width
  61. padding: UM.Theme.getSize("default_margin").width
  62. topPadding: 0
  63. spacing: UM.Theme.getSize("default_margin").height
  64. Label
  65. {
  66. width: parent.width - parent.padding * 2
  67. text: catalog.i18nc("@header", "Description")
  68. font: UM.Theme.getFont("medium_bold")
  69. color: UM.Theme.getColor("text")
  70. elide: Text.ElideRight
  71. }
  72. Label
  73. {
  74. width: parent.width - parent.padding * 2
  75. text: packageData.formattedDescription
  76. font: UM.Theme.getFont("medium")
  77. color: UM.Theme.getColor("text")
  78. linkColor: UM.Theme.getColor("text_link")
  79. wrapMode: Text.Wrap
  80. textFormat: Text.RichText
  81. onLinkActivated: UM.UrlUtil.openUrl(link, ["http", "https"])
  82. }
  83. Column //Separate column to have no spacing between compatible printers.
  84. {
  85. id: compatiblePrinterColumn
  86. width: parent.width - parent.padding * 2
  87. visible: packageData.packageType === "material"
  88. spacing: 0
  89. Label
  90. {
  91. width: parent.width
  92. text: catalog.i18nc("@header", "Compatible printers")
  93. font: UM.Theme.getFont("medium_bold")
  94. color: UM.Theme.getColor("text")
  95. elide: Text.ElideRight
  96. }
  97. Repeater
  98. {
  99. model: packageData.compatiblePrinters
  100. Label
  101. {
  102. width: compatiblePrinterColumn.width
  103. text: modelData
  104. font: UM.Theme.getFont("medium")
  105. color: UM.Theme.getColor("text")
  106. elide: Text.ElideRight
  107. }
  108. }
  109. Label
  110. {
  111. width: parent.width
  112. visible: packageData.compatiblePrinters.length == 0
  113. text: "(" + catalog.i18nc("@info", "No compatibility information") + ")"
  114. font: UM.Theme.getFont("medium")
  115. color: UM.Theme.getColor("text")
  116. elide: Text.ElideRight
  117. }
  118. }
  119. Column
  120. {
  121. id: compatibleSupportMaterialColumn
  122. width: parent.width - parent.padding * 2
  123. visible: packageData.packageType === "material"
  124. spacing: 0
  125. Label
  126. {
  127. width: parent.width
  128. text: catalog.i18nc("@header", "Compatible support materials")
  129. font: UM.Theme.getFont("medium_bold")
  130. color: UM.Theme.getColor("text")
  131. elide: Text.ElideRight
  132. }
  133. Repeater
  134. {
  135. model: packageData.compatibleSupportMaterials
  136. Label
  137. {
  138. width: compatibleSupportMaterialColumn.width
  139. text: modelData
  140. font: UM.Theme.getFont("medium")
  141. color: UM.Theme.getColor("text")
  142. elide: Text.ElideRight
  143. }
  144. }
  145. Label
  146. {
  147. width: parent.width
  148. visible: packageData.compatibleSupportMaterials.length == 0
  149. text: "(" + catalog.i18nc("@info No materials", "None") + ")"
  150. font: UM.Theme.getFont("medium")
  151. color: UM.Theme.getColor("text")
  152. elide: Text.ElideRight
  153. }
  154. }
  155. Column
  156. {
  157. width: parent.width - parent.padding * 2
  158. visible: packageData.packageType === "material"
  159. spacing: 0
  160. Label
  161. {
  162. width: parent.width
  163. text: catalog.i18nc("@header", "Compatible with Material Station")
  164. font: UM.Theme.getFont("medium_bold")
  165. color: UM.Theme.getColor("text")
  166. elide: Text.ElideRight
  167. }
  168. Label
  169. {
  170. width: parent.width
  171. text: packageData.isCompatibleMaterialStation ? catalog.i18nc("@info", "Yes") : catalog.i18nc("@info", "No")
  172. font: UM.Theme.getFont("medium")
  173. color: UM.Theme.getColor("text")
  174. elide: Text.ElideRight
  175. }
  176. }
  177. Column
  178. {
  179. width: parent.width - parent.padding * 2
  180. visible: packageData.packageType === "material"
  181. spacing: 0
  182. Label
  183. {
  184. width: parent.width
  185. text: catalog.i18nc("@header", "Optimized for Air Manager")
  186. font: UM.Theme.getFont("medium_bold")
  187. color: UM.Theme.getColor("text")
  188. elide: Text.ElideRight
  189. }
  190. Label
  191. {
  192. width: parent.width
  193. text: packageData.isCompatibleAirManager ? catalog.i18nc("@info", "Yes") : catalog.i18nc("@info", "No")
  194. font: UM.Theme.getFont("medium")
  195. color: UM.Theme.getColor("text")
  196. elide: Text.ElideRight
  197. }
  198. }
  199. Row
  200. {
  201. id: externalButtonRow
  202. anchors.horizontalCenter: parent.horizontalCenter
  203. spacing: UM.Theme.getSize("narrow_margin").width
  204. Cura.SecondaryButton
  205. {
  206. text: packageData.packageType === "plugin" ? catalog.i18nc("@button", "Visit plug-in website") : catalog.i18nc("@button", "Website")
  207. iconSource: UM.Theme.getIcon("Globe")
  208. outlineColor: "transparent"
  209. onClicked: Qt.openUrlExternally(packageData.packageInfoUrl)
  210. }
  211. Cura.SecondaryButton
  212. {
  213. visible: packageData.packageType === "material"
  214. text: catalog.i18nc("@button", "Buy spool")
  215. iconSource: UM.Theme.getIcon("ShoppingCart")
  216. outlineColor: "transparent"
  217. onClicked: Qt.openUrlExternally(packageData.whereToBuy)
  218. }
  219. Cura.SecondaryButton
  220. {
  221. visible: packageData.packageType === "material"
  222. text: catalog.i18nc("@button", "Safety datasheet")
  223. iconSource: UM.Theme.getIcon("Warning")
  224. outlineColor: "transparent"
  225. onClicked: Qt.openUrlExternally(packageData.safetyDataSheet)
  226. }
  227. Cura.SecondaryButton
  228. {
  229. visible: packageData.packageType === "material"
  230. text: catalog.i18nc("@button", "Technical datasheet")
  231. iconSource: UM.Theme.getIcon("DocumentFilled")
  232. outlineColor: "transparent"
  233. onClicked: Qt.openUrlExternally(packageData.technicalDataSheet)
  234. }
  235. }
  236. }
  237. }
  238. FontMetrics
  239. {
  240. id: fontMetrics
  241. font: UM.Theme.getFont("default")
  242. }
  243. }