PrintJobInformation.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 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. id: byMaterialType
  77. property var printMaterialLengths: PrintInformation.materialLengths
  78. property var printMaterialWeights: PrintInformation.materialWeights
  79. property var printMaterialCosts: PrintInformation.materialCosts
  80. property var printMaterialNames: PrintInformation.materialNames
  81. property var columnWidthMultipliers: [ 0.4, 0.2, 0.2, 0.2 ]
  82. function getMaterialTable()
  83. {
  84. var result = []
  85. var lengths = []
  86. var weights = []
  87. var costs = []
  88. var names = []
  89. if(printMaterialLengths)
  90. {
  91. for(var index = 0; index < printMaterialLengths.length; index++)
  92. {
  93. if(printMaterialLengths[index] > 0)
  94. {
  95. names.push(printMaterialNames[index])
  96. lengths.push(printMaterialLengths[index].toFixed(2))
  97. weights.push(String(Math.round(printMaterialWeights[index])))
  98. var cost = printMaterialCosts[index] == undefined ? 0 : printMaterialCosts[index].toFixed(2)
  99. costs.push(cost)
  100. }
  101. }
  102. }
  103. if(lengths.length == 0)
  104. {
  105. lengths = ["0.00"]
  106. weights = ["0"]
  107. costs = ["0.00"]
  108. }
  109. for(var index = 0; index < lengths.length; index++)
  110. {
  111. var row = []
  112. row.push("%1:".arg(names[index]))
  113. row.push(catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]))
  114. row.push(catalog.i18nc("@label g for grams", "%1g").arg(weights[index]))
  115. row.push("%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]))
  116. result.push(row)
  117. }
  118. return result
  119. }
  120. Column
  121. {
  122. Repeater
  123. {
  124. model: byMaterialType.getMaterialTable()
  125. Row
  126. {
  127. Repeater
  128. {
  129. model: modelData
  130. Text
  131. {
  132. width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index])
  133. height: contentHeight
  134. font: UM.Theme.getFont("default")
  135. wrapMode: Text.WrapAnywhere
  136. text: modelData
  137. }
  138. }
  139. }
  140. }
  141. }
  142. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  143. height: childrenRect.height
  144. color: UM.Theme.getColor("text")
  145. font: UM.Theme.getFont("default")
  146. renderType: Text.NativeRendering
  147. textFormat: Text.RichText
  148. }
  149. }
  150. }