OutputProcessWidget.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.1
  5. import QtQuick.Layouts 1.3
  6. import UM 1.1 as UM
  7. import Cura 1.0 as Cura
  8. // This element contains all the elements the user needs to visualize the data
  9. // that is gather after the slicing process, such as printint time, material usage, ...
  10. // There are also two buttons: one to previsualize the output layers, and the other to
  11. // select what to do with it (such as print over network, save to file, ...)
  12. Column
  13. {
  14. id: widget
  15. spacing: UM.Theme.getSize("thin_margin").height
  16. property bool preSlicedData: PrintInformation.preSliced
  17. property alias hasPreviewButton: previewStageShortcut.visible
  18. UM.I18nCatalog
  19. {
  20. id: catalog
  21. name: "cura"
  22. }
  23. Item
  24. {
  25. id: information
  26. width: parent.width
  27. height: childrenRect.height
  28. PrintInformationWidget
  29. {
  30. id: printInformationPanel
  31. visible: !preSlicedData
  32. anchors.right: parent.right
  33. }
  34. Column
  35. {
  36. id: timeAndCostsInformation
  37. spacing: UM.Theme.getSize("thin_margin").height
  38. anchors
  39. {
  40. left: parent.left
  41. right: parent.right
  42. }
  43. Cura.IconWithText
  44. {
  45. id: estimatedTime
  46. width: parent.width
  47. text: preSlicedData ? catalog.i18nc("@label", "No time estimation available") : PrintInformation.currentPrintTime.getDisplayString(UM.DurationFormat.Long)
  48. source: UM.Theme.getIcon("Clock")
  49. font: UM.Theme.getFont("medium_bold")
  50. }
  51. Cura.IconWithText
  52. {
  53. id: estimatedCosts
  54. width: parent.width
  55. property var printMaterialLengths: PrintInformation.materialLengths
  56. property var printMaterialWeights: PrintInformation.materialWeights
  57. property var printMaterialCosts: PrintInformation.materialCosts
  58. text:
  59. {
  60. if (preSlicedData)
  61. {
  62. return catalog.i18nc("@label", "No cost estimation available")
  63. }
  64. var totalLengths = 0
  65. var totalWeights = 0
  66. var totalCosts = 0.0
  67. if (printMaterialLengths)
  68. {
  69. for(var index = 0; index < printMaterialLengths.length; index++)
  70. {
  71. if(printMaterialLengths[index] > 0)
  72. {
  73. totalLengths += printMaterialLengths[index]
  74. totalWeights += Math.round(printMaterialWeights[index])
  75. var cost = printMaterialCosts[index] == undefined ? 0.0 : printMaterialCosts[index]
  76. totalCosts += cost
  77. }
  78. }
  79. }
  80. if(totalCosts > 0)
  81. {
  82. var costString = "%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(totalCosts.toFixed(2))
  83. return totalWeights + "g · " + totalLengths.toFixed(2) + "m · " + costString
  84. }
  85. return totalWeights + "g · " + totalLengths.toFixed(2) + "m"
  86. }
  87. source: UM.Theme.getIcon("Spool")
  88. font: UM.Theme.getFont("default")
  89. }
  90. }
  91. }
  92. Item
  93. {
  94. id: buttonRow
  95. anchors.right: parent.right
  96. anchors.left: parent.left
  97. height: UM.Theme.getSize("action_button").height
  98. Cura.SecondaryButton
  99. {
  100. id: previewStageShortcut
  101. anchors
  102. {
  103. left: parent.left
  104. right: outputDevicesButton.left
  105. rightMargin: UM.Theme.getSize("default_margin").width
  106. }
  107. height: UM.Theme.getSize("action_button").height
  108. text: catalog.i18nc("@button", "Preview")
  109. tooltip: text
  110. fixedWidthMode: true
  111. toolTipContentAlignment: Cura.ToolTip.ContentAlignment.AlignLeft
  112. onClicked: UM.Controller.setActiveStage("PreviewStage")
  113. }
  114. Cura.OutputDevicesActionButton
  115. {
  116. id: outputDevicesButton
  117. anchors.right: parent.right
  118. width: previewStageShortcut.visible ? UM.Theme.getSize("action_button").width : parent.width
  119. height: UM.Theme.getSize("action_button").height
  120. }
  121. }
  122. }