PrintMonitor.qml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. // Copyright (c) 2017 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.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. import "PrinterOutput"
  10. Column
  11. {
  12. id: printMonitor
  13. property var connectedDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
  14. property var activePrinter: connectedDevice != null ? connectedDevice.activePrinter : null
  15. property var activePrintJob: activePrinter != null ? activePrinter.activePrintJob: null
  16. Cura.ExtrudersModel
  17. {
  18. id: extrudersModel
  19. simpleNames: true
  20. }
  21. OutputDeviceHeader
  22. {
  23. width: parent.width
  24. outputDevice: connectedDevice
  25. }
  26. Rectangle
  27. {
  28. color: UM.Theme.getColor("sidebar_lining")
  29. width: parent.width
  30. height: childrenRect.height
  31. Flow
  32. {
  33. id: extrudersGrid
  34. spacing: UM.Theme.getSize("sidebar_lining_thin").width
  35. width: parent.width
  36. Repeater
  37. {
  38. id: extrudersRepeater
  39. model: activePrinter.extruders
  40. ExtruderBox
  41. {
  42. color: UM.Theme.getColor("sidebar")
  43. width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : Math.floor(extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2)
  44. extruderModel: modelData
  45. }
  46. }
  47. }
  48. }
  49. Rectangle
  50. {
  51. color: UM.Theme.getColor("sidebar_lining")
  52. width: parent.width
  53. height: UM.Theme.getSize("sidebar_lining_thin").width
  54. }
  55. HeatedBedBox
  56. {
  57. visible: {
  58. if(activePrinter != null && activePrinter.bed_temperature != -1)
  59. {
  60. return true
  61. }
  62. return false
  63. }
  64. printerModel: activePrinter
  65. }
  66. UM.SettingPropertyProvider
  67. {
  68. id: bedTemperature
  69. containerStackId: Cura.MachineManager.activeMachineId
  70. key: "material_bed_temperature"
  71. watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
  72. storeIndex: 0
  73. property var resolve: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId ? properties.resolve : "None"
  74. }
  75. UM.SettingPropertyProvider
  76. {
  77. id: machineExtruderCount
  78. containerStackId: Cura.MachineManager.activeMachineId
  79. key: "machine_extruder_count"
  80. watchedProperties: ["value"]
  81. }
  82. Column
  83. {
  84. visible: connectedPrinter != null ? connectedPrinter.canControlManually : false
  85. enabled:
  86. {
  87. if (connectedPrinter == null || activePrintJob == null)
  88. {
  89. return false; //Can't control the printer if not connected or if there is no print job.
  90. }
  91. if (!connectedPrinter.acceptsCommands)
  92. {
  93. return false; //Not allowed to do anything.
  94. }
  95. if (activePrintJob.state == "printing" || activePrintJob.state == "resuming" || activePrintJob.state == "pausing" || activePrintJob.state == "error" || activePrintJob.state == "offline")
  96. {
  97. return false; //Printer is in a state where it can't react to manual control
  98. }
  99. return true;
  100. }
  101. Loader
  102. {
  103. sourceComponent: monitorSection
  104. property string label: catalog.i18nc("@label", "Printer control")
  105. }
  106. Row
  107. {
  108. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  109. height: childrenRect.height + UM.Theme.getSize("default_margin").width
  110. anchors.left: parent.left
  111. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  112. spacing: UM.Theme.getSize("default_margin").width
  113. Label
  114. {
  115. text: catalog.i18nc("@label", "Jog Position")
  116. color: UM.Theme.getColor("setting_control_text")
  117. font: UM.Theme.getFont("default")
  118. width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
  119. height: UM.Theme.getSize("setting_control").height
  120. verticalAlignment: Text.AlignVCenter
  121. }
  122. GridLayout
  123. {
  124. columns: 3
  125. rows: 4
  126. rowSpacing: UM.Theme.getSize("default_lining").width
  127. columnSpacing: UM.Theme.getSize("default_lining").height
  128. Label
  129. {
  130. text: catalog.i18nc("@label", "X/Y")
  131. color: UM.Theme.getColor("setting_control_text")
  132. font: UM.Theme.getFont("default")
  133. width: height
  134. height: UM.Theme.getSize("setting_control").height
  135. verticalAlignment: Text.AlignVCenter
  136. horizontalAlignment: Text.AlignHCenter
  137. Layout.row: 1
  138. Layout.column: 2
  139. Layout.preferredWidth: width
  140. Layout.preferredHeight: height
  141. }
  142. Button
  143. {
  144. Layout.row: 2
  145. Layout.column: 2
  146. Layout.preferredWidth: width
  147. Layout.preferredHeight: height
  148. iconSource: UM.Theme.getIcon("arrow_top");
  149. style: monitorButtonStyle
  150. width: height
  151. height: UM.Theme.getSize("setting_control").height
  152. onClicked:
  153. {
  154. connectedPrinter.moveHead(0, distancesRow.currentDistance, 0)
  155. }
  156. }
  157. Button
  158. {
  159. Layout.row: 3
  160. Layout.column: 1
  161. Layout.preferredWidth: width
  162. Layout.preferredHeight: height
  163. iconSource: UM.Theme.getIcon("arrow_left");
  164. style: monitorButtonStyle
  165. width: height
  166. height: UM.Theme.getSize("setting_control").height
  167. onClicked:
  168. {
  169. connectedPrinter.moveHead(-distancesRow.currentDistance, 0, 0)
  170. }
  171. }
  172. Button
  173. {
  174. Layout.row: 3
  175. Layout.column: 3
  176. Layout.preferredWidth: width
  177. Layout.preferredHeight: height
  178. iconSource: UM.Theme.getIcon("arrow_right");
  179. style: monitorButtonStyle
  180. width: height
  181. height: UM.Theme.getSize("setting_control").height
  182. onClicked:
  183. {
  184. connectedPrinter.moveHead(distancesRow.currentDistance, 0, 0)
  185. }
  186. }
  187. Button
  188. {
  189. Layout.row: 4
  190. Layout.column: 2
  191. Layout.preferredWidth: width
  192. Layout.preferredHeight: height
  193. iconSource: UM.Theme.getIcon("arrow_bottom");
  194. style: monitorButtonStyle
  195. width: height
  196. height: UM.Theme.getSize("setting_control").height
  197. onClicked:
  198. {
  199. connectedPrinter.moveHead(0, -distancesRow.currentDistance, 0)
  200. }
  201. }
  202. Button
  203. {
  204. Layout.row: 3
  205. Layout.column: 2
  206. Layout.preferredWidth: width
  207. Layout.preferredHeight: height
  208. iconSource: UM.Theme.getIcon("home");
  209. style: monitorButtonStyle
  210. width: height
  211. height: UM.Theme.getSize("setting_control").height
  212. onClicked:
  213. {
  214. connectedPrinter.homeHead()
  215. }
  216. }
  217. }
  218. Column
  219. {
  220. spacing: UM.Theme.getSize("default_lining").height
  221. Label
  222. {
  223. text: catalog.i18nc("@label", "Z")
  224. color: UM.Theme.getColor("setting_control_text")
  225. font: UM.Theme.getFont("default")
  226. width: UM.Theme.getSize("section").height
  227. height: UM.Theme.getSize("setting_control").height
  228. verticalAlignment: Text.AlignVCenter
  229. horizontalAlignment: Text.AlignHCenter
  230. }
  231. Button
  232. {
  233. iconSource: UM.Theme.getIcon("arrow_top");
  234. style: monitorButtonStyle
  235. width: height
  236. height: UM.Theme.getSize("setting_control").height
  237. onClicked:
  238. {
  239. connectedPrinter.moveHead(0, 0, distancesRow.currentDistance)
  240. }
  241. }
  242. Button
  243. {
  244. iconSource: UM.Theme.getIcon("home");
  245. style: monitorButtonStyle
  246. width: height
  247. height: UM.Theme.getSize("setting_control").height
  248. onClicked:
  249. {
  250. connectedPrinter.homeBed()
  251. }
  252. }
  253. Button
  254. {
  255. iconSource: UM.Theme.getIcon("arrow_bottom");
  256. style: monitorButtonStyle
  257. width: height
  258. height: UM.Theme.getSize("setting_control").height
  259. onClicked:
  260. {
  261. connectedPrinter.moveHead(0, 0, -distancesRow.currentDistance)
  262. }
  263. }
  264. }
  265. }
  266. Row
  267. {
  268. id: distancesRow
  269. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  270. height: childrenRect.height + UM.Theme.getSize("default_margin").width
  271. anchors.left: parent.left
  272. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  273. spacing: UM.Theme.getSize("default_margin").width
  274. property real currentDistance: 10
  275. Label
  276. {
  277. text: catalog.i18nc("@label", "Jog Distance")
  278. color: UM.Theme.getColor("setting_control_text")
  279. font: UM.Theme.getFont("default")
  280. width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
  281. height: UM.Theme.getSize("setting_control").height
  282. verticalAlignment: Text.AlignVCenter
  283. }
  284. Row
  285. {
  286. Repeater
  287. {
  288. model: distancesModel
  289. delegate: Button
  290. {
  291. height: UM.Theme.getSize("setting_control").height
  292. width: height + UM.Theme.getSize("default_margin").width
  293. text: model.label
  294. exclusiveGroup: distanceGroup
  295. checkable: true
  296. checked: distancesRow.currentDistance == model.value
  297. onClicked: distancesRow.currentDistance = model.value
  298. style: ButtonStyle {
  299. background: Rectangle {
  300. border.width: control.checked ? UM.Theme.getSize("default_lining").width * 2 : UM.Theme.getSize("default_lining").width
  301. border.color:
  302. {
  303. if(!control.enabled)
  304. {
  305. return UM.Theme.getColor("action_button_disabled_border");
  306. }
  307. else if (control.checked || control.pressed)
  308. {
  309. return UM.Theme.getColor("action_button_active_border");
  310. }
  311. else if(control.hovered)
  312. {
  313. return UM.Theme.getColor("action_button_hovered_border");
  314. }
  315. return UM.Theme.getColor("action_button_border");
  316. }
  317. color:
  318. {
  319. if(!control.enabled)
  320. {
  321. return UM.Theme.getColor("action_button_disabled");
  322. }
  323. else if (control.checked || control.pressed)
  324. {
  325. return UM.Theme.getColor("action_button_active");
  326. }
  327. else if (control.hovered)
  328. {
  329. return UM.Theme.getColor("action_button_hovered");
  330. }
  331. return UM.Theme.getColor("action_button");
  332. }
  333. Behavior on color { ColorAnimation { duration: 50; } }
  334. Label {
  335. anchors.left: parent.left
  336. anchors.right: parent.right
  337. anchors.verticalCenter: parent.verticalCenter
  338. anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2
  339. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  340. color:
  341. {
  342. if(!control.enabled)
  343. {
  344. return UM.Theme.getColor("action_button_disabled_text");
  345. }
  346. else if (control.checked || control.pressed)
  347. {
  348. return UM.Theme.getColor("action_button_active_text");
  349. }
  350. else if (control.hovered)
  351. {
  352. return UM.Theme.getColor("action_button_hovered_text");
  353. }
  354. return UM.Theme.getColor("action_button_text");
  355. }
  356. font: UM.Theme.getFont("default")
  357. text: control.text
  358. horizontalAlignment: Text.AlignHCenter
  359. elide: Text.ElideMiddle
  360. }
  361. }
  362. label: Item { }
  363. }
  364. }
  365. }
  366. }
  367. }
  368. ListModel
  369. {
  370. id: distancesModel
  371. ListElement { label: "0.1"; value: 0.1 }
  372. ListElement { label: "1"; value: 1 }
  373. ListElement { label: "10"; value: 10 }
  374. ListElement { label: "100"; value: 100 }
  375. }
  376. ExclusiveGroup { id: distanceGroup }
  377. }
  378. Loader
  379. {
  380. sourceComponent: monitorSection
  381. property string label: catalog.i18nc("@label", "Active print")
  382. }
  383. Loader
  384. {
  385. sourceComponent: monitorItem
  386. property string label: catalog.i18nc("@label", "Job Name")
  387. property string value: activePrintJob != null ? activePrintJob.name : ""
  388. }
  389. Loader
  390. {
  391. sourceComponent: monitorItem
  392. property string label: catalog.i18nc("@label", "Printing Time")
  393. property string value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal) : ""
  394. }
  395. Loader
  396. {
  397. sourceComponent: monitorItem
  398. property string label: catalog.i18nc("@label", "Estimated time left")
  399. property string value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal - activePrintJob.timeElapsed) : ""
  400. visible:
  401. {
  402. if(activePrintJob == null)
  403. {
  404. return false
  405. }
  406. return (activePrintJob.state == "printing" ||
  407. activePrintJob.state == "resuming" ||
  408. activePrintJob.state == "pausing" ||
  409. activePrintJob.state == "paused")
  410. }
  411. }
  412. Component
  413. {
  414. id: monitorItem
  415. Row
  416. {
  417. height: UM.Theme.getSize("setting_control").height
  418. width: Math.floor(base.width - 2 * UM.Theme.getSize("default_margin").width)
  419. anchors.left: parent.left
  420. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  421. Label
  422. {
  423. width: Math.floor(parent.width * 0.4)
  424. anchors.verticalCenter: parent.verticalCenter
  425. text: label
  426. color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  427. font: UM.Theme.getFont("default")
  428. elide: Text.ElideRight
  429. }
  430. Label
  431. {
  432. width: Math.floor(parent.width * 0.6)
  433. anchors.verticalCenter: parent.verticalCenter
  434. text: value
  435. color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  436. font: UM.Theme.getFont("default")
  437. elide: Text.ElideRight
  438. }
  439. }
  440. }
  441. Component
  442. {
  443. id: monitorSection
  444. Rectangle
  445. {
  446. color: UM.Theme.getColor("setting_category")
  447. width: base.width
  448. height: UM.Theme.getSize("section").height
  449. Label
  450. {
  451. anchors.verticalCenter: parent.verticalCenter
  452. anchors.left: parent.left
  453. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  454. text: label
  455. font: UM.Theme.getFont("setting_category")
  456. color: UM.Theme.getColor("setting_category_text")
  457. }
  458. }
  459. }
  460. Component
  461. {
  462. id: monitorButtonStyle
  463. ButtonStyle
  464. {
  465. background: Rectangle
  466. {
  467. border.width: UM.Theme.getSize("default_lining").width
  468. border.color:
  469. {
  470. if(!control.enabled)
  471. {
  472. return UM.Theme.getColor("action_button_disabled_border");
  473. }
  474. else if(control.pressed)
  475. {
  476. return UM.Theme.getColor("action_button_active_border");
  477. }
  478. else if(control.hovered)
  479. {
  480. return UM.Theme.getColor("action_button_hovered_border");
  481. }
  482. return UM.Theme.getColor("action_button_border");
  483. }
  484. color:
  485. {
  486. if(!control.enabled)
  487. {
  488. return UM.Theme.getColor("action_button_disabled");
  489. }
  490. else if(control.pressed)
  491. {
  492. return UM.Theme.getColor("action_button_active");
  493. }
  494. else if(control.hovered)
  495. {
  496. return UM.Theme.getColor("action_button_hovered");
  497. }
  498. return UM.Theme.getColor("action_button");
  499. }
  500. Behavior on color
  501. {
  502. ColorAnimation
  503. {
  504. duration: 50
  505. }
  506. }
  507. }
  508. label: Item
  509. {
  510. UM.RecolorImage
  511. {
  512. anchors.verticalCenter: parent.verticalCenter
  513. anchors.horizontalCenter: parent.horizontalCenter
  514. width: Math.floor(control.width / 2)
  515. height: Math.floor(control.height / 2)
  516. sourceSize.width: width
  517. sourceSize.height: width
  518. color:
  519. {
  520. if(!control.enabled)
  521. {
  522. return UM.Theme.getColor("action_button_disabled_text");
  523. }
  524. else if(control.pressed)
  525. {
  526. return UM.Theme.getColor("action_button_active_text");
  527. }
  528. else if(control.hovered)
  529. {
  530. return UM.Theme.getColor("action_button_hovered_text");
  531. }
  532. return UM.Theme.getColor("action_button_text");
  533. }
  534. source: control.iconSource
  535. }
  536. }
  537. }
  538. }
  539. }