From 177295999b3e81e116442d0cc17eea8a76046a38 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sun, 29 Oct 2017 09:19:50 +0100 Subject: [PATCH 1/9] Allow richer markup in tooltips --- resources/qml/SidebarTooltip.qml | 1 + 1 file changed, 1 insertion(+) 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"); } From 208d365d51b61b077a0f6a627ddca91f524a5707 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sun, 29 Oct 2017 09:20:59 +0100 Subject: [PATCH 2/9] Make sure saveRow does not extend sidebar --- resources/qml/SaveButton.qml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index acc97ebf11..63c44a6720 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,11 +91,12 @@ Item { Item { id: saveRow - width: base.width + width: Math.min(childrenRect.width + UM.Theme.getSize("sidebar_margin").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 From 6a0ba435084d9b5a2007183828fae1c70dfdf07f Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sun, 29 Oct 2017 10:07:42 +0100 Subject: [PATCH 3/9] Make sure monitor buttons do not extend sidebar --- resources/qml/MonitorButton.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/qml/MonitorButton.qml b/resources/qml/MonitorButton.qml index 29b00f50e6..7a620c42ea 100644 --- a/resources/qml/MonitorButton.qml +++ b/resources/qml/MonitorButton.qml @@ -185,17 +185,20 @@ Item anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width; } - Row { + Item { id: buttonsRow height: abortButton.height + width: Math.min(childrenRect.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 +218,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 +266,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) From 03724755604a31f2adc6e9293645ea9586bbe149 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sun, 29 Oct 2017 10:09:52 +0100 Subject: [PATCH 4/9] Rearrange print specs area * remove superfluous "Print time" label * format print time tooltip * add elide to cost spec * add (empty) cost spec tooltip --- resources/qml/Sidebar.qml | 64 +++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 403c18a4ff..ed6b07cc4e 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -313,31 +313,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 +346,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,20 +375,13 @@ 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 text: { var lengths = []; @@ -421,6 +420,33 @@ Rectangle 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) + { + // All the time information for the different features is achieved + 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", "Cost specification
"); + content += "
"; + + base.showTooltip(parent, Qt.point(-UM.Theme.getSize("sidebar_margin").width, 0), content); + } + } + onExited: + { + base.hideTooltip(); + } + } } } From 6d4ea381f0b9420b2ae89805915a985b743eb4c9 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sun, 29 Oct 2017 11:44:36 +0100 Subject: [PATCH 5/9] Create cost specification tooltip --- resources/qml/Sidebar.qml | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index ed6b07cc4e..582fb346c5 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -355,7 +355,7 @@ Rectangle { if(!print_time[feature].isTotalDurationZero) { - content += "" + feature + + content += "" + feature + ":" + "  " + print_time[feature].getDisplayString(UM.DurationFormat.Short) + "  " + Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds) + "%" + ""; @@ -382,12 +382,16 @@ Rectangle color: UM.Theme.getColor("text_subtext") elide: Text.ElideMiddle width: parent.width + property string tooltipText: "test" 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; if(base.printMaterialLengths) { for(var index = 0; index < base.printMaterialLengths.length; index++) { @@ -399,8 +403,12 @@ Rectangle 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]; } } } @@ -410,10 +418,21 @@ Rectangle weights = ["0"]; costs = ["0.00"]; } - if(someCostsKnown) + + tooltipText = catalog.i18nc("@tooltip", "Cost specification
"); + for(var index = 0; index < lengths.length; index++) + { + tooltipText += catalog.i18nc("@label Print estimates: m for meters, g for grams, %4 is currency and %3 is print cost", "").arg(index + 1).arg(lengths[index]) + .arg(weights[index]).arg(costs[index]).arg(UM.Preferences.getValue("cura/currency")); + } + tooltipText += catalog.i18nc("@label Print totals: m for meters, g for grams, %4 is currency and %3 is print cost", "").arg(total_length.toFixed(2)) + .arg(Math.round(total_weight)).arg(total_cost.toFixed(2)).arg(UM.Preferences.getValue("cura/currency")); + tooltipText += "
Extruder %0:  %1m  %2g  %4 %3
Total:  %1m  %2g  %4 %3
"; + + 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 { @@ -431,15 +450,7 @@ Rectangle if(base.printDuration.valid && !base.printDuration.isTotalDurationZero) { - // All the time information for the different features is achieved - 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", "Cost specification
"); - content += "
"; - - 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), costSpec.tooltipText); } } onExited: From 84002a70d0462ff44d98b90fd9144b98a2e7e8f1 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 30 Oct 2017 11:50:57 +0100 Subject: [PATCH 6/9] Remove binding loop by cleaning up tooltipText creation --- resources/qml/Sidebar.qml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 582fb346c5..14179d388d 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -382,7 +382,7 @@ Rectangle color: UM.Theme.getColor("text_subtext") elide: Text.ElideMiddle width: parent.width - property string tooltipText: "test" + property string tooltipText text: { var lengths = []; @@ -419,15 +419,32 @@ Rectangle costs = ["0.00"]; } - tooltipText = catalog.i18nc("@tooltip", "Cost specification
"); + var tooltip_html = "%1
".arg(catalog.i18nc("@label", "Cost specification")); for(var index = 0; index < lengths.length; index++) { - tooltipText += catalog.i18nc("@label Print estimates: m for meters, g for grams, %4 is currency and %3 is print cost", "").arg(index + 1).arg(lengths[index]) - .arg(weights[index]).arg(costs[index]).arg(UM.Preferences.getValue("cura/currency")); + var item_strings = [ + catalog.i18nc("@label", "Extruder %1:").arg(index + 1), + 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]); + } } - tooltipText += catalog.i18nc("@label Print totals: m for meters, g for grams, %4 is currency and %3 is print cost", "").arg(total_length.toFixed(2)) - .arg(Math.round(total_weight)).arg(total_cost.toFixed(2)).arg(UM.Preferences.getValue("cura/currency")); - tooltipText += "
Extruder %0:  %1m  %2g  %4 %3
%1  
Total:  %1m  %2g  %4 %3
"; + 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 += "%1  ".arg(item_strings[item]); + } + tooltip_html += ""; + tooltipText = tooltip_html; if(some_costs_known) { From 6fa4dd0a977634f5693c759ea87ae8411399c629 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 30 Oct 2017 12:26:02 +0100 Subject: [PATCH 7/9] Fix qml binding loops --- resources/qml/MonitorButton.qml | 6 +++++- resources/qml/SaveButton.qml | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/resources/qml/MonitorButton.qml b/resources/qml/MonitorButton.qml index 7a620c42ea..67ca2e708e 100644 --- a/resources/qml/MonitorButton.qml +++ b/resources/qml/MonitorButton.qml @@ -188,7 +188,11 @@ Item Item { id: buttonsRow height: abortButton.height - width: Math.min(childrenRect.width, base.width - 2 * UM.Theme.getSize("sidebar_margin").width) + 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 diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index 63c44a6720..e2890a6b49 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -91,7 +91,19 @@ Item { Item { id: saveRow - width: Math.min(childrenRect.width + UM.Theme.getSize("sidebar_margin").width, base.width - UM.Theme.getSize("sidebar_margin").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 @@ -102,7 +114,7 @@ Item { 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 } From fc7d1210cf660147a4650a69df884e844f5f3fc8 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 30 Oct 2017 12:31:46 +0100 Subject: [PATCH 8/9] Fix qml binding loop --- resources/qml/JobSpecs.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 308316d3e9..5e892a34bc 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 { From 2d109090bc29ab79af81322c3ac9f2fd92c4fa3a Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 30 Oct 2017 12:40:41 +0100 Subject: [PATCH 9/9] Show material name instead of extruder number --- cura/PrintInformation.py | 10 ++++++++++ resources/qml/Sidebar.qml | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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/Sidebar.qml b/resources/qml/Sidebar.qml index 14179d388d..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"} @@ -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]),