MonitorQueue.qml 9.0 KB

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