Merge branch 'master' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2016-08-09 17:11:23 +02:00
commit 433db40e9c
7 changed files with 37 additions and 27 deletions

View File

@ -20,7 +20,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
NameRole = Qt.UserRole + 2 NameRole = Qt.UserRole + 2
## Colour of the material loaded in the extruder. ## Colour of the material loaded in the extruder.
ColourRole = Qt.UserRole + 3 ColorRole = Qt.UserRole + 3
## Index of the extruder, which is also the value of the setting itself. ## Index of the extruder, which is also the value of the setting itself.
# #
@ -31,7 +31,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
## List of colours to display if there is no material or the material has no known ## List of colours to display if there is no material or the material has no known
# colour. # colour.
defaultColours = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"] defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"]
## Initialises the extruders model, defining the roles and listening for ## Initialises the extruders model, defining the roles and listening for
# changes in the data. # changes in the data.
@ -42,7 +42,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
self.addRoleName(self.IdRole, "id") self.addRoleName(self.IdRole, "id")
self.addRoleName(self.NameRole, "name") self.addRoleName(self.NameRole, "name")
self.addRoleName(self.ColourRole, "colour") self.addRoleName(self.ColorRole, "color")
self.addRoleName(self.IndexRole, "index") self.addRoleName(self.IndexRole, "index")
self._add_global = False self._add_global = False
@ -104,11 +104,11 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
if global_container_stack: if global_container_stack:
if self._add_global: if self._add_global:
material = global_container_stack.findContainer({ "type": "material" }) material = global_container_stack.findContainer({ "type": "material" })
colour = material.getMetaDataEntry("color_code", default = self.defaultColours[0]) if material else self.defaultColours[0] color = material.getMetaDataEntry("color_code", default = self.defaultColors[0]) if material else self.defaultColors[0]
item = { item = {
"id": global_container_stack.getId(), "id": global_container_stack.getId(),
"name": "Global", "name": "Global",
"colour": colour, "color": color,
"index": -1 "index": -1
} }
self.appendItem(item) self.appendItem(item)
@ -125,12 +125,12 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
position = int(position) position = int(position)
except ValueError: #Not a proper int. except ValueError: #Not a proper int.
position = -1 position = -1
default_colour = self.defaultColours[position] if position >= 0 and position < len(self.defaultColours) else self.defaultColours[0] default_color = self.defaultColors[position] if position >= 0 and position < len(self.defaultColors) else self.defaultColors[0]
colour = material.getMetaDataEntry("color_code", default = default_colour) if material else default_colour color = material.getMetaDataEntry("color_code", default = default_color) if material else default_color
item = { #Construct an item with only the relevant information. item = { #Construct an item with only the relevant information.
"id": extruder.getId(), "id": extruder.getId(),
"name": extruder_name, "name": extruder_name,
"colour": colour, "color": color,
"index": position "index": position
} }
self.appendItem(item) self.appendItem(item)

View File

@ -47,9 +47,9 @@ Item {
id: extruders_model id: extruders_model
onRowsInserted: extruderSelector.visible = extruders_model.rowCount() > 1 onRowsInserted: extruderSelector.visible = extruders_model.rowCount() > 1
onModelReset: extruderSelector.visible = extruders_model.rowCount() > 1 onModelReset: extruderSelector.visible = extruders_model.rowCount() > 1
onModelChanged: extruderSelector.color = extruders_model.getItem(extruderSelector.currentIndex).colour onModelChanged: extruderSelector.color = extruders_model.getItem(extruderSelector.currentIndex).color
} }
property string color: extruders_model.getItem(extruderSelector.currentIndex).colour property string color: extruders_model.getItem(extruderSelector.currentIndex).color
visible: extruders_model.rowCount() > 1 visible: extruders_model.rowCount() > 1
textRole: "name" textRole: "name"
width: UM.Theme.getSize("setting_control").width width: UM.Theme.getSize("setting_control").width
@ -138,7 +138,7 @@ Item {
if(extruders_model.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder")) if(extruders_model.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder"))
{ {
extruderSelector.currentIndex = i; extruderSelector.currentIndex = i;
extruderSelector.color = extruders_model.getItem(i).colour; extruderSelector.color = extruders_model.getItem(i).color;
return; return;
} }
} }

View File

@ -61,7 +61,7 @@ class SolidView(View):
uniforms = {} uniforms = {}
if self._extruders_model.rowCount() == 0: if self._extruders_model.rowCount() == 0:
material = Application.getInstance().getGlobalContainerStack().findContainer({ "type": "material" }) material = Application.getInstance().getGlobalContainerStack().findContainer({ "type": "material" })
material_color = material.getMetaDataEntry("color_code", default = self._extruders_model.defaultColours[0]) if material else self._extruders_model.defaultColours[0] material_color = material.getMetaDataEntry("color_code", default = self._extruders_model.defaultColors[0]) if material else self._extruders_model.defaultColors[0]
else: else:
# Get color to render this mesh in from ExtrudersModel # Get color to render this mesh in from ExtrudersModel
extruder_index = 0 extruder_index = 0
@ -69,7 +69,7 @@ class SolidView(View):
if extruder_id: if extruder_id:
extruder_index = max(0, self._extruders_model.find("id", extruder_id)) extruder_index = max(0, self._extruders_model.find("id", extruder_id))
material_color = self._extruders_model.getItem(extruder_index)["colour"] material_color = self._extruders_model.getItem(extruder_index)["color"]
try: try:
# Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs
# an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0])

