ToolboxCompatibilityChart.qml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. // Copyright (c) 2019 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 UM 1.5 as UM
  6. Item
  7. {
  8. id: base
  9. property var packageData
  10. property var technicalDataSheetUrl: packageData.links.technicalDataSheet
  11. property var safetyDataSheetUrl: packageData.links.safetyDataSheet
  12. property var printingGuidelinesUrl: packageData.links.printingGuidelines
  13. property var materialWebsiteUrl: packageData.links.website
  14. height: childrenRect.height
  15. onVisibleChanged: packageData.type === "material" && (compatibilityItem.visible || dataSheetLinks.visible)
  16. Column
  17. {
  18. id: compatibilityItem
  19. visible: packageData.has_configs
  20. width: parent.width
  21. // This is a bit of a hack, but the whole QML is pretty messy right now. This needs a big overhaul.
  22. height: visible ? heading.height + table.height: 0
  23. Label
  24. {
  25. id: heading
  26. width: parent.width
  27. text: catalog.i18nc("@label", "Compatibility")
  28. wrapMode: Text.WordWrap
  29. color: UM.Theme.getColor("text_medium")
  30. font: UM.Theme.getFont("medium")
  31. renderType: Text.NativeRendering
  32. }
  33. TableView
  34. {
  35. id: table
  36. width: parent.width
  37. frameVisible: false
  38. // Workaround for scroll issues (QTBUG-49652)
  39. flickableItem.interactive: false
  40. Component.onCompleted:
  41. {
  42. for (var i = 0; i < flickableItem.children.length; ++i)
  43. {
  44. flickableItem.children[i].enabled = false
  45. }
  46. }
  47. selectionMode: 0
  48. model: packageData.supported_configs
  49. headerDelegate: Rectangle
  50. {
  51. color: UM.Theme.getColor("main_background")
  52. height: UM.Theme.getSize("toolbox_chart_row").height
  53. Label
  54. {
  55. anchors.verticalCenter: parent.verticalCenter
  56. elide: Text.ElideRight
  57. text: styleData.value || ""
  58. color: UM.Theme.getColor("text")
  59. font: UM.Theme.getFont("default_bold")
  60. renderType: Text.NativeRendering
  61. }
  62. Rectangle
  63. {
  64. anchors.bottom: parent.bottom
  65. height: UM.Theme.getSize("default_lining").height
  66. width: parent.width
  67. color: "black"
  68. }
  69. }
  70. rowDelegate: Item
  71. {
  72. height: UM.Theme.getSize("toolbox_chart_row").height
  73. Label
  74. {
  75. anchors.verticalCenter: parent.verticalCenter
  76. elide: Text.ElideRight
  77. text: styleData.value || ""
  78. color: UM.Theme.getColor("text_medium")
  79. font: UM.Theme.getFont("default")
  80. renderType: Text.NativeRendering
  81. }
  82. }
  83. itemDelegate: Item
  84. {
  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_medium")
  92. font: UM.Theme.getFont("default")
  93. renderType: Text.NativeRendering
  94. }
  95. }
  96. Component
  97. {
  98. id: columnTextDelegate
  99. Label
  100. {
  101. anchors.fill: parent
  102. verticalAlignment: Text.AlignVCenter
  103. text: styleData.value || ""
  104. elide: Text.ElideRight
  105. color: UM.Theme.getColor("text_medium")
  106. font: UM.Theme.getFont("default")
  107. renderType: Text.NativeRendering
  108. }
  109. }
  110. TableViewColumn
  111. {
  112. role: "machine"
  113. title: catalog.i18nc("@label:table_header", "Machine")
  114. width: Math.floor(table.width * 0.25)
  115. delegate: columnTextDelegate
  116. }
  117. TableViewColumn
  118. {
  119. role: "print_core"
  120. title: "Print Core" //This term should not be translated.
  121. width: Math.floor(table.width * 0.2)
  122. }
  123. TableViewColumn
  124. {
  125. role: "build_plate"
  126. title: catalog.i18nc("@label:table_header", "Build Plate")
  127. width: Math.floor(table.width * 0.225)
  128. }
  129. TableViewColumn
  130. {
  131. role: "support_material"
  132. title: catalog.i18nc("@label:table_header", "Support")
  133. width: Math.floor(table.width * 0.225)
  134. }
  135. TableViewColumn
  136. {
  137. role: "quality"
  138. title: catalog.i18nc("@label:table_header", "Quality")
  139. width: Math.floor(table.width * 0.1)
  140. }
  141. }
  142. }
  143. Label
  144. {
  145. id: dataSheetLinks
  146. anchors.top: compatibilityItem.bottom
  147. anchors.topMargin: UM.Theme.getSize("narrow_margin").height
  148. visible: base.technicalDataSheetUrl !== undefined ||
  149. base.safetyDataSheetUrl !== undefined ||
  150. base.printingGuidelinesUrl !== undefined ||
  151. base.materialWebsiteUrl !== undefined
  152. text:
  153. {
  154. var result = ""
  155. if (base.technicalDataSheetUrl !== undefined)
  156. {
  157. var tds_name = catalog.i18nc("@action:label", "Technical Data Sheet")
  158. result += "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg(tds_name)
  159. }
  160. if (base.safetyDataSheetUrl !== undefined)
  161. {
  162. if (result.length > 0)
  163. {
  164. result += "<br/>"
  165. }
  166. var sds_name = catalog.i18nc("@action:label", "Safety Data Sheet")
  167. result += "<a href='%1'>%2</a>".arg(base.safetyDataSheetUrl).arg(sds_name)
  168. }
  169. if (base.printingGuidelinesUrl !== undefined)
  170. {
  171. if (result.length > 0)
  172. {
  173. result += "<br/>"
  174. }
  175. var pg_name = catalog.i18nc("@action:label", "Printing Guidelines")
  176. result += "<a href='%1'>%2</a>".arg(base.printingGuidelinesUrl).arg(pg_name)
  177. }
  178. if (base.materialWebsiteUrl !== undefined)
  179. {
  180. if (result.length > 0)
  181. {
  182. result += "<br/>"
  183. }
  184. var pg_name = catalog.i18nc("@action:label", "Website")
  185. result += "<a href='%1'>%2</a>".arg(base.materialWebsiteUrl).arg(pg_name)
  186. }
  187. return result
  188. }
  189. font: UM.Theme.getFont("default")
  190. color: UM.Theme.getColor("text")
  191. linkColor: UM.Theme.getColor("text_link")
  192. onLinkActivated: UM.UrlUtil.openUrl(link, ["http", "https"])
  193. renderType: Text.NativeRendering
  194. }
  195. }