PackagePage.qml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. UM.Label
  48. {
  49. anchors.verticalCenter: downloadsIcon.verticalCenter
  50. text: packageData.downloadCount
  51. }
  52. }
  53. }
  54. }
  55. Column
  56. {
  57. id: extendedDescription
  58. width: parent.width
  59. padding: UM.Theme.getSize("default_margin").width
  60. topPadding: 0
  61. spacing: UM.Theme.getSize("default_margin").height
  62. UM.Label
  63. {
  64. width: parent.width - parent.padding * 2
  65. text: catalog.i18nc("@header", "Description")
  66. font: UM.Theme.getFont("medium_bold")
  67. elide: Text.ElideRight
  68. }
  69. UM.Label
  70. {
  71. width: parent.width - parent.padding * 2
  72. text: packageData.formattedDescription
  73. font: UM.Theme.getFont("medium")
  74. linkColor: UM.Theme.getColor("text_link")
  75. textFormat: Text.RichText
  76. onLinkActivated: UM.UrlUtil.openUrl(link, ["http", "https"])
  77. }
  78. Column //Separate column to have no spacing between compatible printers.
  79. {
  80. id: compatiblePrinterColumn
  81. width: parent.width - parent.padding * 2
  82. visible: packageData.packageType === "material"
  83. spacing: 0
  84. UM.Label
  85. {
  86. width: parent.width
  87. text: catalog.i18nc("@header", "Compatible printers")
  88. font: UM.Theme.getFont("medium_bold")
  89. elide: Text.ElideRight
  90. }
  91. Repeater
  92. {
  93. model: packageData.compatiblePrinters
  94. UM.Label
  95. {
  96. width: compatiblePrinterColumn.width
  97. text: modelData
  98. font: UM.Theme.getFont("medium")
  99. elide: Text.ElideRight
  100. }
  101. }
  102. UM.Label
  103. {
  104. width: parent.width
  105. visible: packageData.compatiblePrinters.length == 0
  106. text: "(" + catalog.i18nc("@info", "No compatibility information") + ")"
  107. font: UM.Theme.getFont("medium")
  108. elide: Text.ElideRight
  109. }
  110. }
  111. Column
  112. {
  113. id: compatibleSupportMaterialColumn
  114. width: parent.width - parent.padding * 2
  115. visible: packageData.packageType === "material"
  116. spacing: 0
  117. UM.Label
  118. {
  119. width: parent.width
  120. text: catalog.i18nc("@header", "Compatible support materials")
  121. font: UM.Theme.getFont("medium_bold")
  122. elide: Text.ElideRight
  123. }
  124. Repeater
  125. {
  126. model: packageData.compatibleSupportMaterials
  127. UM.Label
  128. {
  129. width: compatibleSupportMaterialColumn.width
  130. text: modelData
  131. font: UM.Theme.getFont("medium")
  132. elide: Text.ElideRight
  133. }
  134. }
  135. UM.Label
  136. {
  137. width: parent.width
  138. visible: packageData.compatibleSupportMaterials.length == 0
  139. text: "(" + catalog.i18nc("@info No materials", "None") + ")"
  140. font: UM.Theme.getFont("medium")
  141. elide: Text.ElideRight
  142. }
  143. }
  144. Column
  145. {
  146. width: parent.width - parent.padding * 2
  147. visible: packageData.packageType === "material"
  148. spacing: 0
  149. UM.Label
  150. {
  151. width: parent.width
  152. text: catalog.i18nc("@header", "Compatible with Material Station")
  153. font: UM.Theme.getFont("medium_bold")
  154. elide: Text.ElideRight
  155. }
  156. UM.Label
  157. {
  158. width: parent.width
  159. text: packageData.isCompatibleMaterialStation ? catalog.i18nc("@info", "Yes") : catalog.i18nc("@info", "No")
  160. font: UM.Theme.getFont("medium")
  161. elide: Text.ElideRight
  162. }
  163. }
  164. Column
  165. {
  166. width: parent.width - parent.padding * 2
  167. visible: packageData.packageType === "material"
  168. spacing: 0
  169. UM.Label
  170. {
  171. width: parent.width
  172. text: catalog.i18nc("@header", "Optimized for Air Manager")
  173. font: UM.Theme.getFont("medium_bold")
  174. elide: Text.ElideRight
  175. }
  176. UM.Label
  177. {
  178. width: parent.width
  179. text: packageData.isCompatibleAirManager ? catalog.i18nc("@info", "Yes") : catalog.i18nc("@info", "No")
  180. font: UM.Theme.getFont("medium")
  181. elide: Text.ElideRight
  182. }
  183. }
  184. Row
  185. {
  186. id: externalButtonRow
  187. anchors.horizontalCenter: parent.horizontalCenter
  188. spacing: UM.Theme.getSize("narrow_margin").width
  189. Cura.SecondaryButton
  190. {
  191. text: packageData.packageType === "plugin" ? catalog.i18nc("@button", "Visit plug-in website") : catalog.i18nc("@button", "Website")
  192. iconSource: UM.Theme.getIcon("Globe")
  193. outlineColor: "transparent"
  194. onClicked: Qt.openUrlExternally(packageData.packageInfoUrl)
  195. }
  196. Cura.SecondaryButton
  197. {
  198. visible: packageData.packageType === "material"
  199. text: catalog.i18nc("@button", "Buy spool")
  200. iconSource: UM.Theme.getIcon("ShoppingCart")
  201. outlineColor: "transparent"
  202. onClicked: Qt.openUrlExternally(packageData.whereToBuy)
  203. }
  204. Cura.SecondaryButton
  205. {
  206. visible: packageData.packageType === "material"
  207. text: catalog.i18nc("@button", "Safety datasheet")
  208. iconSource: UM.Theme.getIcon("Warning")
  209. outlineColor: "transparent"
  210. onClicked: Qt.openUrlExternally(packageData.safetyDataSheet)
  211. }
  212. Cura.SecondaryButton
  213. {
  214. visible: packageData.packageType === "material"
  215. text: catalog.i18nc("@button", "Technical datasheet")
  216. iconSource: UM.Theme.getIcon("DocumentFilled")
  217. outlineColor: "transparent"
  218. onClicked: Qt.openUrlExternally(packageData.technicalDataSheet)
  219. }
  220. }
  221. }
  222. }
  223. FontMetrics
  224. {
  225. id: fontMetrics
  226. font: UM.Theme.getFont("default")
  227. }
  228. }