MonitorQueue.qml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.3 as UM
  7. import Cura 1.0 as Cura
  8. /**
  9. * This component contains the print job queue, extracted from the primary
  10. * MonitorStage.qml file not for reusability but simply to keep it lean and more
  11. * readable.
  12. */
  13. Item
  14. {
  15. // If the printer is a cloud printer or not. Other items base their enabled state off of this boolean. In the future
  16. // they might not need to though.
  17. property bool cloudConnection: Cura.MachineManager.activeMachineIsUsingCloudConnection
  18. Label
  19. {
  20. id: queuedLabel
  21. anchors
  22. {
  23. left: queuedPrintJobs.left
  24. top: parent.top
  25. }
  26. color: UM.Theme.getColor("monitor_text_primary")
  27. font: UM.Theme.getFont("large")
  28. text: catalog.i18nc("@label", "Queued")
  29. renderType: Text.NativeRendering
  30. }
  31. Item
  32. {
  33. id: manageQueueLabel
  34. anchors
  35. {
  36. right: queuedPrintJobs.right
  37. verticalCenter: queuedLabel.verticalCenter
  38. }
  39. height: 18 * screenScaleFactor // TODO: Theme!
  40. width: childrenRect.width
  41. visible: !cloudConnection
  42. UM.RecolorImage
  43. {
  44. id: externalLinkIcon
  45. anchors.verticalCenter: manageQueueLabel.verticalCenter
  46. color: UM.Theme.getColor("monitor_text_link")
  47. source: UM.Theme.getIcon("external_link")
  48. width: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
  49. height: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
  50. }
  51. Label
  52. {
  53. id: manageQueueText
  54. anchors
  55. {
  56. left: externalLinkIcon.right
  57. leftMargin: 6 * screenScaleFactor // TODO: Theme!
  58. verticalCenter: externalLinkIcon.verticalCenter
  59. }
  60. color: UM.Theme.getColor("monitor_text_link")
  61. font: UM.Theme.getFont("medium") // 14pt, regular
  62. linkColor: UM.Theme.getColor("monitor_text_link")
  63. text: catalog.i18nc("@label link to connect manager", "Go to Cura Connect")
  64. renderType: Text.NativeRendering
  65. }
  66. }
  67. MouseArea
  68. {
  69. anchors.fill: manageQueueLabel
  70. enabled: !cloudConnection
  71. hoverEnabled: !cloudConnection
  72. onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel()
  73. onEntered:
  74. {
  75. manageQueueText.font.underline = true
  76. }
  77. onExited:
  78. {
  79. manageQueueText.font.underline = false
  80. }
  81. }
  82. Row
  83. {
  84. id: printJobQueueHeadings
  85. anchors
  86. {
  87. left: queuedPrintJobs.left
  88. leftMargin: 6 * screenScaleFactor // TODO: Theme!
  89. top: queuedLabel.bottom
  90. topMargin: 24 * screenScaleFactor // TODO: Theme!
  91. }
  92. spacing: 18 * screenScaleFactor // TODO: Theme!
  93. Label
  94. {
  95. text: catalog.i18nc("@label", "Print jobs")
  96. color: UM.Theme.getColor("monitor_text_primary")
  97. elide: Text.ElideRight
  98. font: UM.Theme.getFont("medium") // 14pt, regular
  99. anchors.verticalCenter: parent.verticalCenter
  100. width: 284 * screenScaleFactor // TODO: Theme! (Should match column size)
  101. // FIXED-LINE-HEIGHT:
  102. height: 18 * screenScaleFactor // TODO: Theme!
  103. verticalAlignment: Text.AlignVCenter
  104. renderType: Text.NativeRendering
  105. }
  106. Label
  107. {
  108. text: catalog.i18nc("@label", "Total print time")
  109. color: UM.Theme.getColor("monitor_text_primary")
  110. elide: Text.ElideRight
  111. font: UM.Theme.getFont("medium") // 14pt, regular
  112. anchors.verticalCenter: parent.verticalCenter
  113. width: UM.Theme.getSize("monitor_column").width
  114. // FIXED-LINE-HEIGHT:
  115. height: 18 * screenScaleFactor // TODO: Theme!
  116. verticalAlignment: Text.AlignVCenter
  117. renderType: Text.NativeRendering
  118. }
  119. Label
  120. {
  121. text: catalog.i18nc("@label", "Waiting for")
  122. color: UM.Theme.getColor("monitor_text_primary")
  123. elide: Text.ElideRight
  124. font: UM.Theme.getFont("medium") // 14pt, regular
  125. anchors.verticalCenter: parent.verticalCenter
  126. width: UM.Theme.getSize("monitor_column").width
  127. // FIXED-LINE-HEIGHT:
  128. height: 18 * screenScaleFactor // TODO: Theme!
  129. verticalAlignment: Text.AlignVCenter
  130. renderType: Text.NativeRendering
  131. }
  132. }
  133. ScrollView
  134. {
  135. id: queuedPrintJobs
  136. anchors
  137. {
  138. bottom: parent.bottom
  139. horizontalCenter: parent.horizontalCenter
  140. top: printJobQueueHeadings.bottom
  141. topMargin: 12 * screenScaleFactor // TODO: Theme!
  142. }
  143. style: UM.Theme.styles.scrollview
  144. width: parent.width
  145. ListView
  146. {
  147. id: printJobList
  148. anchors.fill: parent
  149. delegate: MonitorPrintJobCard
  150. {
  151. anchors
  152. {
  153. left: parent.left
  154. right: parent.right
  155. }
  156. printJob: modelData
  157. }
  158. model:
  159. {
  160. // When printing over the cloud we don't recieve print jobs until there is one, so
  161. // unless there's at least one print job we'll be stuck with skeleton loading
  162. // indefinitely.
  163. if (Cura.MachineManager.activeMachineIsUsingCloudConnection || OutputDevice.receivedPrintJobs)
  164. {
  165. return OutputDevice.queuedPrintJobs
  166. }
  167. return [null, null]
  168. }
  169. spacing: 6 // TODO: Theme!
  170. }
  171. }
  172. Rectangle
  173. {
  174. anchors
  175. {
  176. horizontalCenter: parent.horizontalCenter
  177. top: printJobQueueHeadings.bottom
  178. topMargin: 12 * screenScaleFactor // TODO: Theme!
  179. }
  180. height: 48 * screenScaleFactor // TODO: Theme!
  181. width: parent.width
  182. color: UM.Theme.getColor("monitor_card_background")
  183. border.color: UM.Theme.getColor("monitor_card_border")
  184. radius: 2 * screenScaleFactor // TODO: Theme!
  185. visible: printJobList.model.length == 0
  186. Row
  187. {
  188. anchors
  189. {
  190. left: parent.left
  191. leftMargin: 18 * screenScaleFactor // TODO: Theme!
  192. verticalCenter: parent.verticalCenter
  193. }
  194. spacing: 18 * screenScaleFactor // TODO: Theme!
  195. height: 18 * screenScaleFactor // TODO: Theme!
  196. Label
  197. {
  198. text: i18n.i18nc("@info", "All jobs are printed.")
  199. color: UM.Theme.getColor("monitor_text_primary")
  200. font: UM.Theme.getFont("medium") // 14pt, regular
  201. renderType: Text.NativeRendering
  202. }
  203. Item
  204. {
  205. id: viewPrintHistoryLabel
  206. height: 18 * screenScaleFactor // TODO: Theme!
  207. width: childrenRect.width
  208. visible: !cloudConnection
  209. UM.RecolorImage
  210. {
  211. id: printHistoryIcon
  212. anchors.verticalCenter: parent.verticalCenter
  213. color: UM.Theme.getColor("monitor_text_link")
  214. source: UM.Theme.getIcon("external_link")
  215. width: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
  216. height: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
  217. }
  218. Label
  219. {
  220. id: viewPrintHistoryText
  221. anchors
  222. {
  223. left: printHistoryIcon.right
  224. leftMargin: 6 * screenScaleFactor // TODO: Theme!
  225. verticalCenter: printHistoryIcon.verticalCenter
  226. }
  227. color: UM.Theme.getColor("monitor_text_link")
  228. font: UM.Theme.getFont("medium") // 14pt, regular
  229. linkColor: UM.Theme.getColor("monitor_text_link")
  230. text: catalog.i18nc("@label link to connect manager", "View print history")
  231. renderType: Text.NativeRendering
  232. }
  233. MouseArea
  234. {
  235. anchors.fill: parent
  236. hoverEnabled: true
  237. onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel()
  238. onEntered:
  239. {
  240. viewPrintHistoryText.font.underline = true
  241. }
  242. onExited:
  243. {
  244. viewPrintHistoryText.font.underline = false
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }