PackagePage.qml 9.3 KB

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