ToolboxCompatibilityChart.qml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  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. }
  64. TableView
  65. {
  66. id: table
  67. anchors.top: heading.bottom
  68. anchors.topMargin: UM.Theme.getSize("default_margin").height
  69. width: parent.width
  70. frameVisible: false
  71. // Workaround for scroll issues (QTBUG-49652)
  72. flickableItem.interactive: false
  73. Component.onCompleted:
  74. {
  75. for (var i = 0; i < flickableItem.children.length; ++i)
  76. {
  77. flickableItem.children[i].enabled = false
  78. }
  79. }
  80. selectionMode: 0
  81. model: packageData.supported_configs
  82. headerDelegate: Rectangle
  83. {
  84. color: UM.Theme.getColor("main_background")
  85. height: UM.Theme.getSize("toolbox_chart_row").height
  86. Label
  87. {
  88. anchors.verticalCenter: parent.verticalCenter
  89. elide: Text.ElideRight
  90. text: styleData.value || ""
  91. color: UM.Theme.getColor("text")
  92. font: UM.Theme.getFont("default_bold")
  93. }
  94. Rectangle
  95. {
  96. anchors.bottom: parent.bottom
  97. height: UM.Theme.getSize("default_lining").height
  98. width: parent.width
  99. color: "black"
  100. }
  101. }
  102. rowDelegate: Item
  103. {
  104. height: UM.Theme.getSize("toolbox_chart_row").height
  105. Label
  106. {
  107. anchors.verticalCenter: parent.verticalCenter
  108. elide: Text.ElideRight
  109. text: styleData.value || ""
  110. color: UM.Theme.getColor("text_medium")
  111. font: UM.Theme.getFont("default")
  112. }
  113. }
  114. itemDelegate: Item
  115. {
  116. height: UM.Theme.getSize("toolbox_chart_row").height
  117. Label
  118. {
  119. anchors.verticalCenter: parent.verticalCenter
  120. elide: Text.ElideRight
  121. text: styleData.value || ""
  122. color: UM.Theme.getColor("text_medium")
  123. font: UM.Theme.getFont("default")
  124. }
  125. }
  126. Component
  127. {
  128. id: columnTextDelegate
  129. Label
  130. {
  131. anchors.fill: parent
  132. verticalAlignment: Text.AlignVCenter
  133. text: styleData.value || ""
  134. elide: Text.ElideRight
  135. color: UM.Theme.getColor("text_medium")
  136. font: UM.Theme.getFont("default")
  137. }
  138. }
  139. TableViewColumn
  140. {
  141. role: "machine"
  142. title: "Machine"
  143. width: Math.floor(table.width * 0.25)
  144. delegate: columnTextDelegate
  145. }
  146. TableViewColumn
  147. {
  148. role: "print_core"
  149. title: "Print Core"
  150. width: Math.floor(table.width * 0.2)
  151. }
  152. TableViewColumn
  153. {
  154. role: "build_plate"
  155. title: "Build Plate"
  156. width: Math.floor(table.width * 0.225)
  157. }
  158. TableViewColumn
  159. {
  160. role: "support_material"
  161. title: "Support"
  162. width: Math.floor(table.width * 0.225)
  163. }
  164. TableViewColumn
  165. {
  166. role: "quality"
  167. title: "Quality"
  168. width: Math.floor(table.width * 0.1)
  169. }
  170. }
  171. }
  172. Label
  173. {
  174. id: data_sheet_links
  175. anchors.top: combatibilityItem.bottom
  176. anchors.topMargin: UM.Theme.getSize("default_margin").height / 2
  177. visible: base.technicalDataSheetUrl !== undefined ||
  178. base.safetyDataSheetUrl !== undefined || base.printingGuidelinesUrl !== undefined ||
  179. base.materialWebsiteUrl !== undefined
  180. height: visible ? contentHeight : 0
  181. text:
  182. {
  183. var result = ""
  184. if (base.technicalDataSheetUrl !== undefined)
  185. {
  186. var tds_name = catalog.i18nc("@action:label", "Technical Data Sheet")
  187. result += "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg(tds_name)
  188. }
  189. if (base.safetyDataSheetUrl !== undefined)
  190. {
  191. if (result.length > 0)
  192. {
  193. result += "<br/>"
  194. }
  195. var sds_name = catalog.i18nc("@action:label", "Safety Data Sheet")
  196. result += "<a href='%1'>%2</a>".arg(base.safetyDataSheetUrl).arg(sds_name)
  197. }
  198. if (base.printingGuidelinesUrl !== undefined)
  199. {
  200. if (result.length > 0)
  201. {
  202. result += "<br/>"
  203. }
  204. var pg_name = catalog.i18nc("@action:label", "Printing Guidelines")
  205. result += "<a href='%1'>%2</a>".arg(base.printingGuidelinesUrl).arg(pg_name)
  206. }
  207. if (base.materialWebsiteUrl !== undefined)
  208. {
  209. if (result.length > 0)
  210. {
  211. result += "<br/>"
  212. }
  213. var pg_name = catalog.i18nc("@action:label", "Website")
  214. result += "<a href='%1'>%2</a>".arg(base.materialWebsiteUrl).arg(pg_name)
  215. }
  216. return result
  217. }
  218. font: UM.Theme.getFont("default")
  219. color: UM.Theme.getColor("text")
  220. linkColor: UM.Theme.getColor("text_link")
  221. onLinkActivated: Qt.openUrlExternally(link)
  222. }
  223. }