PrintMonitor.qml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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") : showError ? UM.Theme.getColor("setting_validation_error_background") : UM.Theme.getColor("setting_validation_ok")
  304. property var showError:
  305. {
  306. if(bedTemperature.properties.maximum_value != "None" && bedTemperature.properties.maximum_value < parseInt(preheatTemperatureInput.text))
  307. {
  308. return true;
  309. } else
  310. {
  311. return false;
  312. }
  313. }
  314. enabled:
  315. {
  316. if (connectedPrinter == null)
  317. {
  318. return false; //Can't preheat if not connected.
  319. }
  320. if (!connectedPrinter.acceptsCommands)
  321. {
  322. return false; //Not allowed to do anything.
  323. }
  324. if (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "pre_print" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "pausing" || connectedPrinter.jobState == "paused" || connectedPrinter.jobState == "error" || connectedPrinter.jobState == "offline")
  325. {
  326. return false; //Printer is in a state where it can't react to pre-heating.
  327. }
  328. return true;
  329. }
  330. border.width: UM.Theme.getSize("default_lining").width
  331. 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")
  332. anchors.left: parent.left
  333. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  334. anchors.bottom: parent.bottom
  335. anchors.bottomMargin: UM.Theme.getSize("default_margin").height
  336. width: UM.Theme.getSize("setting_control").width
  337. height: UM.Theme.getSize("setting_control").height
  338. Rectangle //Highlight of input field.
  339. {
  340. anchors.fill: parent
  341. anchors.margins: UM.Theme.getSize("default_lining").width
  342. color: UM.Theme.getColor("setting_control_highlight")
  343. opacity: preheatTemperatureControl.hovered ? 1.0 : 0
  344. }
  345. Text //Maximum temperature indication.
  346. {
  347. text: (bedTemperature.properties.maximum_value != "None" ? bedTemperature.properties.maximum_value : "") + "°C"
  348. color: UM.Theme.getColor("setting_unit")
  349. font: UM.Theme.getFont("default")
  350. anchors.right: parent.right
  351. anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width
  352. anchors.verticalCenter: parent.verticalCenter
  353. }
  354. MouseArea //Change cursor on hovering.
  355. {
  356. id: preheatTemperatureInputMouseArea
  357. hoverEnabled: true
  358. anchors.fill: parent
  359. cursorShape: Qt.IBeamCursor
  360. onHoveredChanged:
  361. {
  362. if (containsMouse)
  363. {
  364. base.showTooltip(
  365. base,
  366. {x: 0, y: preheatTemperatureInputMouseArea.mapToItem(base, 0, 0).y},
  367. catalog.i18nc("@tooltip of temperature input", "The temperature to pre-heat the bed to.")
  368. );
  369. }
  370. else
  371. {
  372. base.hideTooltip();
  373. }
  374. }
  375. }
  376. TextInput
  377. {
  378. id: preheatTemperatureInput
  379. font: UM.Theme.getFont("default")
  380. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  381. selectByMouse: true
  382. maximumLength: 10
  383. enabled: parent.enabled
  384. validator: RegExpValidator { regExp: /^-?[0-9]{0,9}[.,]?[0-9]{0,10}$/ } //Floating point regex.
  385. anchors.left: parent.left
  386. anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
  387. anchors.right: parent.right
  388. anchors.verticalCenter: parent.verticalCenter
  389. Component.onCompleted:
  390. {
  391. if ((bedTemperature.resolve != "None" && bedTemperature.resolve) && (bedTemperature.stackLevels[0] != 0) && (bedTemperature.stackLevels[0] != 1))
  392. {
  393. // We have a resolve function. Indicates that the setting is not settable per extruder and that
  394. // we have to choose between the resolved value (default) and the global value
  395. // (if user has explicitly set this).
  396. text = bedTemperature.resolve;
  397. }
  398. else
  399. {
  400. text = bedTemperature.properties.value;
  401. }
  402. }
  403. }
  404. }
  405. UM.RecolorImage
  406. {
  407. id: preheatCountdownIcon
  408. width: UM.Theme.getSize("save_button_specs_icons").width
  409. height: UM.Theme.getSize("save_button_specs_icons").height
  410. sourceSize.width: width
  411. sourceSize.height: height
  412. color: UM.Theme.getColor("text")
  413. visible: preheatCountdown.visible
  414. source: UM.Theme.getIcon("print_time")
  415. anchors.right: preheatCountdown.left
  416. anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2
  417. anchors.verticalCenter: preheatCountdown.verticalCenter
  418. }
  419. Timer
  420. {
  421. id: preheatUpdateTimer
  422. 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.
  423. running: connectedPrinter != null && connectedPrinter.preheatBedRemainingTime != ""
  424. repeat: true
  425. onTriggered: update()
  426. 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.
  427. function update()
  428. {
  429. preheatCountdown.text = ""
  430. if (connectedPrinter != null)
  431. {
  432. preheatCountdown.text = connectedPrinter.preheatBedRemainingTime;
  433. }
  434. if (preheatCountdown.text == "") //Either time elapsed or not connected.
  435. {
  436. stop();
  437. }
  438. }
  439. }
  440. Text
  441. {
  442. id: preheatCountdown
  443. text: connectedPrinter != null ? connectedPrinter.preheatBedRemainingTime : ""
  444. visible: text != "" //Has no direct effect, but just so that we can link visibility of clock icon to visibility of the countdown text.
  445. font: UM.Theme.getFont("default")
  446. color: UM.Theme.getColor("text")
  447. anchors.right: preheatButton.left
  448. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  449. anchors.verticalCenter: preheatButton.verticalCenter
  450. }
  451. Button //The pre-heat button.
  452. {
  453. id: preheatButton
  454. height: UM.Theme.getSize("setting_control").height
  455. enabled:
  456. {
  457. if (!preheatTemperatureControl.enabled)
  458. {
  459. return false; //Not connected, not authenticated or printer is busy.
  460. }
  461. if (preheatUpdateTimer.running)
  462. {
  463. return true; //Can always cancel if the timer is running.
  464. }
  465. if (bedTemperature.properties.minimum_value != "None" && parseInt(preheatTemperatureInput.text) < parseInt(bedTemperature.properties.minimum_value))
  466. {
  467. return false; //Target temperature too low.
  468. }
  469. if (bedTemperature.properties.maximum_value != "None" && parseInt(preheatTemperatureInput.text) > parseInt(bedTemperature.properties.maximum_value))
  470. {
  471. return false; //Target temperature too high.
  472. }
  473. if (parseInt(preheatTemperatureInput.text) == 0)
  474. {
  475. return false; //Setting the temperature to 0 is not allowed (since that cancels the pre-heating).
  476. }
  477. return true; //Preconditions are met.
  478. }
  479. anchors.right: parent.right
  480. anchors.bottom: parent.bottom
  481. anchors.margins: UM.Theme.getSize("default_margin").width
  482. style: ButtonStyle {
  483. background: Rectangle
  484. {
  485. border.width: UM.Theme.getSize("default_lining").width
  486. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
  487. border.color:
  488. {
  489. if(!control.enabled)
  490. {
  491. return UM.Theme.getColor("action_button_disabled_border");
  492. }
  493. else if(control.pressed)
  494. {
  495. return UM.Theme.getColor("action_button_active_border");
  496. }
  497. else if(control.hovered)
  498. {
  499. return UM.Theme.getColor("action_button_hovered_border");
  500. }
  501. else
  502. {
  503. return UM.Theme.getColor("action_button_border");
  504. }
  505. }
  506. color:
  507. {
  508. if(!control.enabled)
  509. {
  510. return UM.Theme.getColor("action_button_disabled");
  511. }
  512. else if(control.pressed)
  513. {
  514. return UM.Theme.getColor("action_button_active");
  515. }
  516. else if(control.hovered)
  517. {
  518. return UM.Theme.getColor("action_button_hovered");
  519. }
  520. else
  521. {
  522. return UM.Theme.getColor("action_button");
  523. }
  524. }
  525. Behavior on color
  526. {
  527. ColorAnimation
  528. {
  529. duration: 50
  530. }
  531. }
  532. Text
  533. {
  534. id: actualLabel
  535. anchors.centerIn: parent
  536. color:
  537. {
  538. if(!control.enabled)
  539. {
  540. return UM.Theme.getColor("action_button_disabled_text");
  541. }
  542. else if(control.pressed)
  543. {
  544. return UM.Theme.getColor("action_button_active_text");
  545. }
  546. else if(control.hovered)
  547. {
  548. return UM.Theme.getColor("action_button_hovered_text");
  549. }
  550. else
  551. {
  552. return UM.Theme.getColor("action_button_text");
  553. }
  554. }
  555. font: UM.Theme.getFont("action_button")
  556. text: preheatUpdateTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat")
  557. }
  558. }
  559. }
  560. onClicked:
  561. {
  562. if (!preheatUpdateTimer.running)
  563. {
  564. connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout);
  565. preheatUpdateTimer.start();
  566. preheatUpdateTimer.update(); //Update once before the first timer is triggered.
  567. }
  568. else
  569. {
  570. connectedPrinter.cancelPreheatBed();
  571. preheatUpdateTimer.update();
  572. }
  573. }
  574. onHoveredChanged:
  575. {
  576. if (hovered)
  577. {
  578. base.showTooltip(
  579. base,
  580. {x: 0, y: preheatButton.mapToItem(base, 0, 0).y},
  581. 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.")
  582. );
  583. }
  584. else
  585. {
  586. base.hideTooltip();
  587. }
  588. }
  589. }
  590. }
  591. UM.SettingPropertyProvider
  592. {
  593. id: bedTemperature
  594. containerStackId: Cura.MachineManager.activeMachineId
  595. key: "material_bed_temperature"
  596. watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
  597. storeIndex: 0
  598. property var resolve: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId ? properties.resolve : "None"
  599. }
  600. UM.SettingPropertyProvider
  601. {
  602. id: machineExtruderCount
  603. containerStackId: Cura.MachineManager.activeMachineId
  604. key: "machine_extruder_count"
  605. watchedProperties: ["value"]
  606. }
  607. Loader
  608. {
  609. sourceComponent: monitorSection
  610. property string label: catalog.i18nc("@label", "Active print")
  611. }
  612. Loader
  613. {
  614. sourceComponent: monitorItem
  615. property string label: catalog.i18nc("@label", "Job Name")
  616. property string value: connectedPrinter != null ? connectedPrinter.jobName : ""
  617. }
  618. Loader
  619. {
  620. sourceComponent: monitorItem
  621. property string label: catalog.i18nc("@label", "Printing Time")
  622. property string value: connectedPrinter != null ? getPrettyTime(connectedPrinter.timeTotal) : ""
  623. }
  624. Loader
  625. {
  626. sourceComponent: monitorItem
  627. property string label: catalog.i18nc("@label", "Estimated time left")
  628. property string value: connectedPrinter != null ? getPrettyTime(connectedPrinter.timeTotal - connectedPrinter.timeElapsed) : ""
  629. visible: connectedPrinter != null && (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "pausing" || connectedPrinter.jobState == "paused")
  630. }
  631. Component
  632. {
  633. id: monitorItem
  634. Row
  635. {
  636. height: UM.Theme.getSize("setting_control").height
  637. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  638. anchors.left: parent.left
  639. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  640. Text
  641. {
  642. width: parent.width * 0.4
  643. anchors.verticalCenter: parent.verticalCenter
  644. text: label
  645. color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  646. font: UM.Theme.getFont("default")
  647. elide: Text.ElideRight
  648. }
  649. Text
  650. {
  651. width: parent.width * 0.6
  652. anchors.verticalCenter: parent.verticalCenter
  653. text: value
  654. color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  655. font: UM.Theme.getFont("default")
  656. elide: Text.ElideRight
  657. }
  658. }
  659. }
  660. Component
  661. {
  662. id: monitorSection
  663. Rectangle
  664. {
  665. color: UM.Theme.getColor("setting_category")
  666. width: base.width
  667. height: UM.Theme.getSize("section").height
  668. Text
  669. {
  670. anchors.verticalCenter: parent.verticalCenter
  671. anchors.left: parent.left
  672. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  673. text: label
  674. font: UM.Theme.getFont("setting_category")
  675. color: UM.Theme.getColor("setting_category_text")
  676. }
  677. }
  678. }
  679. }