diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index f3b178c356..c709bec20a 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -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": diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 426d9dd916..c701e5ebf4 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -18,7 +18,6 @@ Item { UM.I18nCatalog { id: catalog; name:"cura"} height: childrenRect.height - width: childrenRect.width Connections { diff --git a/resources/qml/MonitorButton.qml b/resources/qml/MonitorButton.qml index 29b00f50e6..67ca2e708e 100644 --- a/resources/qml/MonitorButton.qml +++ b/resources/qml/MonitorButton.qml @@ -185,17 +185,24 @@ Item anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width; } - Row { + Item { id: buttonsRow 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.topMargin: UM.Theme.getSize("sidebar_margin").height anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width - spacing: UM.Theme.getSize("default_margin").width + clip: true Row { id: additionalComponentsRow + anchors.right: pauseResumeButton.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width spacing: UM.Theme.getSize("default_margin").width } @@ -215,6 +222,8 @@ Item { id: pauseResumeButton + anchors.right: abortButton.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width height: UM.Theme.getSize("save_button_save_to_button").height property bool userClicked: false @@ -261,6 +270,8 @@ Item { id: abortButton + anchors.right: parent.right + visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].canAbort enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands && (["paused", "printing", "pre_print"].indexOf(Cura.MachineManager.printerOutputDevices[0].jobState) >= 0) diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index acc97ebf11..e2890a6b49 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -18,6 +18,8 @@ Item { property var backend: CuraApplication.getBackend(); property bool activity: CuraApplication.platformActivity; + property alias buttonRowWidth: saveRow.width + property string fileBaseName property string statusText: { @@ -89,17 +91,30 @@ Item { Item { 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 anchors.bottom: parent.bottom anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height - anchors.left: parent.left + anchors.right: parent.right + clip: true Row { id: additionalComponentsRow anchors.top: parent.top 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 } diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 403c18a4ff..32dceb6078 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -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"} @@ -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) } - Rectangle + Item { id: printSpecs anchors.left: parent.left anchors.bottom: parent.bottom anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width 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 + clip: true Label { id: timeDetails anchors.left: parent.left - anchors.bottom: timeSpecDescription.top + anchors.bottom: costSpec.top font: UM.Theme.getFont("large") 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) MouseArea { - id: infillMouseArea + id: timeDetailsMouseArea anchors.fill: parent hoverEnabled: true - //enabled: base.settingsEnabled onEntered: { @@ -345,19 +347,24 @@ Rectangle if(base.printDuration.valid && !base.printDuration.isTotalDurationZero) { // 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 - var content = catalog.i18nc("@tooltip", "Time information") + var content = catalog.i18nc("@tooltip", "Time specification
"); for(var feature in print_time) { if(!print_time[feature].isTotalDurationZero) { - content += "
" + feature + ": " + print_time[feature].getDisplayString(UM.DurationFormat.Short) + content += ""; } } + content += "
" + feature + ":" + + "  " + print_time[feature].getDisplayString(UM.DurationFormat.Short) + + "  " + Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds) + "%" + + "
"; - 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: @@ -369,39 +376,42 @@ Rectangle Label { - id: timeSpecDescription - 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 + id: costSpec anchors.left: parent.left anchors.bottom: parent.bottom font: UM.Theme.getFont("very_small") color: UM.Theme.getColor("text_subtext") + elide: Text.ElideMiddle + width: parent.width + property string tooltipText text: { var lengths = []; + var total_length = 0; var weights = []; + var total_weight = 0; var costs = []; - var someCostsKnown = false; + 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); costs.push(cost); 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"]; costs = ["0.00"]; } - if(someCostsKnown) + + var tooltip_html = "%1
".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 += ""; + for(var item = 0; item < item_strings.length; item++) { + tooltip_html += "".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 += ""; + for(var item = 0; item < item_strings.length; item++) { + tooltip_html += "".arg(item_strings[item]); + } + tooltip_html += "
%1  
%1  
"; + 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(" + ")) - .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 { 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(); + } + } } } diff --git a/resources/qml/SidebarTooltip.qml b/resources/qml/SidebarTooltip.qml index 60d01dd6f6..07b95777b5 100644 --- a/resources/qml/SidebarTooltip.qml +++ b/resources/qml/SidebarTooltip.qml @@ -54,6 +54,7 @@ UM.PointingRectangle { rightMargin: UM.Theme.getSize("tooltip_margins").width; } wrapMode: Text.Wrap; + textFormat: Text.RichText font: UM.Theme.getFont("default"); color: UM.Theme.getColor("tooltip_text"); }