MonitorPrintJobCard.qml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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: Math.round(48 * screenScaleFactor) // TODO: Theme!
  30. anchors.left: parent.left
  31. anchors.leftMargin: Math.round(24 * screenScaleFactor) // TODO: Theme!
  32. spacing: Math.round(18 * screenScaleFactor) // TODO: Theme!
  33. MonitorPrintJobPreview
  34. {
  35. printJob: base.printJob
  36. size: Math.round(32 * screenScaleFactor) // TODO: Theme!
  37. anchors.verticalCenter: parent.verticalCenter
  38. }
  39. Item
  40. {
  41. anchors.verticalCenter: parent.verticalCenter
  42. height: Math.round(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("text")
  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: Math.round(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("text")
  83. elide: Text.ElideRight
  84. font: UM.Theme.getFont("medium") // 14pt, regular
  85. visible: printJob
  86. // FIXED-LINE-HEIGHT:
  87. height: Math.round(18 * screenScaleFactor) // TODO: Theme!
  88. verticalAlignment: Text.AlignVCenter
  89. renderType: Text.NativeRendering
  90. }
  91. }
  92. Item
  93. {
  94. anchors.verticalCenter: parent.verticalCenter
  95. height: Math.round(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: Math.round(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("text")
  110. elide: Text.ElideRight
  111. font: UM.Theme.getFont("medium") // 14pt, regular
  112. text: {
  113. if (printJob !== null)
  114. {
  115. if (printJob.assignedPrinter == null)
  116. {
  117. if (printJob.state == "error")
  118. {
  119. return catalog.i18nc("@label", "Unavailable printer");
  120. }
  121. return catalog.i18nc("@label", "First available");
  122. }
  123. return printJob.assignedPrinter.name;
  124. }
  125. return "";
  126. }
  127. visible: printJob
  128. width: Math.round(120 * screenScaleFactor) // TODO: Theme!
  129. // FIXED-LINE-HEIGHT:
  130. height: parent.height
  131. verticalAlignment: Text.AlignVCenter
  132. renderType: Text.NativeRendering
  133. }
  134. Row
  135. {
  136. id: printerFamilyPills
  137. anchors
  138. {
  139. left: printerAssignmentLabel.right;
  140. leftMargin: Math.round(12 * screenScaleFactor) // TODO: Theme!
  141. verticalCenter: parent.verticalCenter
  142. }
  143. height: childrenRect.height
  144. spacing: Math.round(6 * screenScaleFactor) // TODO: Theme!
  145. visible: printJob
  146. MonitorPrinterPill
  147. {
  148. text: printJob.configuration.printerType
  149. }
  150. }
  151. }
  152. }
  153. drawerItem: Row
  154. {
  155. anchors
  156. {
  157. left: parent.left
  158. leftMargin: Math.round(74 * screenScaleFactor) // TODO: Theme!
  159. }
  160. height: Math.round(108 * screenScaleFactor) // TODO: Theme!
  161. spacing: Math.round(18 * screenScaleFactor) // TODO: Theme!
  162. MonitorPrinterConfiguration
  163. {
  164. id: printerConfiguration
  165. anchors.verticalCenter: parent.verticalCenter
  166. buildplate: catalog.i18nc("@label", "Glass")
  167. configurations: base.printJob.configuration.extruderConfigurations
  168. height: Math.round(72 * screenScaleFactor) // TODO: Theme!
  169. }
  170. Label {
  171. text: printJob && printJob.owner ? printJob.owner : ""
  172. color: UM.Theme.getColor("text")
  173. elide: Text.ElideRight
  174. font: UM.Theme.getFont("medium") // 14pt, regular
  175. anchors.top: printerConfiguration.top
  176. // FIXED-LINE-HEIGHT:
  177. height: Math.round(18 * screenScaleFactor) // TODO: Theme!
  178. verticalAlignment: Text.AlignVCenter
  179. renderType: Text.NativeRendering
  180. }
  181. }
  182. }
  183. MonitorContextMenuButton
  184. {
  185. id: contextMenuButton
  186. anchors
  187. {
  188. right: parent.right
  189. rightMargin: Math.round(8 * screenScaleFactor) // TODO: Theme!
  190. top: parent.top
  191. topMargin: Math.round(8 * screenScaleFactor) // TODO: Theme!
  192. }
  193. width: Math.round(32 * screenScaleFactor) // TODO: Theme!
  194. height: Math.round(32 * screenScaleFactor) // TODO: Theme!
  195. enabled: OutputDevice.supportsPrintJobActions
  196. onClicked: enabled ? contextMenu.switchPopupState() : {}
  197. visible:
  198. {
  199. if (!printJob)
  200. {
  201. return false;
  202. }
  203. var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"];
  204. return states.indexOf(printJob.state) !== -1;
  205. }
  206. }
  207. MonitorContextMenu
  208. {
  209. id: contextMenu
  210. printJob: base.printJob ? base.printJob : null
  211. target: contextMenuButton
  212. }
  213. // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available
  214. MouseArea
  215. {
  216. id: contextMenuDisabledButtonArea
  217. anchors.fill: contextMenuButton
  218. hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled
  219. onEntered: contextMenuDisabledInfo.open()
  220. onExited: contextMenuDisabledInfo.close()
  221. enabled: !contextMenuButton.enabled
  222. }
  223. MonitorInfoBlurb
  224. {
  225. id: contextMenuDisabledInfo
  226. text: catalog.i18nc("@info", "Please update your printer's firmware to manage the queue remotely.")
  227. target: contextMenuButton
  228. }
  229. }