PackagePage.qml 9.3 KB

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