Show material name instead of extruder number

This commit is contained in:
fieldOfView 2017-10-30 12:40:41 +01:00
parent fc7d1210cf
commit 2d109090bc
2 changed files with 14 additions and 1 deletions

View file

@ -56,6 +56,7 @@ class PrintInformation(QObject):
self._material_lengths = []
self._material_weights = []
self._material_costs = []
self._material_names = []
self._pre_sliced = False
@ -139,6 +140,12 @@ class PrintInformation(QObject):
def materialCosts(self):
return self._material_costs
materialNamesChanged = pyqtSignal()
@pyqtProperty("QVariantList", notify = materialNamesChanged)
def materialNames(self):
return self._material_names
def _onPrintDurationMessage(self, print_time, material_amounts):
self._updateTotalPrintTimePerFeature(print_time)
@ -170,6 +177,7 @@ class PrintInformation(QObject):
self._material_lengths = []
self._material_weights = []
self._material_costs = []
self._material_names = []
material_preference_values = json.loads(Preferences.getInstance().getValue("cura/material_settings"))
@ -208,10 +216,12 @@ class PrintInformation(QObject):
self._material_weights.append(weight)
self._material_lengths.append(length)
self._material_costs.append(cost)
self._material_names.append(material.getName())
self.materialLengthsChanged.emit()
self.materialWeightsChanged.emit()
self.materialCostsChanged.emit()
self.materialNamesChanged.emit()
def _onPreferencesChanged(self, preference):
if preference != "cura/material_settings":

View file

@ -30,6 +30,7 @@ Rectangle
property variant printMaterialLengths: PrintInformation.materialLengths
property variant printMaterialWeights: PrintInformation.materialWeights
property variant printMaterialCosts: PrintInformation.materialCosts
property variant printMaterialNames: PrintInformation.materialNames
color: UM.Theme.getColor("sidebar")
UM.I18nCatalog { id: catalog; name:"cura"}
@ -392,11 +393,13 @@ Rectangle
var costs = [];
var total_cost = 0;
var some_costs_known = false;
var names = [];
if(base.printMaterialLengths) {
for(var index = 0; index < base.printMaterialLengths.length; index++)
{
if(base.printMaterialLengths[index] > 0)
{
names.push(base.printMaterialNames[index]);
lengths.push(base.printMaterialLengths[index].toFixed(2));
weights.push(String(Math.floor(base.printMaterialWeights[index])));
var cost = base.printMaterialCosts[index] == undefined ? 0 : base.printMaterialCosts[index].toFixed(2);
@ -423,7 +426,7 @@ Rectangle
for(var index = 0; index < lengths.length; index++)
{
var item_strings = [
catalog.i18nc("@label", "Extruder %1:").arg(index + 1),
"%1:".arg(names[index]),
catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]),
catalog.i18nc("@label g for grams", "%1g").arg(weights[index]),
"%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]),