MonitorPrintJobCard.qml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.0
  5. import UM 1.3 as UM
  6. import Cura 1.0 as Cura
  7. /**
  8. * A Print Job Card is essentially just a filled-in Expandable Card item. All
  9. * data within it is derived from being passed a printJob property.
  10. *
  11. * NOTE: For most labels, a fixed height with vertical alignment is used to make
  12. * layouts more deterministic (like the fixed-size textboxes used in original
  13. * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
  14. * with '// FIXED-LINE-HEIGHT:'.
  15. */
  16. Item
  17. {
  18. id: base
  19. // The print job which all other data is derived from
  20. property var printJob: null
  21. // If the printer is a cloud printer or not. Other items base their enabled state off of this boolean. In the future
  22. // they might not need to though.
  23. property bool cloudConnection: Cura.MachineManager.activeMachineIsUsingCloudConnection
  24. width: parent.width
  25. height: childrenRect.height
  26. ExpandableCard
  27. {
  28. enabled: printJob != null
  29. borderColor: printJob && printJob.configurationChanges.length !== 0 ? UM.Theme.getColor("warning") : UM.Theme.getColor("monitor_card_border")
  30. headerItem: Row
  31. {
  32. height: 48 * screenScaleFactor // TODO: Theme!
  33. anchors.left: parent.left
  34. anchors.leftMargin: 24 * screenScaleFactor // TODO: Theme!
  35. spacing: 18 * screenScaleFactor // TODO: Theme!
  36. MonitorPrintJobPreview
  37. {
  38. printJob: base.printJob
  39. size: 32 * screenScaleFactor // TODO: Theme!
  40. anchors.verticalCenter: parent.verticalCenter
  41. }
  42. Item
  43. {
  44. anchors.verticalCenter: parent.verticalCenter
  45. height: 18 * screenScaleFactor // TODO: Theme!
  46. width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
  47. Rectangle
  48. {
  49. color: UM.Theme.getColor("monitor_skeleton_loading")
  50. width: Math.round(parent.width / 2)
  51. height: parent.height
  52. visible: !printJob
  53. radius: 2 * screenScaleFactor // TODO: Theme!
  54. }
  55. Label
  56. {
  57. text: printJob && printJob.name ? printJob.name : ""
  58. color: UM.Theme.getColor("monitor_text_primary")
  59. elide: Text.ElideRight
  60. font: UM.Theme.getFont("medium") // 14pt, regular
  61. visible: printJob
  62. // FIXED-LINE-HEIGHT:
  63. height: parent.height
  64. verticalAlignment: Text.AlignVCenter
  65. }
  66. }
  67. Item
  68. {
  69. anchors.verticalCenter: parent.verticalCenter
  70. height: 18 * screenScaleFactor // TODO: Theme!
  71. width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
  72. Rectangle
  73. {
  74. color: UM.Theme.getColor("monitor_skeleton_loading")
  75. width: Math.round(parent.width / 3)
  76. height: parent.height
  77. visible: !printJob
  78. radius: 2 * screenScaleFactor // TODO: Theme!
  79. }
  80. Label
  81. {
  82. text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : ""
  83. color: UM.Theme.getColor("monitor_text_primary")
  84. elide: Text.ElideRight
  85. font: UM.Theme.getFont("medium") // 14pt, regular
  86. visible: printJob
  87. // FIXED-LINE-HEIGHT:
  88. height: 18 * screenScaleFactor // TODO: Theme!
  89. verticalAlignment: Text.AlignVCenter
  90. }
  91. }
  92. Item
  93. {
  94. anchors.verticalCenter: parent.verticalCenter
  95. height: 18 * screenScaleFactor // TODO: This should be childrenRect.height but QML throws warnings
  96. width: childrenRect.width
  97. Rectangle
  98. {
  99. color: UM.Theme.getColor("monitor_skeleton_loading")
  100. width: 72 * screenScaleFactor // TODO: Theme!
  101. height: parent.height
  102. visible: !printJob
  103. radius: 2 * screenScaleFactor // TODO: Theme!
  104. }
  105. Label
  106. {
  107. id: printerAssignmentLabel
  108. anchors.verticalCenter: parent.verticalCenter
  109. color: UM.Theme.getColor("monitor_text_primary")
  110. elide: Text.ElideRight
  111. font: UM.Theme.getFont("medium") // 14pt, regular
  112. text: {
  113. if (printJob !== null) {
  114. if (printJob.assignedPrinter == null)
  115. {
  116. if (printJob.state == "error")
  117. {
  118. return catalog.i18nc("@label", "Unavailable printer")
  119. }
  120. return catalog.i18nc("@label", "First available")
  121. }
  122. return printJob.assignedPrinter.name
  123. }
  124. return ""
  125. }
  126. visible: printJob
  127. width: 120 * screenScaleFactor // TODO: Theme!
  128. // FIXED-LINE-HEIGHT:
  129. height: parent.height
  130. verticalAlignment: Text.AlignVCenter
  131. }
  132. Row
  133. {
  134. id: printerFamilyPills
  135. anchors
  136. {
  137. left: printerAssignmentLabel.right;
  138. leftMargin: 12 // TODO: Theme!
  139. verticalCenter: parent.verticalCenter
  140. }
  141. height: childrenRect.height
  142. spacing: 6 // TODO: Theme!
  143. visible: printJob
  144. Repeater
  145. {
  146. id: compatiblePills
  147. delegate: MonitorPrinterPill
  148. {
  149. text: modelData
  150. }
  151. model: printJob ? printJob.compatibleMachineFamilies : []
  152. }
  153. }
  154. }
  155. }
  156. drawerItem: Row
  157. {
  158. anchors
  159. {
  160. left: parent.left
  161. leftMargin: 74 * screenScaleFactor // TODO: Theme!
  162. }
  163. height: 108 * screenScaleFactor // TODO: Theme!
  164. spacing: 18 * screenScaleFactor // TODO: Theme!
  165. MonitorPrinterConfiguration
  166. {
  167. id: printerConfiguration
  168. anchors.verticalCenter: parent.verticalCenter
  169. buildplate: catalog.i18nc("@label", "Glass")
  170. configurations:
  171. [
  172. base.printJob.configuration.extruderConfigurations[0],
  173. base.printJob.configuration.extruderConfigurations[1]
  174. ]
  175. height: 72 * screenScaleFactor // TODO: Theme!
  176. }
  177. Label {
  178. text: printJob && printJob.owner ? printJob.owner : ""
  179. color: UM.Theme.getColor("monitor_text_primary")
  180. elide: Text.ElideRight
  181. font: UM.Theme.getFont("medium") // 14pt, regular
  182. anchors.top: printerConfiguration.top
  183. // FIXED-LINE-HEIGHT:
  184. height: 18 * screenScaleFactor // TODO: Theme!
  185. verticalAlignment: Text.AlignVCenter
  186. }
  187. }
  188. }
  189. MonitorContextMenuButton
  190. {
  191. id: contextMenuButton
  192. anchors
  193. {
  194. right: parent.right
  195. rightMargin: 8 * screenScaleFactor // TODO: Theme!
  196. top: parent.top
  197. topMargin: 8 * screenScaleFactor // TODO: Theme!
  198. }
  199. width: 32 * screenScaleFactor // TODO: Theme!
  200. height: 32 * screenScaleFactor // TODO: Theme!
  201. enabled: !cloudConnection
  202. onClicked: enabled ? contextMenu.switchPopupState() : {}
  203. visible:
  204. {
  205. if (!printJob) {
  206. return false
  207. }
  208. var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"]
  209. return states.indexOf(printJob.state) !== -1
  210. }
  211. }
  212. MonitorContextMenu
  213. {
  214. id: contextMenu
  215. printJob: base.printJob ? base.printJob : null
  216. target: contextMenuButton
  217. }
  218. // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available
  219. MouseArea
  220. {
  221. id: contextMenuDisabledButtonArea
  222. anchors.fill: contextMenuButton
  223. hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled
  224. onEntered: contextMenuDisabledInfo.open()
  225. onExited: contextMenuDisabledInfo.close()
  226. enabled: !contextMenuButton.enabled
  227. }
  228. MonitorInfoBlurb
  229. {
  230. id: contextMenuDisabledInfo
  231. text: catalog.i18nc("@info", "These options are not available because you are monitoring a cloud printer.")
  232. target: contextMenuButton
  233. }
  234. }