MonitorPrintJobCard.qml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. renderType: Text.NativeRendering
  66. }
  67. }
  68. Item
  69. {
  70. anchors.verticalCenter: parent.verticalCenter
  71. height: 18 * screenScaleFactor // TODO: Theme!
  72. width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
  73. Rectangle
  74. {
  75. color: UM.Theme.getColor("monitor_skeleton_loading")
  76. width: Math.round(parent.width / 3)
  77. height: parent.height
  78. visible: !printJob
  79. radius: 2 * screenScaleFactor // TODO: Theme!
  80. }
  81. Label
  82. {
  83. text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : ""
  84. color: UM.Theme.getColor("monitor_text_primary")
  85. elide: Text.ElideRight
  86. font: UM.Theme.getFont("medium") // 14pt, regular
  87. visible: printJob
  88. // FIXED-LINE-HEIGHT:
  89. height: 18 * screenScaleFactor // TODO: Theme!
  90. verticalAlignment: Text.AlignVCenter
  91. renderType: Text.NativeRendering
  92. }
  93. }
  94. Item
  95. {
  96. anchors.verticalCenter: parent.verticalCenter
  97. height: 18 * screenScaleFactor // TODO: This should be childrenRect.height but QML throws warnings
  98. width: childrenRect.width
  99. Rectangle
  100. {
  101. color: UM.Theme.getColor("monitor_skeleton_loading")
  102. width: 72 * screenScaleFactor // TODO: Theme!
  103. height: parent.height
  104. visible: !printJob
  105. radius: 2 * screenScaleFactor // TODO: Theme!
  106. }
  107. Label
  108. {
  109. id: printerAssignmentLabel
  110. anchors.verticalCenter: parent.verticalCenter
  111. color: UM.Theme.getColor("monitor_text_primary")
  112. elide: Text.ElideRight
  113. font: UM.Theme.getFont("medium") // 14pt, regular
  114. text: {
  115. if (printJob !== null) {
  116. if (printJob.assignedPrinter == null)
  117. {
  118. if (printJob.state == "error")
  119. {
  120. return catalog.i18nc("@label", "Unavailable printer")
  121. }
  122. return catalog.i18nc("@label", "First available")
  123. }
  124. return printJob.assignedPrinter.name
  125. }
  126. return ""
  127. }
  128. visible: printJob
  129. width: 120 * screenScaleFactor // TODO: Theme!
  130. // FIXED-LINE-HEIGHT:
  131. height: parent.height
  132. verticalAlignment: Text.AlignVCenter
  133. renderType: Text.NativeRendering
  134. }
  135. Row
  136. {
  137. id: printerFamilyPills
  138. anchors
  139. {
  140. left: printerAssignmentLabel.right;
  141. leftMargin: 12 // TODO: Theme!
  142. verticalCenter: parent.verticalCenter
  143. }
  144. height: childrenRect.height
  145. spacing: 6 // TODO: Theme!
  146. visible: printJob
  147. MonitorPrinterPill
  148. {
  149. text: printJob.configuration.printerType
  150. }
  151. }
  152. }
  153. }
  154. drawerItem: Row
  155. {
  156. anchors
  157. {
  158. left: parent.left
  159. leftMargin: 74 * screenScaleFactor // TODO: Theme!
  160. }
  161. height: 108 * screenScaleFactor // TODO: Theme!
  162. spacing: 18 * screenScaleFactor // TODO: Theme!
  163. MonitorPrinterConfiguration
  164. {
  165. id: printerConfiguration
  166. anchors.verticalCenter: parent.verticalCenter
  167. buildplate: catalog.i18nc("@label", "Glass")
  168. configurations:
  169. [
  170. base.printJob.configuration.extruderConfigurations[0],
  171. base.printJob.configuration.extruderConfigurations[1]
  172. ]
  173. height: 72 * screenScaleFactor // TODO: Theme!
  174. }
  175. Label {
  176. text: printJob && printJob.owner ? printJob.owner : ""
  177. color: UM.Theme.getColor("monitor_text_primary")
  178. elide: Text.ElideRight
  179. font: UM.Theme.getFont("medium") // 14pt, regular
  180. anchors.top: printerConfiguration.top
  181. // FIXED-LINE-HEIGHT:
  182. height: 18 * screenScaleFactor // TODO: Theme!
  183. verticalAlignment: Text.AlignVCenter
  184. renderType: Text.NativeRendering
  185. }
  186. }
  187. }
  188. MonitorContextMenuButton
  189. {
  190. id: contextMenuButton
  191. anchors
  192. {
  193. right: parent.right
  194. rightMargin: 8 * screenScaleFactor // TODO: Theme!
  195. top: parent.top
  196. topMargin: 8 * screenScaleFactor // TODO: Theme!
  197. }
  198. width: 32 * screenScaleFactor // TODO: Theme!
  199. height: 32 * screenScaleFactor // TODO: Theme!
  200. enabled: !cloudConnection
  201. onClicked: enabled ? contextMenu.switchPopupState() : {}
  202. visible:
  203. {
  204. if (!printJob) {
  205. return false
  206. }
  207. var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"]
  208. return states.indexOf(printJob.state) !== -1
  209. }
  210. }
  211. MonitorContextMenu
  212. {
  213. id: contextMenu
  214. printJob: base.printJob ? base.printJob : null
  215. target: contextMenuButton
  216. }
  217. // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available
  218. MouseArea
  219. {
  220. id: contextMenuDisabledButtonArea
  221. anchors.fill: contextMenuButton
  222. hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled
  223. onEntered: contextMenuDisabledInfo.open()
  224. onExited: contextMenuDisabledInfo.close()
  225. enabled: !contextMenuButton.enabled
  226. }
  227. MonitorInfoBlurb
  228. {
  229. id: contextMenuDisabledInfo
  230. text: catalog.i18nc("@info", "These options are not available because you are monitoring a cloud printer.")
  231. target: contextMenuButton
  232. }
  233. }