From 4303278602d2d93f68342e3d9939c193814ad015 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 30 Nov 2017 10:35:31 +0100 Subject: [PATCH 1/2] Tweak layout and alignment of print time and (material) cost estimation... improving readability * table takes the full width and values are right-aligned * time estimates are shortened * values are right aligned * feature/time/percentage are on a single line again * handle long feature & material names gracefully Fixes #2712 * totals are only shown when there are multiple extruders --- resources/qml/Sidebar.qml | 69 +++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 31bda45b56..e02bb00c0a 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -350,21 +350,20 @@ Rectangle 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 specification
"); + var tooltip_html = "%1
".arg(catalog.i18nc("@tooltip", "Time specification")); for(var feature in print_time) { if(!print_time[feature].isTotalDurationZero) { - content += "" + - "" + - "" + - "" + + "".arg(print_time[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3)) + + "".arg(Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds)) + ""; } } - content += "
" + feature + "
" + print_time[feature].getDisplayString(UM.DurationFormat.Short) + "  " + Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds) + "%" + + tooltip_html += "
" + feature + " (in a more verbose language):  %1  %1%
"; + tooltip_html += ""; - 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), tooltip_html); } } onExited: @@ -376,9 +375,26 @@ Rectangle Label { + function formatRow(items) + { + var row_html = ""; + for(var item = 0; item < items.length; item++) + { + if (item == 0) + { + row_html += "%1".arg(items[item]); + } + else + { + row_html += "  %1".arg(items[item]); + } + } + row_html += ""; + return row_html; + } - function getSpecsData(){ - + function getSpecsData() + { var lengths = []; var total_length = 0; var weights = []; @@ -387,7 +403,8 @@ Rectangle 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++) { if(base.printMaterialLengths[index] > 0) @@ -415,34 +432,28 @@ Rectangle costs = ["0.00"]; } - var tooltip_html = "%1
".arg(catalog.i18nc("@label", "Cost specification")); + var tooltip_html = "%1
".arg(catalog.i18nc("@label", "Cost specification")); for(var index = 0; index < lengths.length; index++) { - var item_strings = [ + tooltip_html += formatRow([ "%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]); - } + "%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]), + ]); } - 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]); + if(lengths.length > 1) + { + tooltip_html += formatRow([ + 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 += "
%1  
%1  
"; + tooltip_html += ""; tooltipText = tooltip_html; - return tooltipText } From 9564bb645f8c0ca54c9e8ea950ced71320f2cd58 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 30 Nov 2017 15:54:24 +0100 Subject: [PATCH 2/2] Remove test code --- resources/qml/Sidebar.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index e02bb00c0a..bed5b4c873 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -350,12 +350,12 @@ Rectangle var total_seconds = parseInt(base.printDuration.getDisplayString(UM.DurationFormat.Seconds)) // A message is created and displayed when the user hover the time label - var tooltip_html = "%1
".arg(catalog.i18nc("@tooltip", "Time specification")); + var tooltip_html = "%1
".arg(catalog.i18nc("@tooltip", "Time specification")); for(var feature in print_time) { if(!print_time[feature].isTotalDurationZero) { - tooltip_html += "" + + tooltip_html += "" + "".arg(print_time[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3)) + "".arg(Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds)) + "";
" + feature + " (in a more verbose language):
" + feature + ":  %1  %1%