Re-add config changes in monitor tab

Contributes to CL-1152
This commit is contained in:
Ian Paschal 2018-12-10 11:36:51 +01:00
parent ad7dcf6fc0
commit 8a856f13d2
9 changed files with 210 additions and 32 deletions

View file

@ -130,7 +130,7 @@ Component
verticalCenter: externalLinkIcon.verticalCenter verticalCenter: externalLinkIcon.verticalCenter
} }
color: UM.Theme.getColor("primary") color: UM.Theme.getColor("primary")
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default") // 12pt, regular
linkColor: UM.Theme.getColor("primary") linkColor: UM.Theme.getColor("primary")
text: catalog.i18nc("@label link to connect manager", "Manage queue in Cura Connect") text: catalog.i18nc("@label link to connect manager", "Manage queue in Cura Connect")
} }

View file

@ -57,7 +57,7 @@ Cura.MachineAction
spacing: UM.Theme.getSize("default_margin").height spacing: UM.Theme.getSize("default_margin").height
SystemPalette { id: palette } SystemPalette { id: palette }
UM.I18nCatalog { id: catalog; name: "cura" } UM.I18nCatalog { id: catalog; name:"cura" }
Label Label
{ {
id: pageTitle id: pageTitle

View file

@ -1,12 +0,0 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.3
import QtQuick.Controls 2.0
import UM 1.3 as UM
Rectangle {
color: UM.Theme.getColor("monitor_lining_light"); // TODO: Maybe theme separately? Maybe not.
height: UM.Theme.getSize("default_lining").height;
width: parent.width;
}

View file

@ -0,0 +1,131 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.3
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
import UM 1.3 as UM
UM.Dialog
{
id: overrideConfirmationDialog
property var printer: null
minimumWidth: screenScaleFactor * 640;
minimumHeight: screenScaleFactor * 320;
width: minimumWidth
height: minimumHeight
title: catalog.i18nc("@title:window", "Configuration Changes")
rightButtons:
[
Button
{
id: overrideButton
anchors.margins: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@action:button", "Override")
onClicked:
{
OutputDevice.forceSendJob(printer.activePrintJob.key)
overrideConfirmationDialog.close()
}
},
Button
{
id: cancelButton
anchors.margins: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@action:button", "Cancel")
onClicked:
{
overrideConfirmationDialog.reject()
}
}
]
Label
{
anchors
{
fill: parent
leftMargin: 60
rightMargin: 60
topMargin: 18
bottomMargin: 56
}
wrapMode: Text.WordWrap
text:
{
var topLine
if (materialsAreKnown(printer.activePrintJob))
{
topLine = catalog.i18nc("@label", "The assigned printer, %1, requires the following configuration change(s):").arg(printer.name)
}
else
{
topLine = catalog.i18nc("@label", "The printer %1 is assigned, but the job contains an unknown material configuration.").arg(printer.name)
}
var result = "<p>" + topLine +"</p>"
for (var i = 0; i < printer.activePrintJob.configurationChanges.length; i++)
{
var change = printer.activePrintJob.configurationChanges[i]
var text
switch (change.typeOfChange)
{
case "material_change":
text = catalog.i18nc("@label", "Change material %1 from %2 to %3.").arg(change.index + 1).arg(change.originName).arg(change.targetName)
break
case "material_insert":
text = catalog.i18nc("@label", "Load %3 as material %1 (This cannot be overridden).").arg(change.index + 1).arg(change.targetName)
break
case "print_core_change":
text = catalog.i18nc("@label", "Change print core %1 from %2 to %3.").arg(change.index + 1).arg(change.originName).arg(change.targetName)
break
case "buildplate_change":
text = catalog.i18nc("@label", "Change build plate to %1 (This cannot be overridden).").arg(formatBuildPlateType(change.target_name))
break
default:
text = "unknown"
}
result += "<p><b>" + text + "</b></p>"
}
return result
}
}
// Utils
function formatPrintJobName(name) {
var extensions = [ ".gz", ".gcode", ".ufp" ];
for (var i = 0; i < extensions.length; i++) {
var extension = extensions[i];
if (name.slice(-extension.length) === extension) {
name = name.substring(0, name.length - extension.length);
}
}
return name;
}
function materialsAreKnown(job) {
var conf0 = job.configuration[0];
if (conf0 && !conf0.material.material) {
return false;
}
var conf1 = job.configuration[1];
if (conf1 && !conf1.material.material) {
return false;
}
return true;
}
function formatBuildPlateType(buildPlateType) {
var translationText = "";
switch (buildPlateType) {
case "glass":
translationText = catalog.i18nc("@label", "Glass");
break;
case "aluminum":
translationText = catalog.i18nc("@label", "Aluminum");
break;
default:
translationText = null;
}
return translationText;
}
}

View file

@ -26,6 +26,7 @@ Item
ExpandableCard ExpandableCard
{ {
borderColor: printJob.configurationChanges.length !== 0 ? "#f5a623" : "#EAEAEC" // TODO: Theme!
headerItem: Row headerItem: Row
{ {
height: 48 * screenScaleFactor // TODO: Theme! height: 48 * screenScaleFactor // TODO: Theme!

View file

@ -23,7 +23,7 @@ Item
anchors.fill: parent anchors.fill: parent
opacity: opacity:
{ {
if (printJob && (printJob.state == "error" || !printJob.isActive)) if (printJob && (printJob.state == "error" || printJob.configurationChanges.length > 0 || !printJob.isActive))
{ {
return 0.5 return 0.5
} }
@ -60,6 +60,10 @@ Item
height: 0.5 * printJobPreview.height height: 0.5 * printJobPreview.height
source: source:
{ {
if (printJob.configurationChanges.length > 0)
{
return "../svg/warning-icon.svg"
}
switch(printJob.state) switch(printJob.state)
{ {
case "error": case "error":
@ -75,6 +79,7 @@ Item
default: default:
return "" return ""
} }
return ""
} }
sourceSize sourceSize
{ {

View file

@ -88,6 +88,8 @@ Item
return catalog.i18nc("@label:status", "Aborted") return catalog.i18nc("@label:status", "Aborted")
} }
return catalog.i18nc("@label:status", "Finished") return catalog.i18nc("@label:status", "Finished")
case "finished":
return catalog.i18nc("@label:status", "Finished")
case "sent_to_printer": case "sent_to_printer":
return catalog.i18nc("@label:status", "Preparing...") return catalog.i18nc("@label:status", "Preparing...")
case "pre_print": case "pre_print":

View file

@ -3,6 +3,7 @@
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.1
import UM 1.3 as UM import UM 1.3 as UM
/** /**
@ -66,7 +67,7 @@ Item
{ {
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
width: 216 * screenScaleFactor // TODO: Theme! width: 180 * screenScaleFactor // TODO: Theme!
height: printerNameLabel.height + printerFamilyPill.height + 6 * screenScaleFactor // TODO: Theme! height: printerNameLabel.height + printerFamilyPill.height + 6 * screenScaleFactor // TODO: Theme!
Label Label
@ -150,7 +151,7 @@ Item
} }
border border
{ {
color: "#EAEAEC" // TODO: Theme! color: printer.activePrintJob && printer.activePrintJob.configurationChanges.length > 0 ? "#f5a623" : "#EAEAEC" // TODO: Theme!
width: borderSize // TODO: Remove once themed width: borderSize // TODO: Remove once themed
} }
color: "white" // TODO: Theme! color: "white" // TODO: Theme!
@ -185,14 +186,15 @@ Item
} }
if (printer && printer.state == "unreachable") if (printer && printer.state == "unreachable")
{ {
return catalog.i18nc("@label:status", "Unreachable") return catalog.i18nc("@label:status", "Unavailable")
} }
if (printer && printer.state == "idle") if (printer && !printer.activePrintJob && printer.state == "idle")
{ {
return catalog.i18nc("@label:status", "Idle") return catalog.i18nc("@label:status", "Idle")
} }
return "" return ""
} }
visible: text !== ""
} }
Item Item
@ -218,7 +220,7 @@ Item
{ {
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
width: 216 * screenScaleFactor // TODO: Theme! width: 180 * screenScaleFactor // TODO: Theme!
height: printerNameLabel.height + printerFamilyPill.height + 6 * screenScaleFactor // TODO: Theme! height: printerNameLabel.height + printerFamilyPill.height + 6 * screenScaleFactor // TODO: Theme!
visible: printer.activePrintJob visible: printer.activePrintJob
@ -247,7 +249,7 @@ Item
} }
color: printer.activePrintJob && printer.activePrintJob.isActive ? "#53657d" : "#babac1" // TODO: Theme! color: printer.activePrintJob && printer.activePrintJob.isActive ? "#53657d" : "#babac1" // TODO: Theme!
elide: Text.ElideRight elide: Text.ElideRight
font: UM.Theme.getFont("very_small") // 12pt, regular font: UM.Theme.getFont("default") // 12pt, regular
text: printer.activePrintJob ? printer.activePrintJob.owner : "Anonymous" // TODO: I18N text: printer.activePrintJob ? printer.activePrintJob.owner : "Anonymous" // TODO: I18N
width: parent.width width: parent.width
@ -264,8 +266,67 @@ Item
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
printJob: printer.activePrintJob printJob: printer.activePrintJob
visible: printer.activePrintJob visible: printer.activePrintJob && printer.activePrintJob.configurationChanges.length === 0
}
Label
{
anchors
{
verticalCenter: parent.verticalCenter
}
font: UM.Theme.getFont("default")
text: "Requires configuration changes"
visible: printer.activePrintJob && printer.activePrintJob.configurationChanges.length > 0
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
} }
} }
Button
{
id: detailsButton
anchors
{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 18 * screenScaleFactor // TODO: Theme!
}
background: Rectangle
{
color: "#d8d8d8" // TODO: Theme!
radius: 2 * screenScaleFactor // Todo: Theme!
Rectangle
{
anchors.fill: parent
anchors.bottomMargin: 2 * screenScaleFactor // TODO: Theme!
color: detailsButton.hovered ? "#e4e4e4" : "#f0f0f0" // TODO: Theme!
radius: 2 * screenScaleFactor // Todo: Theme!
}
}
contentItem: Label
{
anchors.fill: parent
anchors.bottomMargin: 2 * screenScaleFactor // TODO: Theme!
color: "#1e66d7" // TODO: Theme!
font: UM.Theme.getFont("medium") // 14pt, regular
text: "Details" // TODO: I18NC!
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
height: 18 * screenScaleFactor // TODO: Theme!
}
implicitHeight: 32 * screenScaleFactor // TODO: Theme!
implicitWidth: 96 * screenScaleFactor // TODO: Theme!
visible: printer.activePrintJob && printer.activePrintJob.configurationChanges.length > 0
onClicked: overrideConfirmationDialog.open()
}
}
MonitorConfigOverrideDialog
{
id: overrideConfirmationDialog
printer: base.printer
} }
} }

View file

@ -608,16 +608,6 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
def _createMaterialOutputModel(self, material_data: Dict[str, Any]) -> "MaterialOutputModel": def _createMaterialOutputModel(self, material_data: Dict[str, Any]) -> "MaterialOutputModel":
material_manager = CuraApplication.getInstance().getMaterialManager() material_manager = CuraApplication.getInstance().getMaterialManager()
material_group_list = material_manager.getMaterialGroupListByGUID(material_data["guid"]) material_group_list = material_manager.getMaterialGroupListByGUID(material_data["guid"])
# This can happen if the connected machine has no material in one or more extruders (if GUID is empty), or the
# material is unknown to Cura, so we should return an "empty" or "unknown" material model.
if material_group_list is None:
material_name = "Empty" if len(material_data["guid"]) == 0 else "Unknown"
return MaterialOutputModel(guid = material_data["guid"],
type = material_data.get("type", ""),
color = material_data.get("color", ""),
brand = material_data.get("brand", ""),
name = material_data.get("name", material_name)
)
# Sort the material groups by "is_read_only = True" first, and then the name alphabetically. # Sort the material groups by "is_read_only = True" first, and then the name alphabetically.
read_only_material_group_list = list(filter(lambda x: x.is_read_only, material_group_list)) read_only_material_group_list = list(filter(lambda x: x.is_read_only, material_group_list))