MonitorPrintJobCard.qml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. // Copyright (c) 2019 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. width: parent.width
  61. height: parent.height
  62. verticalAlignment: Text.AlignVCenter
  63. renderType: Text.NativeRendering
  64. }
  65. }
  66. Item
  67. {
  68. anchors.verticalCenter: parent.verticalCenter
  69. height: 18 * screenScaleFactor // TODO: Theme!
  70. width: UM.Theme.getSize("monitor_column").width
  71. Rectangle
  72. {
  73. color: UM.Theme.getColor("monitor_skeleton_loading")
  74. width: Math.round(parent.width / 3)
  75. height: parent.height
  76. visible: !printJob
  77. radius: 2 * screenScaleFactor // TODO: Theme!
  78. }
  79. Label
  80. {
  81. text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : ""
  82. color: UM.Theme.getColor("monitor_text_primary")
  83. elide: Text.ElideRight
  84. font: UM.Theme.getFont("medium") // 14pt, regular
  85. visible: printJob
  86. // FIXED-LINE-HEIGHT:
  87. height: 18 * screenScaleFactor // TODO: Theme!
  88. verticalAlignment: Text.AlignVCenter
  89. renderType: Text.NativeRendering
  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. renderType: Text.NativeRendering
  132. }
  133. Row
  134. {
  135. id: printerFamilyPills
  136. anchors
  137. {
  138. left: printerAssignmentLabel.right;
  139. leftMargin: 12 // TODO: Theme!
  140. verticalCenter: parent.verticalCenter
  141. }
  142. height: childrenRect.height
  143. spacing: 6 // TODO: Theme!
  144. visible: printJob
  145. MonitorPrinterPill
  146. {
  147. text: printJob.configuration.printerType
  148. }
  149. }
  150. }
  151. }
  152. drawerItem: Row
  153. {
  154. anchors
  155. {
  156. left: parent.left
  157. leftMargin: 74 * screenScaleFactor // TODO: Theme!
  158. }
  159. height: 108 * screenScaleFactor // TODO: Theme!
  160. spacing: 18 * screenScaleFactor // TODO: Theme!
  161. MonitorPrinterConfiguration
  162. {
  163. id: printerConfiguration
  164. anchors.verticalCenter: parent.verticalCenter
  165. buildplate: catalog.i18nc("@label", "Glass")
  166. configurations: base.printJob.configuration.extruderConfigurations
  167. height: 72 * screenScaleFactor // TODO: Theme!
  168. }
  169. Label {
  170. text: printJob && printJob.owner ? printJob.owner : ""
  171. color: UM.Theme.getColor("monitor_text_primary")
  172. elide: Text.ElideRight
  173. font: UM.Theme.getFont("medium") // 14pt, regular
  174. anchors.top: printerConfiguration.top
  175. // FIXED-LINE-HEIGHT:
  176. height: 18 * screenScaleFactor // TODO: Theme!
  177. verticalAlignment: Text.AlignVCenter
  178. renderType: Text.NativeRendering
  179. }
  180. }
  181. }
  182. MonitorContextMenuButton
  183. {
  184. id: contextMenuButton
  185. anchors
  186. {
  187. right: parent.right
  188. rightMargin: 8 * screenScaleFactor // TODO: Theme!
  189. top: parent.top
  190. topMargin: 8 * screenScaleFactor // TODO: Theme!
  191. }
  192. width: 32 * screenScaleFactor // TODO: Theme!
  193. height: 32 * screenScaleFactor // TODO: Theme!
  194. enabled: OutputDevice.supportsPrintJobActions
  195. onClicked: enabled ? contextMenu.switchPopupState() : {}
  196. visible:
  197. {
  198. if (!printJob) {
  199. return false
  200. }
  201. var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"]
  202. return states.indexOf(printJob.state) !== -1
  203. }
  204. }
  205. MonitorContextMenu
  206. {
  207. id: contextMenu
  208. printJob: base.printJob ? base.printJob : null
  209. target: contextMenuButton
  210. }
  211. // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available
  212. MouseArea
  213. {
  214. id: contextMenuDisabledButtonArea
  215. anchors.fill: contextMenuButton
  216. hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled
  217. onEntered: contextMenuDisabledInfo.open()
  218. onExited: contextMenuDisabledInfo.close()
  219. enabled: !contextMenuButton.enabled
  220. }
  221. MonitorInfoBlurb
  222. {
  223. id: contextMenuDisabledInfo
  224. text: catalog.i18nc("@info", "Please update your printer's firmware to manage the queue remotely.")
  225. target: contextMenuButton
  226. }
  227. }