PrintJobInfoBlock.qml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. import QtQuick 2.2
  2. import QtQuick.Controls 2.0
  3. import QtQuick.Controls.Styles 1.4
  4. import QtGraphicalEffects 1.0
  5. import UM 1.3 as UM
  6. Item
  7. {
  8. id: base
  9. property var printJob: null
  10. property var shadowRadius: 5
  11. function getPrettyTime(time)
  12. {
  13. return OutputDevice.formatDuration(time)
  14. }
  15. UM.I18nCatalog
  16. {
  17. id: catalog
  18. name: "cura"
  19. }
  20. Rectangle
  21. {
  22. id: background
  23. anchors
  24. {
  25. top: parent.top
  26. topMargin: 3
  27. left: parent.left
  28. leftMargin: base.shadowRadius
  29. rightMargin: base.shadowRadius
  30. right: parent.right
  31. bottom: parent.bottom
  32. bottomMargin: base.shadowRadius
  33. }
  34. layer.enabled: true
  35. layer.effect: DropShadow
  36. {
  37. radius: base.shadowRadius
  38. verticalOffset: 2
  39. color: "#3F000000" // 25% shadow
  40. }
  41. Item
  42. {
  43. // Content on the left of the infobox
  44. anchors
  45. {
  46. top: parent.top
  47. bottom: parent.bottom
  48. left: parent.left
  49. right: parent.horizontalCenter
  50. margins: 2 * UM.Theme.getSize("default_margin").width
  51. rightMargin: UM.Theme.getSize("default_margin").width
  52. }
  53. Label
  54. {
  55. id: printJobName
  56. text: printJob.name
  57. font: UM.Theme.getFont("default_bold")
  58. width: parent.width
  59. elide: Text.ElideRight
  60. }
  61. Label
  62. {
  63. id: ownerName
  64. anchors.top: printJobName.bottom
  65. text: printJob.owner
  66. font: UM.Theme.getFont("default")
  67. opacity: 0.6
  68. width: parent.width
  69. elide: Text.ElideRight
  70. }
  71. Image
  72. {
  73. source: printJob.previewImageUrl
  74. anchors.top: ownerName.bottom
  75. anchors.horizontalCenter: parent.horizontalCenter
  76. anchors.bottom: totalTimeLabel.bottom
  77. width: height
  78. }
  79. Label
  80. {
  81. id: totalTimeLabel
  82. opacity: 0.6
  83. anchors.bottom: parent.bottom
  84. anchors.right: parent.right
  85. font: UM.Theme.getFont("default")
  86. text: printJob != null ? getPrettyTime(printJob.timeTotal) : ""
  87. elide: Text.ElideRight
  88. }
  89. }
  90. Item
  91. {
  92. // Content on the right side of the infobox.
  93. anchors
  94. {
  95. top: parent.top
  96. bottom: parent.bottom
  97. left: parent.horizontalCenter
  98. right: parent.right
  99. margins: 2 * UM.Theme.getSize("default_margin").width
  100. leftMargin: UM.Theme.getSize("default_margin").width
  101. }
  102. Label
  103. {
  104. id: targetPrinterLabel
  105. elide: Text.ElideRight
  106. font: UM.Theme.getFont("default_bold")
  107. text:
  108. {
  109. if(printJob.assignedPrinter == null)
  110. {
  111. return catalog.i18nc("@label", "Waiting for: first available")
  112. }
  113. else
  114. {
  115. return catalog.i18nc("@label", "Waiting for: ") + printJob.assignedPrinter.name
  116. }
  117. }
  118. anchors
  119. {
  120. left: parent.left
  121. right: contextButton.left
  122. rightMargin: UM.Theme.getSize("default_margin").width
  123. }
  124. }
  125. function switchPopupState()
  126. {
  127. popup.visible ? popup.close() : popup.open()
  128. }
  129. Button
  130. {
  131. id: contextButton
  132. text: "\u22EE" //Unicode; Three stacked points.
  133. font.pixelSize: 25
  134. width: 35
  135. height: width
  136. anchors
  137. {
  138. right: parent.right
  139. top: parent.top
  140. }
  141. hoverEnabled: true
  142. background: Rectangle
  143. {
  144. opacity: contextButton.down || contextButton.hovered ? 1 : 0
  145. width: contextButton.width
  146. height: contextButton.height
  147. radius: 0.5 * width
  148. color: UM.Theme.getColor("viewport_background")
  149. }
  150. onClicked: parent.switchPopupState()
  151. }
  152. Popup
  153. {
  154. // TODO Change once updating to Qt5.10 - The 'opened' property is in 5.10 but the behavior is now implemented with the visible property
  155. id: popup
  156. clip: true
  157. closePolicy: Popup.CloseOnPressOutsideParent
  158. x: parent.width - width
  159. y: contextButton.height
  160. width: 160
  161. height: contentItem.height + 2 * padding
  162. visible: false
  163. transformOrigin: Popup.Top
  164. contentItem: Item
  165. {
  166. width: popup.width - 2 * popup.padding
  167. height: childrenRect.height + 15
  168. Button
  169. {
  170. id: sendToTopButton
  171. text: catalog.i18nc("@label", "Move to top")
  172. onClicked:
  173. {
  174. OutputDevice.sendJobToTop(printJob.key)
  175. popup.close()
  176. }
  177. width: parent.width
  178. enabled: OutputDevice.printJobs[0].key != printJob.key
  179. anchors.top: parent.top
  180. anchors.topMargin: 10
  181. hoverEnabled: true
  182. background: Rectangle
  183. {
  184. opacity: sendToTopButton.down || sendToTopButton.hovered ? 1 : 0
  185. color: UM.Theme.getColor("viewport_background")
  186. }
  187. }
  188. Button
  189. {
  190. id: deleteButton
  191. text: catalog.i18nc("@label", "Delete")
  192. onClicked:
  193. {
  194. OutputDevice.deleteJobFromQueue(printJob.key)
  195. popup.close()
  196. }
  197. width: parent.width
  198. anchors.top: sendToTopButton.bottom
  199. hoverEnabled: true
  200. background: Rectangle
  201. {
  202. opacity: deleteButton.down || deleteButton.hovered ? 1 : 0
  203. color: UM.Theme.getColor("viewport_background")
  204. }
  205. }
  206. }
  207. background: Item
  208. {
  209. width: popup.width
  210. height: popup.height
  211. DropShadow
  212. {
  213. anchors.fill: pointedRectangle
  214. radius: 5
  215. color: "#3F000000" // 25% shadow
  216. source: pointedRectangle
  217. transparentBorder: true
  218. verticalOffset: 2
  219. }
  220. Item
  221. {
  222. id: pointedRectangle
  223. width: parent.width -10
  224. height: parent.height -10
  225. anchors.horizontalCenter: parent.horizontalCenter
  226. anchors.verticalCenter: parent.verticalCenter
  227. Rectangle
  228. {
  229. id: point
  230. height: 13
  231. width: 13
  232. color: UM.Theme.getColor("setting_control")
  233. transform: Rotation { angle: 45}
  234. anchors.right: bloop.right
  235. y: 1
  236. }
  237. Rectangle
  238. {
  239. id: bloop
  240. color: UM.Theme.getColor("setting_control")
  241. width: parent.width
  242. anchors.top: parent.top
  243. anchors.topMargin: 10
  244. anchors.bottom: parent.bottom
  245. anchors.bottomMargin: 5
  246. }
  247. }
  248. }
  249. exit: Transition
  250. {
  251. // This applies a default NumberAnimation to any changes a state change makes to x or y properties
  252. NumberAnimation { property: "visible"; duration: 75; }
  253. }
  254. enter: Transition
  255. {
  256. // This applies a default NumberAnimation to any changes a state change makes to x or y properties
  257. NumberAnimation { property: "visible"; duration: 75; }
  258. }
  259. onClosed: visible = false
  260. onOpened: visible = true
  261. }
  262. Row
  263. {
  264. id: printerFamilyPills
  265. spacing: 0.5 * UM.Theme.getSize("default_margin").width
  266. anchors
  267. {
  268. left: parent.left
  269. right: parent.right
  270. bottom: extrudersInfo.top
  271. bottomMargin: UM.Theme.getSize("default_margin").height
  272. }
  273. height: childrenRect.height
  274. Repeater
  275. {
  276. model: printJob.compatibleMachineFamilies
  277. delegate: PrinterFamilyPill
  278. {
  279. text: modelData
  280. color: UM.Theme.getColor("viewport_background")
  281. padding: 3
  282. }
  283. }
  284. }
  285. // PrintCore && Material config
  286. Row
  287. {
  288. id: extrudersInfo
  289. anchors.bottom: parent.bottom
  290. anchors
  291. {
  292. left: parent.left
  293. right: parent.right
  294. }
  295. height: childrenRect.height
  296. spacing: UM.Theme.getSize("default_margin").width
  297. PrintCoreConfiguration
  298. {
  299. id: leftExtruderInfo
  300. width: Math.round(parent.width / 2)
  301. printCoreConfiguration: printJob.configuration.extruderConfigurations[0]
  302. }
  303. PrintCoreConfiguration
  304. {
  305. id: rightExtruderInfo
  306. width: Math.round(parent.width / 2)
  307. printCoreConfiguration: printJob.configuration.extruderConfigurations[1]
  308. }
  309. }
  310. }
  311. Rectangle
  312. {
  313. color: UM.Theme.getColor("viewport_background")
  314. width: 2
  315. anchors.top: parent.top
  316. anchors.bottom: parent.bottom
  317. anchors.margins: UM.Theme.getSize("default_margin").height
  318. anchors.horizontalCenter: parent.horizontalCenter
  319. }
  320. }
  321. }