mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 01:35:55 +08:00
Create cost specification tooltip
This commit is contained in:
parent
0372475560
commit
6d4ea381f0
@ -355,7 +355,7 @@ Rectangle
|
|||||||
{
|
{
|
||||||
if(!print_time[feature].isTotalDurationZero)
|
if(!print_time[feature].isTotalDurationZero)
|
||||||
{
|
{
|
||||||
content += "<tr><td>" + feature +
|
content += "<tr><td>" + feature + ":" +
|
||||||
" </td><td>" + print_time[feature].getDisplayString(UM.DurationFormat.Short) +
|
" </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><td>" + Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds) + "%" +
|
||||||
"</td></tr>";
|
"</td></tr>";
|
||||||
@ -382,12 +382,16 @@ Rectangle
|
|||||||
color: UM.Theme.getColor("text_subtext")
|
color: UM.Theme.getColor("text_subtext")
|
||||||
elide: Text.ElideMiddle
|
elide: Text.ElideMiddle
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
property string tooltipText: "test"
|
||||||
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;
|
||||||
if(base.printMaterialLengths) {
|
if(base.printMaterialLengths) {
|
||||||
for(var index = 0; index < base.printMaterialLengths.length; index++)
|
for(var index = 0; index < base.printMaterialLengths.length; index++)
|
||||||
{
|
{
|
||||||
@ -399,8 +403,12 @@ Rectangle
|
|||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,10 +418,21 @@ Rectangle
|
|||||||
weights = ["0"];
|
weights = ["0"];
|
||||||
costs = ["0.00"];
|
costs = ["0.00"];
|
||||||
}
|
}
|
||||||
if(someCostsKnown)
|
|
||||||
|
tooltipText = catalog.i18nc("@tooltip", "<b>Cost specification</b><br/><table>");
|
||||||
|
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", "<tr><td>Extruder %0: </td><td>%1m </td><td>%2g </td><td>%4 %3</td></tr>").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", "<tr><td>Total: </td><td>%1m </td><td>%2g </td><td>%4 %3</td></tr>").arg(total_length.toFixed(2))
|
||||||
|
.arg(Math.round(total_weight)).arg(total_cost.toFixed(2)).arg(UM.Preferences.getValue("cura/currency"));
|
||||||
|
tooltipText += "</table>";
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
@ -431,15 +450,7 @@ 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
|
base.showTooltip(parent, Qt.point(-UM.Theme.getSize("sidebar_margin").width, 0), costSpec.tooltipText);
|
||||||
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", "<b>Cost specification</b><br/><table>");
|
|
||||||
content += "</table>";
|
|
||||||
|
|
||||||
base.showTooltip(parent, Qt.point(-UM.Theme.getSize("sidebar_margin").width, 0), content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited:
|
onExited:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user