MonitorPrintJobCard.qml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. width: parent.width
  22. height: childrenRect.height
  23. ExpandableCard
  24. {
  25. enabled: printJob != null
  26. borderColor: printJob && printJob.configurationChanges.length !== 0 ? UM.Theme.getColor("warning") : UM.Theme.getColor("monitor_card_border")
  27. headerItem: Row
  28. {
  29. height: 48 * screenScaleFactor // TODO: Theme!
  30. anchors.left: parent.left
  31. anchors.leftMargin: 24 * screenScaleFactor // TODO: Theme!
  32. spacing: 18 * screenScaleFactor // TODO: Theme!
  33. MonitorPrintJobPreview
  34. {
  35. printJob: base.printJob
  36. size: 32 * screenScaleFactor // TODO: Theme!
  37. anchors.verticalCenter: parent.verticalCenter
  38. }
  39. Item
  40. {
  41. anchors.verticalCenter: parent.verticalCenter
  42. height: 18 * screenScaleFactor // TODO: Theme!
  43. width: UM.Theme.getSize("monitor_column").width
  44. Rectangle
  45. {
  46. color: UM.Theme.getColor("monitor_skeleton_loading")
  47. width: Math.round(parent.width / 2)
  48. height: parent.height
  49. visible: !printJob
  50. radius: 2 * screenScaleFactor // TODO: Theme!
  51. }
  52. Label
  53. {
  54. text: printJob && printJob.name ? printJob.name : ""
  55. color: UM.Theme.getColor("monitor_text_primary")
  56. elide: Text.ElideRight
  57. font: UM.Theme.getFont("medium") // 14pt, regular
  58. visible: printJob
  59. // FIXED-LINE-HEIGHT:
  60. height: parent.height
  61. verticalAlignment: Text.AlignVCenter
  62. renderType: Text.NativeRendering
  63. }
  64. }
  65. Item
  66. {
  67. anchors.verticalCenter: parent.verticalCenter
  68. height: 18 * screenScaleFactor // TODO: Theme!
  69. width: UM.Theme.getSize("monitor_column").width
  70. Rectangle
  71. {
  72. color: UM.Theme.getColor("monitor_skeleton_loading")
  73. width: Math.round(parent.width / 3)
  74. height: parent.height
  75. visible: !printJob
  76. radius: 2 * screenScaleFactor // TODO: Theme!
  77. }
  78. Label
  79. {
  80. text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : ""
  81. color: UM.Theme.getColor("monitor_text_primary")
  82. elide: Text.ElideRight
  83. font: UM.Theme.getFont("medium") // 14pt, regular
  84. visible: printJob
  85. // FIXED-LINE-HEIGHT:
  86. height: 18 * screenScaleFactor // TODO: Theme!
  87. verticalAlignment: Text.AlignVCenter
  88. renderType: Text.NativeRendering
  89. }
  90. }
  91. Item
  92. {
  93. anchors.verticalCenter: parent.verticalCenter
  94. height: 18 * screenScaleFactor // TODO: This should be childrenRect.height but QML throws warnings
  95. width: childrenRect.width
  96. Rectangle
  97. {
  98. color: UM.Theme.getColor("monitor_skeleton_loading")
  99. width: 72 * screenScaleFactor // TODO: Theme!
  100. height: parent.height
  101. visible: !printJob
  102. radius: 2 * screenScaleFactor // TODO: Theme!
  103. }
  104. Label
  105. {
  106. id: printerAssignmentLabel
  107. anchors.verticalCenter: parent.verticalCenter
  108. color: UM.Theme.getColor("monitor_text_primary")
  109. elide: Text.ElideRight
  110. font: UM.Theme.getFont("medium") // 14pt, regular
  111. text: {
  112. if (printJob !== null) {
  113. if (printJob.assignedPrinter == null)
  114. {
  115. if (printJob.state == "error")
  116. {
  117. return catalog.i18nc("@label", "Unavailable printer")
  118. }
  119. return catalog.i18nc("@label", "First available")
  120. }
  121. return printJob.assignedPrinter.name
  122. }
  123. return ""
  124. }
  125. visible: printJob
  126. width: 120 * screenScaleFactor // TODO: Theme!
  127. // FIXED-LINE-HEIGHT:
  128. height: parent.height
  129. verticalAlignment: Text.AlignVCenter
  130. renderType: Text.NativeRendering
  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. MonitorPrinterPill
  145. {
  146. text: printJob.configuration.printerType
  147. }
  148. }
  149. }
  150. }
  151. drawerItem: Row
  152. {
  153. anchors
  154. {
  155. left: parent.left
  156. leftMargin: 74 * screenScaleFactor // TODO: Theme!
  157. }
  158. height: 108 * screenScaleFactor // TODO: Theme!
  159. spacing: 18 * screenScaleFactor // TODO: Theme!
  160. MonitorPrinterConfiguration
  161. {
  162. id: printerConfiguration
  163. anchors.verticalCenter: parent.verticalCenter
  164. buildplate: catalog.i18nc("@label", "Glass")
  165. configurations:
  166. [
  167. base.printJob.configuration.extruderConfigurations[0],
  168. base.printJob.configuration.extruderConfigurations[1]
  169. ]
  170. height: 72 * screenScaleFactor // TODO: Theme!
  171. }
  172. Label {
  173. text: printJob && printJob.owner ? printJob.owner : ""
  174. color: UM.Theme.getColor("monitor_text_primary")
  175. elide: Text.ElideRight
  176. font: UM.Theme.getFont("medium") // 14pt, regular
  177. anchors.top: printerConfiguration.top
  178. // FIXED-LINE-HEIGHT:
  179. height: 18 * screenScaleFactor // TODO: Theme!
  180. verticalAlignment: Text.AlignVCenter
  181. renderType: Text.NativeRendering
  182. }
  183. }
  184. }
  185. MonitorContextMenuButton
  186. {
  187. id: contextMenuButton
  188. anchors
  189. {
  190. right: parent.right
  191. rightMargin: 8 * screenScaleFactor // TODO: Theme!
  192. top: parent.top
  193. topMargin: 8 * screenScaleFactor // TODO: Theme!
  194. }
  195. width: 32 * screenScaleFactor // TODO: Theme!
  196. height: 32 * screenScaleFactor // TODO: Theme!
  197. enabled: OutputDevice.supportsPrintJobActions
  198. onClicked: enabled ? contextMenu.switchPopupState() : {}
  199. visible:
  200. {
  201. if (!printJob) {
  202. return false
  203. }
  204. var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"]
  205. return states.indexOf(printJob.state) !== -1
  206. }
  207. }
  208. MonitorContextMenu
  209. {
  210. id: contextMenu
  211. printJob: base.printJob ? base.printJob : null
  212. target: contextMenuButton
  213. }
  214. // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available
  215. MouseArea
  216. {
  217. id: contextMenuDisabledButtonArea
  218. anchors.fill: contextMenuButton
  219. hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled
  220. onEntered: contextMenuDisabledInfo.open()
  221. onExited: contextMenuDisabledInfo.close()
  222. enabled: !contextMenuButton.enabled
  223. }
  224. // TODO: uncomment this tooltip as soon as the required firmware is released
  225. // MonitorInfoBlurb
  226. // {
  227. // id: contextMenuDisabledInfo
  228. // text: catalog.i18nc("@info", "Please update your printer's firmware to manage the queue remotely.")
  229. // target: contextMenuButton
  230. // }
  231. }