From 067449192a882bfff91f3b8c0f397d7c98af8bdd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 14 Aug 2017 09:04:26 +0200 Subject: [PATCH] Move time/material estimates code to sidebar It sort of works but is aligned all wrong right now. Contributes to issue CURA-4149. --- resources/qml/JobSpecs.qml | 138 +----------------------------------- resources/qml/Sidebar.qml | 141 ++++++++++++++++++++++++++++++++++++- 2 files changed, 141 insertions(+), 138 deletions(-) diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index fa0ca087b7..545615aff0 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Ultimaker B.V. +// Copyright (c) 2017 Ultimaker B.V. // Cura is released under the terms of the AGPLv3 or higher. import QtQuick 2.2 @@ -23,8 +23,6 @@ Item { UM.I18nCatalog { id: catalog; name:"cura"} - property variant printDuration: PrintInformation.currentPrintTime - property variant printDurationPerFeature: PrintInformation.printTimesPerFeature property variant printMaterialLengths: PrintInformation.materialLengths property variant printMaterialWeights: PrintInformation.materialWeights property variant printMaterialCosts: PrintInformation.materialCosts @@ -144,138 +142,4 @@ Item { color: UM.Theme.getColor("text_subtext") text: CuraApplication.getSceneBoundingBoxString } - - Rectangle - { - id: specsRow - anchors.top: boundingSpec.bottom - anchors.right: parent.right - height: UM.Theme.getSize("jobspecs_line").height - - Item - { - width: parent.width - height: parent.height - - UM.TooltipArea - { - id: timeSpecPerFeatureTooltipArea - text: { - var order = ["inset_0", "inset_x", "skin", "infill", "support_infill", "support_interface", "support", "travel", "retract", "none"]; - var visible_names = { - "inset_0": catalog.i18nc("@tooltip", "Outer Wall"), - "inset_x": catalog.i18nc("@tooltip", "Inner Walls"), - "skin": catalog.i18nc("@tooltip", "Skin"), - "infill": catalog.i18nc("@tooltip", "Infill"), - "support_infill": catalog.i18nc("@tooltip", "Support Infill"), - "support_interface": catalog.i18nc("@tooltip", "Support Interface"), - "support": catalog.i18nc("@tooltip", "Support"), - "travel": catalog.i18nc("@tooltip", "Travel"), - "retract": catalog.i18nc("@tooltip", "Retractions"), - "none": catalog.i18nc("@tooltip", "Other") - }; - var result = ""; - for(var feature in order) - { - feature = order[feature]; - if(base.printDurationPerFeature[feature] && base.printDurationPerFeature[feature].totalSeconds > 0) - { - result += "
" + visible_names[feature] + ": " + base.printDurationPerFeature[feature].getDisplayString(UM.DurationFormat.Short); - } - } - result = result.replace(/^\/, ""); // remove newline before first item - return result; - } - width: childrenRect.width - height: childrenRect.height - anchors.right: lengthIcon.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - anchors.verticalCenter: parent.verticalCenter - - UM.RecolorImage - { - id: timeIcon - anchors.left: parent.left - anchors.top: parent.top - anchors.verticalCenter: parent.verticalCenter - width: UM.Theme.getSize("save_button_specs_icons").width - height: UM.Theme.getSize("save_button_specs_icons").height - sourceSize.width: width - sourceSize.height: width - color: UM.Theme.getColor("text_subtext") - source: UM.Theme.getIcon("print_time") - } - - Text - { - id: timeSpec - anchors.left: timeIcon.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width / 2 - anchors.top: parent.top - font: UM.Theme.getFont("small") - color: UM.Theme.getColor("text_subtext") - text: (!base.printDuration || !base.printDuration.valid) ? catalog.i18nc("@label", "00h 00min") : base.printDuration.getDisplayString(UM.DurationFormat.Short) - } - } - UM.RecolorImage - { - id: lengthIcon - anchors.right: lengthSpec.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width/2 - anchors.verticalCenter: parent.verticalCenter - width: UM.Theme.getSize("save_button_specs_icons").width - height: UM.Theme.getSize("save_button_specs_icons").height - sourceSize.width: width - sourceSize.height: width - color: UM.Theme.getColor("text_subtext") - source: UM.Theme.getIcon("category_material") - } - Text - { - id: lengthSpec - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - font: UM.Theme.getFont("small") - color: UM.Theme.getColor("text_subtext") - text: - { - var lengths = []; - var weights = []; - var costs = []; - var someCostsKnown = false; - if(base.printMaterialLengths) { - for(var index = 0; index < base.printMaterialLengths.length; index++) - { - if(base.printMaterialLengths[index] > 0) - { - 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; - } - } - } - } - if(lengths.length == 0) - { - lengths = ["0.00"]; - weights = ["0"]; - costs = ["0.00"]; - } - if(someCostsKnown) - { - return catalog.i18nc("@label", "%1 m / ~ %2 g / ~ %4 %3").arg(lengths.join(" + ")) - .arg(weights.join(" + ")).arg(costs.join(" + ")).arg(UM.Preferences.getValue("cura/currency")); - } - else - { - return catalog.i18nc("@label", "%1 m / ~ %2 g").arg(lengths.join(" + ")).arg(weights.join(" + ")); - } - } - } - } - } } diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index db5f60862d..1f18a3d031 100755 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -21,10 +21,13 @@ Rectangle property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null - property int backendState: UM.Backend.state; + property int backendState: UM.Backend.state property bool monitoringPrint: false + property variant printDuration: PrintInformation.currentPrintTime + property variant printDurationPerFeature: PrintInformation.printTimesPerFeature + color: UM.Theme.getColor("sidebar") UM.I18nCatalog { id: catalog; name:"cura"} @@ -398,6 +401,142 @@ Rectangle anchors.bottomMargin: UM.Theme.getSize("default_margin").height } + Rectangle + { + id: specsRow + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + height: UM.Theme.getSize("jobspecs_line").height + + Item + { + width: parent.width + height: parent.height + + UM.TooltipArea + { + id: timeSpecPerFeatureTooltipArea + text: { + var order = ["inset_0", "inset_x", "skin", "infill", "support_infill", "support_interface", "support", "travel", "retract", "none"]; + var visible_names = { + "inset_0": catalog.i18nc("@tooltip", "Outer Wall"), + "inset_x": catalog.i18nc("@tooltip", "Inner Walls"), + "skin": catalog.i18nc("@tooltip", "Skin"), + "infill": catalog.i18nc("@tooltip", "Infill"), + "support_infill": catalog.i18nc("@tooltip", "Support Infill"), + "support_interface": catalog.i18nc("@tooltip", "Support Interface"), + "support": catalog.i18nc("@tooltip", "Support"), + "travel": catalog.i18nc("@tooltip", "Travel"), + "retract": catalog.i18nc("@tooltip", "Retractions"), + "none": catalog.i18nc("@tooltip", "Other") + }; + var result = ""; + for(var feature in order) + { + feature = order[feature]; + if(base.printDurationPerFeature[feature] && base.printDurationPerFeature[feature].totalSeconds > 0) + { + result += "
" + visible_names[feature] + ": " + base.printDurationPerFeature[feature].getDisplayString(UM.DurationFormat.Short); + } + } + result = result.replace(/^\/, ""); // remove newline before first item + return result; + } + width: childrenRect.width + height: childrenRect.height + anchors.right: lengthIcon.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.verticalCenter: parent.verticalCenter + + UM.RecolorImage + { + id: timeIcon + anchors.left: parent.left + anchors.top: parent.top + anchors.verticalCenter: parent.verticalCenter + width: UM.Theme.getSize("save_button_specs_icons").width + height: UM.Theme.getSize("save_button_specs_icons").height + sourceSize.width: width + sourceSize.height: width + color: UM.Theme.getColor("text_subtext") + source: UM.Theme.getIcon("print_time") + } + + Text + { + id: timeSpec + anchors.left: timeIcon.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width / 2 + anchors.top: parent.top + font: UM.Theme.getFont("small") + color: UM.Theme.getColor("text_subtext") + text: (!base.printDuration || !base.printDuration.valid) ? catalog.i18nc("@label", "00h 00min") : base.printDuration.getDisplayString(UM.DurationFormat.Short) + } + } + UM.RecolorImage + { + id: lengthIcon + anchors.right: lengthSpec.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width/2 + anchors.verticalCenter: parent.verticalCenter + width: UM.Theme.getSize("save_button_specs_icons").width + height: UM.Theme.getSize("save_button_specs_icons").height + sourceSize.width: width + sourceSize.height: width + color: UM.Theme.getColor("text_subtext") + source: UM.Theme.getIcon("category_material") + } + Text + { + id: lengthSpec + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + font: UM.Theme.getFont("small") + color: UM.Theme.getColor("text_subtext") + text: + { + var lengths = []; + var weights = []; + var costs = []; + var someCostsKnown = false; + if(base.printMaterialLengths) { + for(var index = 0; index < base.printMaterialLengths.length; index++) + { + if(base.printMaterialLengths[index] > 0) + { + 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; + } + } + } + } + if(lengths.length == 0) + { + lengths = ["0.00"]; + weights = ["0"]; + costs = ["0.00"]; + } + if(someCostsKnown) + { + return catalog.i18nc("@label", "%1 m / ~ %2 g / ~ %4 %3").arg(lengths.join(" + ")) + .arg(weights.join(" + ")).arg(costs.join(" + ")).arg(UM.Preferences.getValue("cura/currency")); + } + else + { + return catalog.i18nc("@label", "%1 m / ~ %2 g").arg(lengths.join(" + ")).arg(weights.join(" + ")); + } + } + } + } + } + // SaveButton and MonitorButton are actually the bottom footer panels. // "!monitoringPrint" currently means "show-settings-mode" SaveButton