View File

@ -22,8 +22,9 @@ Rectangle
property bool showProgress: { property bool showProgress: {
// determine if we need to show the progress bar + percentage // determine if we need to show the progress bar + percentage
if(!printerConnected || !printerAcceptsCommands) if(!printerConnected || !printerAcceptsCommands) {
return false; return false;
}
switch(Cura.MachineManager.printerOutputDevices[0].jobState) switch(Cura.MachineManager.printerOutputDevices[0].jobState)
{ {
@ -36,7 +37,7 @@ Rectangle
case "offline": case "offline":
case "abort": // note sure if this jobState actually occurs in the wild case "abort": // note sure if this jobState actually occurs in the wild
case "error": // after clicking abort you apparently get "error" case "error": // after clicking abort you apparently get "error"
case "": // ready to print case "": // ready to print or getting ready
default: default:
return false; return false;
} }
@ -150,7 +151,7 @@ Rectangle
visible: printerConnected visible: printerConnected
enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands && enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
(Cura.MachineManager.printerOutputDevices[0].jobState == "paused" || Cura.MachineManager.printerOutputDevices[0].jobState == "printing") (["paused", "printing", "pre_print"].indexOf(Cura.MachineManager.printerOutputDevices[0].jobState) >= 0)
height: UM.Theme.getSize("save_button_save_to_button").height height: UM.Theme.getSize("save_button_save_to_button").height
anchors.top: progressBar.bottom anchors.top: progressBar.bottom
@ -225,33 +226,42 @@ Rectangle
anchors.right: abortButton.left anchors.right: abortButton.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.rightMargin: UM.Theme.getSize("default_margin").width
visible: printerConnected
enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
(Cura.MachineManager.printerOutputDevices[0].jobState == "paused" || Cura.MachineManager.printerOutputDevices[0].jobState == "printing")
property bool userClicked: false property bool userClicked: false
property string lastJobState: ""
visible: printerConnected
enabled: (!userClicked) && printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
(["paused", "printing"].indexOf(Cura.MachineManager.printerOutputDevices[0].jobState) >= 0)
text: { text: {
var result = ""; var result = "";
var jobState = Cura.MachineManager.printerOutputDevices[0].jobState;
if (!printerConnected) { if (!printerConnected) {
return ""; return "";
} }
if (Cura.MachineManager.printerOutputDevices[0].jobState == "paused") if (lastJobState !== jobState) {
// the userClicked message must disappear when an "automated" jobState comes by
userClicked = false;
lastJobState = jobState;
}
if (jobState == "paused")
{ {
if (userClicked) { if (userClicked) {
result = catalog.i18nc("@label:", "Resuming..."); // User feedback for pretending we're already in "printing" mode.
result = catalog.i18nc("@label:", "Pause");
} else { } else {
result = catalog.i18nc("@label:", "Resume"); result = catalog.i18nc("@label:", "Resume");
} }
} else { } else {
if (userClicked) { if (userClicked) {
result = catalog.i18nc("@label:", "Pausing..."); // User feedback for pretending we're already in "pause" mode.
result = catalog.i18nc("@label:", "Resume");
} else { } else {
result = catalog.i18nc("@label:", "Pause"); result = catalog.i18nc("@label:", "Pause");
} }
} }
userClicked = false;
return result; return result;
} }
onClicked: { onClicked: {

View File

@ -64,7 +64,7 @@ SettingItem
anchors.leftMargin: UM.Theme.getSize("default_lining").width anchors.leftMargin: UM.Theme.getSize("default_lining").width
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: extruders_model.getItem(control.currentIndex).colour color: extruders_model.getItem(control.currentIndex).color
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border") border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border")
} }

View File

@ -138,7 +138,7 @@ Column
anchors.leftMargin: (parent.height - height) / 2 anchors.leftMargin: (parent.height - height) / 2
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: model.colour color: model.color
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("toggle_checked") border.color: UM.Theme.getColor("toggle_checked")
} }

View File

@ -373,7 +373,7 @@ Item
for(var extruderNumber = 0; extruderNumber < extruders.model.rowCount() ; extruderNumber++) { for(var extruderNumber = 0; extruderNumber < extruders.model.rowCount() ; extruderNumber++) {
extruderModel.append({ extruderModel.append({
text: catalog.i18nc("@label", "Print using %1").arg(extruders.model.getItem(extruderNumber).name), text: catalog.i18nc("@label", "Print using %1").arg(extruders.model.getItem(extruderNumber).name),
color: extruders.model.getItem(extruderNumber).colour color: extruders.model.getItem(extruderNumber).color
}) })
} }
} }