PrintJobInformation.qml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // Copyright (c) 2018 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 UM 1.1 as UM
  6. import Cura 1.0 as Cura
  7. Column
  8. {
  9. id: base
  10. spacing: UM.Theme.getSize("default_margin").width
  11. UM.I18nCatalog
  12. {
  13. id: catalog
  14. name: "cura"
  15. }
  16. Column
  17. {
  18. id: timeSpecification
  19. width: parent.width
  20. topPadding: UM.Theme.getSize("default_margin").height
  21. leftPadding: UM.Theme.getSize("default_margin").width
  22. rightPadding: UM.Theme.getSize("default_margin").width
  23. Label
  24. {
  25. text: catalog.i18nc("@label", "Time specification").toUpperCase()
  26. color: UM.Theme.getColor("primary")
  27. font: UM.Theme.getFont("default_bold")
  28. renderType: Text.NativeRendering
  29. }
  30. Label
  31. {
  32. property var printDuration: PrintInformation.currentPrintTime
  33. text:
  34. {
  35. // All the time information for the different features is achieved
  36. var printTime = PrintInformation.getFeaturePrintTimes()
  37. var totalSeconds = parseInt(printDuration.getDisplayString(UM.DurationFormat.Seconds))
  38. // A message is created and displayed when the user hover the time label
  39. var text = "<table width=\"100%\">"
  40. for(var feature in printTime)
  41. {
  42. if(!printTime[feature].isTotalDurationZero)
  43. {
  44. text += "<tr><td>" + feature + ":</td>" +
  45. "<td align=\"right\" valign=\"bottom\">&nbsp;&nbsp;%1</td>".arg(printTime[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3)) +
  46. "<td align=\"right\" valign=\"bottom\">&nbsp;&nbsp;%1%</td>".arg(Math.round(100 * parseInt(printTime[feature].getDisplayString(UM.DurationFormat.Seconds)) / totalSeconds)) +
  47. "</tr>"
  48. }
  49. }
  50. text += "</table>"
  51. return text
  52. }
  53. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  54. color: UM.Theme.getColor("text")
  55. font: UM.Theme.getFont("default")
  56. renderType: Text.NativeRendering
  57. textFormat: Text.RichText
  58. }
  59. }
  60. Column
  61. {
  62. id: materialSpecification
  63. width: parent.width
  64. bottomPadding: UM.Theme.getSize("default_margin").height
  65. leftPadding: UM.Theme.getSize("default_margin").width
  66. rightPadding: UM.Theme.getSize("default_margin").width
  67. Label
  68. {
  69. text: catalog.i18nc("@label", "Material specification").toUpperCase()
  70. color: UM.Theme.getColor("primary")
  71. font: UM.Theme.getFont("default_bold")
  72. renderType: Text.NativeRendering
  73. }
  74. Label
  75. {
  76. property var printMaterialLengths: PrintInformation.materialLengths
  77. property var printMaterialWeights: PrintInformation.materialWeights
  78. property var printMaterialCosts: PrintInformation.materialCosts
  79. property var printMaterialNames: PrintInformation.materialNames
  80. function formatRow(items)
  81. {
  82. var rowHTML = "<tr>"
  83. for(var item = 0; item < items.length; item++)
  84. {
  85. if (item == 0)
  86. {
  87. rowHTML += "<td valign=\"bottom\">%1</td>".arg(items[item])
  88. }
  89. else
  90. {
  91. rowHTML += "<td align=\"right\" valign=\"bottom\">&nbsp;&nbsp;%1</td>".arg(items[item])
  92. }
  93. }
  94. rowHTML += "</tr>"
  95. return rowHTML
  96. }
  97. text:
  98. {
  99. var lengths = []
  100. var weights = []
  101. var costs = []
  102. var names = []
  103. if(printMaterialLengths)
  104. {
  105. for(var index = 0; index < printMaterialLengths.length; index++)
  106. {
  107. if(printMaterialLengths[index] > 0)
  108. {
  109. names.push(printMaterialNames[index])
  110. lengths.push(printMaterialLengths[index].toFixed(2))
  111. weights.push(String(Math.round(printMaterialWeights[index])))
  112. var cost = printMaterialCosts[index] == undefined ? 0 : printMaterialCosts[index].toFixed(2)
  113. costs.push(cost)
  114. }
  115. }
  116. }
  117. if(lengths.length == 0)
  118. {
  119. lengths = ["0.00"]
  120. weights = ["0"]
  121. costs = ["0.00"]
  122. }
  123. var text = "<table width=\"100%\">"
  124. for(var index = 0; index < lengths.length; index++)
  125. {
  126. text += formatRow([
  127. "%1:".arg(names[index]),
  128. catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]),
  129. catalog.i18nc("@label g for grams", "%1g").arg(weights[index]),
  130. "%1&nbsp;%2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]),
  131. ])
  132. }
  133. text += "</table>"
  134. return text
  135. }
  136. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  137. color: UM.Theme.getColor("text")
  138. font: UM.Theme.getFont("default")
  139. renderType: Text.NativeRendering
  140. textFormat: Text.RichText
  141. }
  142. }
  143. }