MonitorQueue.qml 8.8 KB

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