mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 03:25:56 +08:00
Show material name instead of extruder number
This commit is contained in:
parent
fc7d1210cf
commit
2d109090bc
@ -56,6 +56,7 @@ class PrintInformation(QObject):
|
|||||||
self._material_lengths = []
|
self._material_lengths = []
|
||||||
self._material_weights = []
|
self._material_weights = []
|
||||||
self._material_costs = []
|
self._material_costs = []
|
||||||
|
self._material_names = []
|
||||||
|
|
||||||
self._pre_sliced = False
|
self._pre_sliced = False
|
||||||
|
|
||||||
@ -139,6 +140,12 @@ class PrintInformation(QObject):
|
|||||||
def materialCosts(self):
|
def materialCosts(self):
|
||||||
return self._material_costs
|
return self._material_costs
|
||||||
|
|
||||||
|
materialNamesChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantList", notify = materialNamesChanged)
|
||||||
|
def materialNames(self):
|
||||||
|
return self._material_names
|
||||||
|
|
||||||
def _onPrintDurationMessage(self, print_time, material_amounts):
|
def _onPrintDurationMessage(self, print_time, material_amounts):
|
||||||
|
|
||||||
self._updateTotalPrintTimePerFeature(print_time)
|
self._updateTotalPrintTimePerFeature(print_time)
|
||||||
@ -170,6 +177,7 @@ class PrintInformation(QObject):
|
|||||||
self._material_lengths = []
|
self._material_lengths = []
|
||||||
self._material_weights = []
|
self._material_weights = []
|
||||||
self._material_costs = []
|
self._material_costs = []
|
||||||
|
self._material_names = []
|
||||||
|
|
||||||
material_preference_values = json.loads(Preferences.getInstance().getValue("cura/material_settings"))
|
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_weights.append(weight)
|
||||||
self._material_lengths.append(length)
|
self._material_lengths.append(length)
|
||||||
self._material_costs.append(cost)
|
self._material_costs.append(cost)
|
||||||
|
self._material_names.append(material.getName())
|
||||||
|
|
||||||
self.materialLengthsChanged.emit()
|
self.materialLengthsChanged.emit()
|
||||||
self.materialWeightsChanged.emit()
|
self.materialWeightsChanged.emit()
|
||||||
self.materialCostsChanged.emit()
|
self.materialCostsChanged.emit()
|
||||||
|
self.materialNamesChanged.emit()
|
||||||
|
|
||||||
def _onPreferencesChanged(self, preference):
|
def _onPreferencesChanged(self, preference):
|
||||||
if preference != "cura/material_settings":
|
if preference != "cura/material_settings":
|
||||||
|
@ -30,6 +30,7 @@ Rectangle
|
|||||||
property variant printMaterialLengths: PrintInformation.materialLengths
|
property variant printMaterialLengths: PrintInformation.materialLengths
|
||||||
property variant printMaterialWeights: PrintInformation.materialWeights
|
property variant printMaterialWeights: PrintInformation.materialWeights
|
||||||
property variant printMaterialCosts: PrintInformation.materialCosts
|
property variant printMaterialCosts: PrintInformation.materialCosts
|
||||||
|
property variant printMaterialNames: PrintInformation.materialNames
|
||||||
|
|
||||||
color: UM.Theme.getColor("sidebar")
|
color: UM.Theme.getColor("sidebar")
|
||||||
UM.I18nCatalog { id: catalog; name:"cura"}
|
UM.I18nCatalog { id: catalog; name:"cura"}
|
||||||
@ -392,11 +393,13 @@ Rectangle
|
|||||||
var costs = [];
|
var costs = [];
|
||||||
var total_cost = 0;
|
var total_cost = 0;
|
||||||
var some_costs_known = false;
|
var some_costs_known = false;
|
||||||
|
var names = [];
|
||||||
if(base.printMaterialLengths) {
|
if(base.printMaterialLengths) {
|
||||||
for(var index = 0; index < base.printMaterialLengths.length; index++)
|
for(var index = 0; index < base.printMaterialLengths.length; index++)
|
||||||
{
|
{
|
||||||
if(base.printMaterialLengths[index] > 0)
|
if(base.printMaterialLengths[index] > 0)
|
||||||
{
|
{
|
||||||
|
names.push(base.printMaterialNames[index]);
|
||||||
lengths.push(base.printMaterialLengths[index].toFixed(2));
|
lengths.push(base.printMaterialLengths[index].toFixed(2));
|
||||||
weights.push(String(Math.floor(base.printMaterialWeights[index])));
|
weights.push(String(Math.floor(base.printMaterialWeights[index])));
|
||||||
var cost = base.printMaterialCosts[index] == undefined ? 0 : base.printMaterialCosts[index].toFixed(2);
|
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++)
|
for(var index = 0; index < lengths.length; index++)
|
||||||
{
|
{
|
||||||
var item_strings = [
|
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 m for meter", "%1m").arg(lengths[index]),
|
||||||
catalog.i18nc("@label g for grams", "%1g").arg(weights[index]),
|
catalog.i18nc("@label g for grams", "%1g").arg(weights[index]),
|
||||||
"%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]),
|
"%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user