PrintMonitor.qml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 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. Column
  10. {
  11. id: printMonitor
  12. property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
  13. Cura.ExtrudersModel
  14. {
  15. id: extrudersModel
  16. simpleNames: true
  17. }
  18. Rectangle
  19. {
  20. id: connectedPrinterHeader
  21. width: parent.width
  22. height: childrenRect.height + UM.Theme.getSize("default_margin").height * 2
  23. color: UM.Theme.getColor("setting_category")
  24. Text
  25. {
  26. id: connectedPrinterNameLabel
  27. text: connectedPrinter != null ? connectedPrinter.name : catalog.i18nc("@info:status", "No printer connected")
  28. font: UM.Theme.getFont("large")
  29. color: UM.Theme.getColor("text")
  30. anchors.left: parent.left
  31. anchors.top: parent.top
  32. anchors.margins: UM.Theme.getSize("default_margin").width
  33. }
  34. Text
  35. {
  36. id: connectedPrinterAddressLabel
  37. text: (connectedPrinter != null && connectedPrinter.address != null) ? connectedPrinter.address : ""
  38. font: UM.Theme.getFont("small")
  39. color: UM.Theme.getColor("text_inactive")
  40. anchors.top: parent.top
  41. anchors.right: parent.right
  42. anchors.margins: UM.Theme.getSize("default_margin").width
  43. }
  44. Text
  45. {
  46. text: connectedPrinter != null ? connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.")
  47. color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  48. font: UM.Theme.getFont("very_small")
  49. wrapMode: Text.WordWrap
  50. anchors.left: parent.left
  51. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  52. anchors.right: parent.right
  53. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  54. anchors.top: connectedPrinterNameLabel.bottom
  55. }
  56. }
  57. Rectangle
  58. {
  59. color: UM.Theme.getColor("sidebar_lining")
  60. width: parent.width
  61. height: childrenRect.height
  62. Flow
  63. {
  64. id: extrudersGrid
  65. spacing: UM.Theme.getSize("sidebar_lining_thin").width
  66. width: parent.width
  67. Repeater
  68. {
  69. id: extrudersRepeater
  70. model: machineExtruderCount.properties.value
  71. delegate: Rectangle
  72. {
  73. id: extruderRectangle
  74. color: UM.Theme.getColor("sidebar")
  75. width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2
  76. height: UM.Theme.getSize("sidebar_extruder_box").height
  77. Text //Extruder name.
  78. {
  79. text: ExtruderManager.getExtruderName(index) != "" ? ExtruderManager.getExtruderName(index) : catalog.i18nc("@label", "Hotend")
  80. color: UM.Theme.getColor("text")
  81. font: UM.Theme.getFont("default")
  82. anchors.left: parent.left
  83. anchors.top: parent.top
  84. anchors.margins: UM.Theme.getSize("default_margin").width
  85. }
  86. Text //Temperature indication.
  87. {
  88. id: extruderTemperature
  89. text: (connectedPrinter != null && connectedPrinter.hotendIds[index] != null && connectedPrinter.hotendTemperatures[index] != null) ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : ""
  90. color: UM.Theme.getColor("text")
  91. font: UM.Theme.getFont("large")
  92. anchors.right: parent.right
  93. anchors.top: parent.top
  94. anchors.margins: UM.Theme.getSize("default_margin").width
  95. MouseArea //For tooltip.
  96. {
  97. id: extruderTemperatureTooltipArea
  98. hoverEnabled: true
  99. anchors.fill: parent
  100. onHoveredChanged:
  101. {
  102. if (containsMouse)
  103. {
  104. base.showTooltip(
  105. base,
  106. {x: 0, y: parent.mapToItem(base, 0, -parent.height / 4).y},
  107. catalog.i18nc("@tooltip", "The current temperature of this extruder.")
  108. );
  109. }
  110. else
  111. {
  112. base.hideTooltip();
  113. }
  114. }
  115. }
  116. }
  117. Rectangle //Material colour indication.
  118. {
  119. id: materialColor
  120. width: materialName.height * 0.75
  121. height: materialName.height * 0.75
  122. color: (connectedPrinter != null && connectedPrinter.materialColors[index] != null && connectedPrinter.materialIds[index] != "") ? connectedPrinter.materialColors[index] : "#00000000"
  123. border.width: UM.Theme.getSize("default_lining").width
  124. border.color: UM.Theme.getColor("lining")
  125. visible: connectedPrinter != null && connectedPrinter.materialColors[index] != null && connectedPrinter.materialIds[index] != ""
  126. anchors.left: parent.left
  127. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  128. anchors.verticalCenter: materialName.verticalCenter
  129. MouseArea //For tooltip.
  130. {
  131. id: materialColorTooltipArea
  132. hoverEnabled: true
  133. anchors.fill: parent
  134. onHoveredChanged:
  135. {
  136. if (containsMouse)
  137. {
  138. base.showTooltip(
  139. base,
  140. {x: 0, y: parent.mapToItem(base, 0, -parent.height / 2).y},
  141. catalog.i18nc("@tooltip", "The colour of the material in this extruder.")
  142. );
  143. }
  144. else
  145. {
  146. base.hideTooltip();
  147. }
  148. }
  149. }
  150. }
  151. Text //Material name.
  152. {
  153. id: materialName
  154. text: (connectedPrinter != null && connectedPrinter.materialNames[index] != null && connectedPrinter.materialIds[index] != "") ? connectedPrinter.materialNames[index] : ""
  155. font: UM.Theme.getFont("default")
  156. color: UM.Theme.getColor("text")
  157. anchors.left: materialColor.right
  158. anchors.bottom: parent.bottom
  159. anchors.margins: UM.Theme.getSize("default_margin").width
  160. MouseArea //For tooltip.
  161. {
  162. id: materialNameTooltipArea
  163. hoverEnabled: true
  164. anchors.fill: parent
  165. onHoveredChanged:
  166. {
  167. if (containsMouse)
  168. {
  169. base.showTooltip(
  170. base,
  171. {x: 0, y: parent.mapToItem(base, 0, 0).y},
  172. catalog.i18nc("@tooltip", "The material in this extruder.")
  173. );
  174. }
  175. else
  176. {
  177. base.hideTooltip();
  178. }
  179. }
  180. }
  181. }
  182. Text //Variant name.
  183. {
  184. id: variantName
  185. text: (connectedPrinter != null && connectedPrinter.hotendIds[index] != null) ? connectedPrinter.hotendIds[index] : ""
  186. font: UM.Theme.getFont("default")
  187. color: UM.Theme.getColor("text")
  188. anchors.right: parent.right
  189. anchors.bottom: parent.bottom
  190. anchors.margins: UM.Theme.getSize("default_margin").width
  191. MouseArea //For tooltip.
  192. {
  193. id: variantNameTooltipArea
  194. hoverEnabled: true
  195. anchors.fill: parent
  196. onHoveredChanged:
  197. {
  198. if (containsMouse)
  199. {
  200. base.showTooltip(
  201. base,
  202. {x: 0, y: parent.mapToItem(base, 0, -parent.height / 4).y},
  203. catalog.i18nc("@tooltip", "The nozzle inserted in this extruder.")
  204. );
  205. }
  206. else
  207. {
  208. base.hideTooltip();
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. Rectangle
  218. {
  219. color: UM.Theme.getColor("sidebar_lining")
  220. width: parent.width
  221. height: UM.Theme.getSize("sidebar_lining_thin").width
  222. }
  223. Rectangle
  224. {
  225. color: UM.Theme.getColor("sidebar")
  226. width: parent.width
  227. height: machineHeatedBed.properties.value == "True" ? UM.Theme.getSize("sidebar_extruder_box").height : 0
  228. visible: machineHeatedBed.properties.value == "True"
  229. Text //Build plate label.
  230. {
  231. text: catalog.i18nc("@label", "Build plate")
  232. font: UM.Theme.getFont("default")
  233. color: UM.Theme.getColor("text")
  234. anchors.left: parent.left
  235. anchors.top: parent.top
  236. anchors.margins: UM.Theme.getSize("default_margin").width
  237. }
  238. Text //Target temperature.
  239. {
  240. id: bedTargetTemperature
  241. text: connectedPrinter != null ? connectedPrinter.targetBedTemperature + "°C" : ""
  242. font: UM.Theme.getFont("small")
  243. color: UM.Theme.getColor("text_inactive")
  244. anchors.right: parent.right
  245. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  246. anchors.bottom: bedCurrentTemperature.bottom
  247. MouseArea //For tooltip.
  248. {
  249. id: bedTargetTemperatureTooltipArea
  250. hoverEnabled: true
  251. anchors.fill: parent
  252. onHoveredChanged:
  253. {
  254. if (containsMouse)
  255. {
  256. base.showTooltip(
  257. base,
  258. {x: 0, y: bedTargetTemperature.mapToItem(base, 0, -parent.height / 4).y},
  259. catalog.i18nc("@tooltip", "The target temperature of the heated bed. The bed will heat up or cool down towards this temperature. If this is 0, the bed heating is turned off.")
  260. );
  261. }
  262. else
  263. {
  264. base.hideTooltip();
  265. }
  266. }
  267. }
  268. }
  269. Text //Current temperature.
  270. {
  271. id: bedCurrentTemperature
  272. text: connectedPrinter != null ? connectedPrinter.bedTemperature + "°C" : ""
  273. font: UM.Theme.getFont("large")
  274. color: UM.Theme.getColor("text")
  275. anchors.right: bedTargetTemperature.left
  276. anchors.top: parent.top
  277. anchors.margins: UM.Theme.getSize("default_margin").width
  278. MouseArea //For tooltip.
  279. {
  280. id: bedTemperatureTooltipArea
  281. hoverEnabled: true
  282. anchors.fill: parent
  283. onHoveredChanged:
  284. {
  285. if (containsMouse)
  286. {
  287. base.showTooltip(
  288. base,
  289. {x: 0, y: bedCurrentTemperature.mapToItem(base, 0, -parent.height / 4).y},
  290. catalog.i18nc("@tooltip", "The current temperature of the heated bed.")
  291. );
  292. }
  293. else
  294. {
  295. base.hideTooltip();
  296. }
  297. }
  298. }
  299. }
  300. Rectangle //Input field for pre-heat temperature.
  301. {
  302. id: preheatTemperatureControl
  303. color: !enabled ? UM.Theme.getColor("setting_control_disabled") : UM.Theme.getColor("setting_validation_ok")
  304. enabled:
  305. {
  306. if (connectedPrinter == null)
  307. {
  308. return false; //Can't preheat if not connected.
  309. }
  310. if (!connectedPrinter.acceptsCommands)
  311. {
  312. return false; //Not allowed to do anything.
  313. }
  314. if (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "pre_print" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "pausing" || connectedPrinter.jobState == "paused" || connectedPrinter.jobState == "error" || connectedPrinter.jobState == "offline")
  315. {
  316. return false; //Printer is in a state where it can't react to pre-heating.
  317. }
  318. return true;
  319. }
  320. border.width: UM.Theme.getSize("default_lining").width
  321. border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : preheatTemperatureInputMouseArea.containsMouse ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
  322. anchors.left: parent.left
  323. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  324. anchors.bottom: parent.bottom
  325. anchors.bottomMargin: UM.Theme.getSize("default_margin").height
  326. width: UM.Theme.getSize("setting_control").width
  327. height: UM.Theme.getSize("setting_control").height
  328. Rectangle //Highlight of input field.
  329. {
  330. anchors.fill: parent
  331. anchors.margins: UM.Theme.getSize("default_lining").width
  332. color: UM.Theme.getColor("setting_control_highlight")
  333. opacity: preheatTemperatureControl.hovered ? 1.0 : 0
  334. }
  335. Text //Maximum temperature indication.
  336. {
  337. text: (bedTemperature.properties.maximum_value != "None" ? bedTemperature.properties.maximum_value : "") + "°C"
  338. color: UM.Theme.getColor("setting_unit")
  339. font: UM.Theme.getFont("default")
  340. anchors.right: parent.right
  341. anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width
  342. anchors.verticalCenter: parent.verticalCenter
  343. }
  344. MouseArea //Change cursor on hovering.
  345. {
  346. id: preheatTemperatureInputMouseArea
  347. hoverEnabled: true
  348. anchors.fill: parent
  349. cursorShape: Qt.IBeamCursor
  350. onHoveredChanged:
  351. {
  352. if (containsMouse)
  353. {
  354. base.showTooltip(
  355. base,
  356. {x: 0, y: preheatTemperatureInputMouseArea.mapToItem(base, 0, 0).y},
  357. catalog.i18nc("@tooltip of temperature input", "The temperature to pre-heat the bed to.")
  358. );
  359. }
  360. else
  361. {
  362. base.hideTooltip();
  363. }
  364. }
  365. }
  366. TextInput
  367. {
  368. id: preheatTemperatureInput
  369. font: UM.Theme.getFont("default")
  370. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  371. selectByMouse: true
  372. maximumLength: 10
  373. enabled: parent.enabled
  374. validator: RegExpValidator { regExp: /^-?[0-9]{0,9}[.,]?[0-9]{0,10}$/ } //Floating point regex.
  375. anchors.left: parent.left
  376. anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
  377. anchors.right: parent.right
  378. anchors.verticalCenter: parent.verticalCenter
  379. Component.onCompleted:
  380. {
  381. if ((bedTemperature.resolve != "None" && bedTemperature.resolve) && (bedTemperature.stackLevels[0] != 0) && (bedTemperature.stackLevels[0] != 1))
  382. {
  383. // We have a resolve function. Indicates that the setting is not settable per extruder and that
  384. // we have to choose between the resolved value (default) and the global value
  385. // (if user has explicitly set this).
  386. text = bedTemperature.resolve;
  387. }
  388. else
  389. {
  390. text = bedTemperature.properties.value;
  391. }
  392. }
  393. }
  394. }
  395. UM.RecolorImage
  396. {
  397. id: preheatCountdownIcon
  398. width: UM.Theme.getSize("save_button_specs_icons").width
  399. height: UM.Theme.getSize("save_button_specs_icons").height
  400. sourceSize.width: width
  401. sourceSize.height: height
  402. color: UM.Theme.getColor("text")
  403. visible: preheatCountdown.visible
  404. source: UM.Theme.getIcon("print_time")
  405. anchors.right: preheatCountdown.left
  406. anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2
  407. anchors.verticalCenter: preheatCountdown.verticalCenter
  408. }
  409. Timer
  410. {
  411. id: preheatUpdateTimer
  412. interval: 100 //Update every 100ms. You want to update every 1s, but then you have one timer for the updating running out of sync with the actual date timer and you might skip seconds.
  413. running: connectedPrinter != null && connectedPrinter.preheatBedRemainingTime != ""
  414. repeat: true
  415. onTriggered: update()
  416. property var endTime: new Date() //Set initial endTime to be the current date, so that the endTime has initially already passed and the timer text becomes invisible if you were to update.
  417. function update()
  418. {
  419. preheatCountdown.text = ""
  420. if (connectedPrinter != null)
  421. {
  422. preheatCountdown.text = connectedPrinter.preheatBedRemainingTime;
  423. }
  424. if (preheatCountdown.text == "") //Either time elapsed or not connected.
  425. {
  426. stop();
  427. }
  428. }
  429. }
  430. Text
  431. {
  432. id: preheatCountdown
  433. text: connectedPrinter != null ? connectedPrinter.preheatBedRemainingTime : ""
  434. visible: text != "" //Has no direct effect, but just so that we can link visibility of clock icon to visibility of the countdown text.
  435. font: UM.Theme.getFont("default")
  436. color: UM.Theme.getColor("text")
  437. anchors.right: preheatButton.left
  438. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  439. anchors.verticalCenter: preheatButton.verticalCenter
  440. }
  441. Button //The pre-heat button.
  442. {
  443. id: preheatButton
  444. height: UM.Theme.getSize("setting_control").height
  445. enabled:
  446. {
  447. if (!preheatTemperatureControl.enabled)
  448. {
  449. return false; //Not connected, not authenticated or printer is busy.
  450. }
  451. if (preheatUpdateTimer.running)
  452. {
  453. return true; //Can always cancel if the timer is running.
  454. }
  455. if (bedTemperature.properties.minimum_value != "None" && parseInt(preheatTemperatureInput.text) < parseInt(bedTemperature.properties.minimum_value))
  456. {
  457. return false; //Target temperature too low.
  458. }
  459. if (bedTemperature.properties.maximum_value != "None" && parseInt(preheatTemperatureInput.text) > parseInt(bedTemperature.properties.maximum_value))
  460. {
  461. return false; //Target temperature too high.
  462. }
  463. if (parseInt(preheatTemperatureInput.text) == 0)
  464. {
  465. return false; //Setting the temperature to 0 is not allowed (since that cancels the pre-heating).
  466. }
  467. return true; //Preconditions are met.
  468. }
  469. anchors.right: parent.right
  470. anchors.bottom: parent.bottom
  471. anchors.margins: UM.Theme.getSize("default_margin").width
  472. style: ButtonStyle {
  473. background: Rectangle
  474. {
  475. border.width: UM.Theme.getSize("default_lining").width
  476. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
  477. border.color:
  478. {
  479. if(!control.enabled)
  480. {
  481. return UM.Theme.getColor("action_button_disabled_border");
  482. }
  483. else if(control.pressed)
  484. {
  485. return UM.Theme.getColor("action_button_active_border");
  486. }
  487. else if(control.hovered)
  488. {
  489. return UM.Theme.getColor("action_button_hovered_border");
  490. }
  491. else
  492. {
  493. return UM.Theme.getColor("action_button_border");
  494. }
  495. }
  496. color:
  497. {
  498. if(!control.enabled)
  499. {
  500. return UM.Theme.getColor("action_button_disabled");
  501. }
  502. else if(control.pressed)
  503. {
  504. return UM.Theme.getColor("action_button_active");
  505. }
  506. else if(control.hovered)
  507. {
  508. return UM.Theme.getColor("action_button_hovered");
  509. }
  510. else
  511. {
  512. return UM.Theme.getColor("action_button");
  513. }
  514. }
  515. Behavior on color
  516. {
  517. ColorAnimation
  518. {
  519. duration: 50
  520. }
  521. }
  522. Text
  523. {
  524. id: actualLabel
  525. anchors.centerIn: parent
  526. color:
  527. {
  528. if(!control.enabled)
  529. {
  530. return UM.Theme.getColor("action_button_disabled_text");
  531. }
  532. else if(control.pressed)
  533. {
  534. return UM.Theme.getColor("action_button_active_text");
  535. }
  536. else if(control.hovered)
  537. {
  538. return UM.Theme.getColor("action_button_hovered_text");
  539. }
  540. else
  541. {
  542. return UM.Theme.getColor("action_button_text");
  543. }
  544. }
  545. font: UM.Theme.getFont("action_button")
  546. text: preheatUpdateTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat")
  547. }
  548. }
  549. }
  550. onClicked:
  551. {
  552. if (!preheatUpdateTimer.running)
  553. {
  554. connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout);
  555. preheatUpdateTimer.start();
  556. preheatUpdateTimer.update(); //Update once before the first timer is triggered.
  557. }
  558. else
  559. {
  560. connectedPrinter.cancelPreheatBed();
  561. preheatUpdateTimer.update();
  562. }
  563. }
  564. onHoveredChanged:
  565. {
  566. if (hovered)
  567. {
  568. base.showTooltip(
  569. base,
  570. {x: 0, y: preheatButton.mapToItem(base, 0, 0).y},
  571. catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.")
  572. );
  573. }
  574. else
  575. {
  576. base.hideTooltip();
  577. }
  578. }
  579. }
  580. }
  581. UM.SettingPropertyProvider
  582. {
  583. id: bedTemperature
  584. containerStackId: Cura.MachineManager.activeMachineId
  585. key: "material_bed_temperature"
  586. watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
  587. storeIndex: 0
  588. property var resolve: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId ? properties.resolve : "None"
  589. }
  590. UM.SettingPropertyProvider
  591. {
  592. id: machineExtruderCount
  593. containerStackId: Cura.MachineManager.activeMachineId
  594. key: "machine_extruder_count"
  595. watchedProperties: ["value"]
  596. }
  597. Loader
  598. {
  599. sourceComponent: monitorSection
  600. property string label: catalog.i18nc("@label", "Active print")
  601. }
  602. Loader
  603. {
  604. sourceComponent: monitorItem
  605. property string label: catalog.i18nc("@label", "Job Name")
  606. property string value: connectedPrinter != null ? connectedPrinter.jobName : ""
  607. }
  608. Loader
  609. {
  610. sourceComponent: monitorItem
  611. property string label: catalog.i18nc("@label", "Printing Time")
  612. property string value: connectedPrinter != null ? getPrettyTime(connectedPrinter.timeTotal) : ""
  613. }
  614. Loader
  615. {
  616. sourceComponent: monitorItem
  617. property string label: catalog.i18nc("@label", "Estimated time left")
  618. property string value: connectedPrinter != null ? getPrettyTime(connectedPrinter.timeTotal - connectedPrinter.timeElapsed) : ""
  619. visible: connectedPrinter != null && (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "pausing" || connectedPrinter.jobState == "paused")
  620. }
  621. Component
  622. {
  623. id: monitorItem
  624. Row
  625. {
  626. height: UM.Theme.getSize("setting_control").height
  627. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  628. anchors.left: parent.left
  629. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  630. Text
  631. {
  632. width: parent.width * 0.4
  633. anchors.verticalCenter: parent.verticalCenter
  634. text: label
  635. color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  636. font: UM.Theme.getFont("default")
  637. elide: Text.ElideRight
  638. }
  639. Text
  640. {
  641. width: parent.width * 0.6
  642. anchors.verticalCenter: parent.verticalCenter
  643. text: value
  644. color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  645. font: UM.Theme.getFont("default")
  646. elide: Text.ElideRight
  647. }
  648. }
  649. }
  650. Component
  651. {
  652. id: monitorSection
  653. Rectangle
  654. {
  655. color: UM.Theme.getColor("setting_category")
  656. width: base.width
  657. height: UM.Theme.getSize("section").height
  658. Text
  659. {
  660. anchors.verticalCenter: parent.verticalCenter
  661. anchors.left: parent.left
  662. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  663. text: label
  664. font: UM.Theme.getFont("setting_category")
  665. color: UM.Theme.getColor("setting_category_text")
  666. }
  667. }
  668. }
  669. }