mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 05:05:53 +08:00
Merge branch 'master' of https://github.com/Ultimaker/Cura
This commit is contained in:
commit
4326884f97
@ -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":
|
||||||
|
@ -18,7 +18,6 @@ Item {
|
|||||||
UM.I18nCatalog { id: catalog; name:"cura"}
|
UM.I18nCatalog { id: catalog; name:"cura"}
|
||||||
|
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: childrenRect.width
|
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
|
@ -185,17 +185,24 @@ Item
|
|||||||
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width;
|
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width;
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: buttonsRow
|
id: buttonsRow
|
||||||
height: abortButton.height
|
height: abortButton.height
|
||||||
|
width: {
|
||||||
|
// using childrenRect.width directly causes a binding loop, because setting the width affects the childrenRect
|
||||||
|
var children_width = additionalComponentsRow.width + pauseResumeButton.width + abortButton.width + 3 * UM.Theme.getSize("default_margin").width;
|
||||||
|
return Math.min(children_width, base.width - 2 * UM.Theme.getSize("sidebar_margin").width);
|
||||||
|
}
|
||||||
anchors.top: progressBar.bottom
|
anchors.top: progressBar.bottom
|
||||||
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
|
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
|
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
|
||||||
spacing: UM.Theme.getSize("default_margin").width
|
clip: true
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: additionalComponentsRow
|
id: additionalComponentsRow
|
||||||
|
anchors.right: pauseResumeButton.left
|
||||||
|
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
spacing: UM.Theme.getSize("default_margin").width
|
spacing: UM.Theme.getSize("default_margin").width
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +222,8 @@ Item
|
|||||||
{
|
{
|
||||||
id: pauseResumeButton
|
id: pauseResumeButton
|
||||||
|
|
||||||
|
anchors.right: abortButton.left
|
||||||
|
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
height: UM.Theme.getSize("save_button_save_to_button").height
|
height: UM.Theme.getSize("save_button_save_to_button").height
|
||||||
|
|
||||||
property bool userClicked: false
|
property bool userClicked: false
|
||||||
@ -261,6 +270,8 @@ Item
|
|||||||
{
|
{
|
||||||
id: abortButton
|
id: abortButton
|
||||||
|
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].canAbort
|
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].canAbort
|
||||||
enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
|
enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
|
||||||
(["paused", "printing", "pre_print"].indexOf(Cura.MachineManager.printerOutputDevices[0].jobState) >= 0)
|
(["paused", "printing", "pre_print"].indexOf(Cura.MachineManager.printerOutputDevices[0].jobState) >= 0)
|
||||||
|
@ -18,6 +18,8 @@ Item {
|
|||||||
property var backend: CuraApplication.getBackend();
|
property var backend: CuraApplication.getBackend();
|
||||||
property bool activity: CuraApplication.platformActivity;
|
property bool activity: CuraApplication.platformActivity;
|
||||||
|
|
||||||
|
property alias buttonRowWidth: saveRow.width
|
||||||
|
|
||||||
property string fileBaseName
|
property string fileBaseName
|
||||||
property string statusText:
|
property string statusText:
|
||||||
{
|
{
|
||||||
@ -89,17 +91,30 @@ Item {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: saveRow
|
id: saveRow
|
||||||
width: base.width
|
width: {
|
||||||
|
// using childrenRect.width directly causes a binding loop, because setting the width affects the childrenRect
|
||||||
|
var children_width = UM.Theme.getSize("default_margin").width;
|
||||||
|
for (var index in children)
|
||||||
|
{
|
||||||
|
var child = children[index];
|
||||||
|
if(child.visible)
|
||||||
|
{
|
||||||
|
children_width += child.width + child.anchors.rightMargin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Math.min(children_width, base.width - UM.Theme.getSize("sidebar_margin").width);
|
||||||
|
}
|
||||||
height: saveToButton.height
|
height: saveToButton.height
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height
|
anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height
|
||||||
anchors.left: parent.left
|
anchors.right: parent.right
|
||||||
|
clip: true
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: additionalComponentsRow
|
id: additionalComponentsRow
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.right: saveToButton.visible ? saveToButton.left : parent.right
|
anchors.right: saveToButton.visible ? saveToButton.left : parent.right
|
||||||
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
|
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
|
|
||||||
spacing: UM.Theme.getSize("default_margin").width
|
spacing: UM.Theme.getSize("default_margin").width
|
||||||
}
|
}
|
||||||
|
@ -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"}
|
||||||
@ -313,31 +314,32 @@ Rectangle
|
|||||||
anchors.bottomMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 2 + UM.Theme.getSize("progressbar").height + UM.Theme.getFont("default_bold").pixelSize)
|
anchors.bottomMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 2 + UM.Theme.getSize("progressbar").height + UM.Theme.getFont("default_bold").pixelSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle
|
Item
|
||||||
{
|
{
|
||||||
id: printSpecs
|
id: printSpecs
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
|
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
|
||||||
anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height
|
anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height
|
||||||
height: timeDetails.height + timeSpecDescription.height + lengthSpec.height
|
height: timeDetails.height + costSpec.height
|
||||||
|
width: base.width - (saveButton.buttonRowWidth + UM.Theme.getSize("sidebar_margin").width)
|
||||||
visible: !monitoringPrint
|
visible: !monitoringPrint
|
||||||
|
clip: true
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
id: timeDetails
|
id: timeDetails
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.bottom: timeSpecDescription.top
|
anchors.bottom: costSpec.top
|
||||||
font: UM.Theme.getFont("large")
|
font: UM.Theme.getFont("large")
|
||||||
color: UM.Theme.getColor("text_subtext")
|
color: UM.Theme.getColor("text_subtext")
|
||||||
text: (!base.printDuration || !base.printDuration.valid) ? catalog.i18nc("@label Hours and minutes", "00h 00min") : base.printDuration.getDisplayString(UM.DurationFormat.Short)
|
text: (!base.printDuration || !base.printDuration.valid) ? catalog.i18nc("@label Hours and minutes", "00h 00min") : base.printDuration.getDisplayString(UM.DurationFormat.Short)
|
||||||
|
|
||||||
MouseArea
|
MouseArea
|
||||||
{
|
{
|
||||||
id: infillMouseArea
|
id: timeDetailsMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
//enabled: base.settingsEnabled
|
|
||||||
|
|
||||||
onEntered:
|
onEntered:
|
||||||
{
|
{
|
||||||
@ -345,19 +347,24 @@ Rectangle
|
|||||||
if(base.printDuration.valid && !base.printDuration.isTotalDurationZero)
|
if(base.printDuration.valid && !base.printDuration.isTotalDurationZero)
|
||||||
{
|
{
|
||||||
// All the time information for the different features is achieved
|
// All the time information for the different features is achieved
|
||||||
var print_time = PrintInformation.getFeaturePrintTimes()
|
var print_time = PrintInformation.getFeaturePrintTimes();
|
||||||
|
var total_seconds = parseInt(base.printDuration.getDisplayString(UM.DurationFormat.Seconds))
|
||||||
|
|
||||||
// A message is created and displayed when the user hover the time label
|
// A message is created and displayed when the user hover the time label
|
||||||
var content = catalog.i18nc("@tooltip", "<b>Time information</b>")
|
var content = catalog.i18nc("@tooltip", "<b>Time specification</b><br/><table>");
|
||||||
for(var feature in print_time)
|
for(var feature in print_time)
|
||||||
{
|
{
|
||||||
if(!print_time[feature].isTotalDurationZero)
|
if(!print_time[feature].isTotalDurationZero)
|
||||||
{
|
{
|
||||||
content += "<br /><i>" + feature + "</i>: " + print_time[feature].getDisplayString(UM.DurationFormat.Short)
|
content += "<tr><td>" + feature + ":" +
|
||||||
|
" </td><td>" + print_time[feature].getDisplayString(UM.DurationFormat.Short) +
|
||||||
|
" </td><td>" + Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds) + "%" +
|
||||||
|
"</td></tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
content += "</table>";
|
||||||
|
|
||||||
base.showTooltip(parent, Qt.point(-UM.Theme.getSize("sidebar_margin").width, 0), content)
|
base.showTooltip(parent, Qt.point(-UM.Theme.getSize("sidebar_margin").width, 0), content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited:
|
onExited:
|
||||||
@ -369,39 +376,42 @@ Rectangle
|
|||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
id: timeSpecDescription
|
id: costSpec
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.bottom: lengthSpec.top
|
|
||||||
font: UM.Theme.getFont("very_small")
|
|
||||||
color: UM.Theme.getColor("text_subtext")
|
|
||||||
text: catalog.i18nc("@description", "Print time")
|
|
||||||
}
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
id: lengthSpec
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
font: UM.Theme.getFont("very_small")
|
font: UM.Theme.getFont("very_small")
|
||||||
color: UM.Theme.getColor("text_subtext")
|
color: UM.Theme.getColor("text_subtext")
|
||||||
|
elide: Text.ElideMiddle
|
||||||
|
width: parent.width
|
||||||
|
property string tooltipText
|
||||||
text:
|
text:
|
||||||
{
|
{
|
||||||
var lengths = [];
|
var lengths = [];
|
||||||
|
var total_length = 0;
|
||||||
var weights = [];
|
var weights = [];
|
||||||
|
var total_weight = 0;
|
||||||
var costs = [];
|
var costs = [];
|
||||||
var someCostsKnown = false;
|
var total_cost = 0;
|
||||||
|
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);
|
||||||
costs.push(cost);
|
costs.push(cost);
|
||||||
if(cost > 0)
|
if(cost > 0)
|
||||||
{
|
{
|
||||||
someCostsKnown = true;
|
some_costs_known = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
total_length += base.printMaterialLengths[index];
|
||||||
|
total_weight += base.printMaterialWeights[index];
|
||||||
|
total_cost += base.printMaterialCosts[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,16 +421,63 @@ Rectangle
|
|||||||
weights = ["0"];
|
weights = ["0"];
|
||||||
costs = ["0.00"];
|
costs = ["0.00"];
|
||||||
}
|
}
|
||||||
if(someCostsKnown)
|
|
||||||
|
var tooltip_html = "<b>%1</b><br/><table>".arg(catalog.i18nc("@label", "Cost specification"));
|
||||||
|
for(var index = 0; index < lengths.length; index++)
|
||||||
|
{
|
||||||
|
var item_strings = [
|
||||||
|
"%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]),
|
||||||
|
];
|
||||||
|
tooltip_html += "<tr>";
|
||||||
|
for(var item = 0; item < item_strings.length; item++) {
|
||||||
|
tooltip_html += "<td>%1 </td>".arg(item_strings[item]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var item_strings = [
|
||||||
|
catalog.i18nc("@label", "Total:"),
|
||||||
|
catalog.i18nc("@label m for meter", "%1m").arg(total_length.toFixed(2)),
|
||||||
|
catalog.i18nc("@label g for grams", "%1g").arg(Math.round(total_weight)),
|
||||||
|
"%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(total_cost.toFixed(2)),
|
||||||
|
];
|
||||||
|
tooltip_html += "<tr>";
|
||||||
|
for(var item = 0; item < item_strings.length; item++) {
|
||||||
|
tooltip_html += "<td>%1 </td>".arg(item_strings[item]);
|
||||||
|
}
|
||||||
|
tooltip_html += "</tr></table>";
|
||||||
|
tooltipText = tooltip_html;
|
||||||
|
|
||||||
|
if(some_costs_known)
|
||||||
{
|
{
|
||||||
return catalog.i18nc("@label Print estimates: m for meters, g for grams, %4 is currency and %3 is print cost", "%1m / ~ %2g / ~ %4 %3").arg(lengths.join(" + "))
|
return catalog.i18nc("@label Print estimates: m for meters, g for grams, %4 is currency and %3 is print cost", "%1m / ~ %2g / ~ %4 %3").arg(lengths.join(" + "))
|
||||||
.arg(weights.join(" + ")).arg(costs.join(" + ")).arg(UM.Preferences.getValue("cura/currency"));
|
.arg(Math.round(total_weight)).arg(total_cost.toFixed(2)).arg(UM.Preferences.getValue("cura/currency"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return catalog.i18nc("@label Print estimates: m for meters, g for grams", "%1m / ~ %2g").arg(lengths.join(" + ")).arg(weights.join(" + "));
|
return catalog.i18nc("@label Print estimates: m for meters, g for grams", "%1m / ~ %2g").arg(lengths.join(" + ")).arg(weights.join(" + "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
id: costSpecMouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
onEntered:
|
||||||
|
{
|
||||||
|
|
||||||
|
if(base.printDuration.valid && !base.printDuration.isTotalDurationZero)
|
||||||
|
{
|
||||||
|
base.showTooltip(parent, Qt.point(-UM.Theme.getSize("sidebar_margin").width, 0), costSpec.tooltipText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited:
|
||||||
|
{
|
||||||
|
base.hideTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ UM.PointingRectangle {
|
|||||||
rightMargin: UM.Theme.getSize("tooltip_margins").width;
|
rightMargin: UM.Theme.getSize("tooltip_margins").width;
|
||||||
}
|
}
|
||||||
wrapMode: Text.Wrap;
|
wrapMode: Text.Wrap;
|
||||||
|
textFormat: Text.RichText
|
||||||
font: UM.Theme.getFont("default");
|
font: UM.Theme.getFont("default");
|
||||||
color: UM.Theme.getColor("tooltip_text");
|
color: UM.Theme.getColor("tooltip_text");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user