ToolboxCompatibilityChart.qml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.1 as UM
  7. Item
  8. {
  9. id: base
  10. property var packageData
  11. property var technicalDataSheetUrl:
  12. {
  13. var link = undefined
  14. if ("Technical Data Sheet" in packageData.links)
  15. {
  16. // HACK: This is the way the old API (used in 3.6-beta) used to do it. For safety it's still here,
  17. // but it can be removed over time.
  18. link = packageData.links["Technical Data Sheet"]
  19. }
  20. else if ("technicalDataSheet" in packageData.links)
  21. {
  22. link = packageData.links["technicalDataSheet"]
  23. }
  24. return link
  25. }
  26. property var safetyDataSheetUrl:
  27. {
  28. var sds_name = "safetyDataSheet"
  29. return (sds_name in packageData.links) ? packageData.links[sds_name] : undefined
  30. }
  31. property var printingGuidelinesUrl:
  32. {
  33. var pg_name = "printingGuidelines"
  34. return (pg_name in packageData.links) ? packageData.links[pg_name] : undefined
  35. }
  36. property var materialWebsiteUrl:
  37. {
  38. var pg_name = "website"
  39. return (pg_name in packageData.links) ? packageData.links[pg_name] : undefined
  40. }
  41. anchors.topMargin: UM.Theme.getSize("default_margin").height
  42. height: visible ? childrenRect.height : 0
  43. visible: packageData.type == "material" &&
  44. (packageData.has_configs || technicalDataSheetUrl !== undefined ||
  45. safetyDataSheetUrl !== undefined || printingGuidelinesUrl !== undefined ||
  46. materialWebsiteUrl !== undefined)
  47. Item
  48. {
  49. id: combatibilityItem
  50. visible: packageData.has_configs
  51. width: parent.width
  52. // This is a bit of a hack, but the whole QML is pretty messy right now. This needs a big overhaul.
  53. height: visible ? heading.height + table.height: 0
  54. Label
  55. {
  56. id: heading
  57. anchors.topMargin: UM.Theme.getSize("default_margin").height
  58. width: parent.width
  59. text: catalog.i18nc("@label", "Compatibility")
  60. wrapMode: Text.WordWrap
  61. color: UM.Theme.getColor("text_medium")
  62. font: UM.Theme.getFont("medium")
  63. renderType: Text.NativeRendering
  64. }
  65. TableView
  66. {
  67. id: table
  68. anchors.top: heading.bottom
  69. anchors.topMargin: UM.Theme.getSize("default_margin").height
  70. width: parent.width
  71. frameVisible: false
  72. // Workaround for scroll issues (QTBUG-49652)
  73. flickableItem.interactive: false
  74. Component.onCompleted:
  75. {
  76. for (var i = 0; i < flickableItem.children.length; ++i)
  77. {
  78. flickableItem.children[i].enabled = false
  79. }
  80. }
  81. selectionMode: 0
  82. model: packageData.supported_configs
  83. headerDelegate: Rectangle
  84. {
  85. color: UM.Theme.getColor("main_background")
  86. height: UM.Theme.getSize("toolbox_chart_row").height
  87. Label
  88. {
  89. anchors.verticalCenter: parent.verticalCenter
  90. elide: Text.ElideRight
  91. text: styleData.value || ""
  92. color: UM.Theme.getColor("text")
  93. font: UM.Theme.getFont("default_bold")
  94. renderType: Text.NativeRendering
  95. }
  96. Rectangle
  97. {
  98. anchors.bottom: parent.bottom
  99. height: UM.Theme.getSize("default_lining").height
  100. width: parent.width
  101. color: "black"
  102. }
  103. }
  104. rowDelegate: Item
  105. {
  106. height: UM.Theme.getSize("toolbox_chart_row").height
  107. Label
  108. {
  109. anchors.verticalCenter: parent.verticalCenter
  110. elide: Text.ElideRight
  111. text: styleData.value || ""
  112. color: UM.Theme.getColor("text_medium")
  113. font: UM.Theme.getFont("default")
  114. renderType: Text.NativeRendering
  115. }
  116. }
  117. itemDelegate: Item
  118. {
  119. height: UM.Theme.getSize("toolbox_chart_row").height
  120. Label
  121. {
  122. anchors.verticalCenter: parent.verticalCenter
  123. elide: Text.ElideRight
  124. text: styleData.value || ""
  125. color: UM.Theme.getColor("text_medium")
  126. font: UM.Theme.getFont("default")
  127. renderType: Text.NativeRendering
  128. }
  129. }
  130. Component
  131. {
  132. id: columnTextDelegate
  133. Label
  134. {
  135. anchors.fill: parent
  136. verticalAlignment: Text.AlignVCenter
  137. text: styleData.value || ""
  138. elide: Text.ElideRight
  139. color: UM.Theme.getColor("text_medium")
  140. font: UM.Theme.getFont("default")
  141. renderType: Text.NativeRendering
  142. }
  143. }
  144. TableViewColumn
  145. {
  146. role: "machine"
  147. title: "Machine"
  148. width: Math.floor(table.width * 0.25)
  149. delegate: columnTextDelegate
  150. }
  151. TableViewColumn
  152. {
  153. role: "print_core"
  154. title: "Print Core"
  155. width: Math.floor(table.width * 0.2)
  156. }
  157. TableViewColumn
  158. {
  159. role: "build_plate"
  160. title: "Build Plate"
  161. width: Math.floor(table.width * 0.225)
  162. }
  163. TableViewColumn
  164. {
  165. role: "support_material"
  166. title: "Support"
  167. width: Math.floor(table.width * 0.225)
  168. }
  169. TableViewColumn
  170. {
  171. role: "quality"
  172. title: "Quality"
  173. width: Math.floor(table.width * 0.1)
  174. }
  175. }
  176. }
  177. Label
  178. {
  179. id: data_sheet_links
  180. anchors.top: combatibilityItem.bottom
  181. anchors.topMargin: UM.Theme.getSize("default_margin").height / 2
  182. visible: base.technicalDataSheetUrl !== undefined ||
  183. base.safetyDataSheetUrl !== undefined || base.printingGuidelinesUrl !== undefined ||
  184. base.materialWebsiteUrl !== undefined
  185. height: visible ? contentHeight : 0
  186. text:
  187. {
  188. var result = ""
  189. if (base.technicalDataSheetUrl !== undefined)
  190. {
  191. var tds_name = catalog.i18nc("@action:label", "Technical Data Sheet")
  192. result += "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg(tds_name)
  193. }
  194. if (base.safetyDataSheetUrl !== undefined)
  195. {
  196. if (result.length > 0)
  197. {
  198. result += "<br/>"
  199. }
  200. var sds_name = catalog.i18nc("@action:label", "Safety Data Sheet")
  201. result += "<a href='%1'>%2</a>".arg(base.safetyDataSheetUrl).arg(sds_name)
  202. }
  203. if (base.printingGuidelinesUrl !== undefined)
  204. {
  205. if (result.length > 0)
  206. {
  207. result += "<br/>"
  208. }
  209. var pg_name = catalog.i18nc("@action:label", "Printing Guidelines")
  210. result += "<a href='%1'>%2</a>".arg(base.printingGuidelinesUrl).arg(pg_name)
  211. }
  212. if (base.materialWebsiteUrl !== undefined)
  213. {
  214. if (result.length > 0)
  215. {
  216. result += "<br/>"
  217. }
  218. var pg_name = catalog.i18nc("@action:label", "Website")
  219. result += "<a href='%1'>%2</a>".arg(base.materialWebsiteUrl).arg(pg_name)
  220. }
  221. return result
  222. }
  223. font: UM.Theme.getFont("default")
  224. color: UM.Theme.getColor("text")
  225. linkColor: UM.Theme.getColor("text_link")
  226. onLinkActivated: Qt.openUrlExternally(link)
  227. renderType: Text.NativeRendering
  228. }
  229. }