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

This commit is contained in:
Jaime van Kessel 2016-06-06 10:19:14 +02:00
commit ffd309f816
10 changed files with 54 additions and 41 deletions

5
.gitignore vendored
View file

@ -16,3 +16,8 @@ resources/firmware
*~
*.qm
.idea
.project
.pydevproject
# Debian packaging
debian/

View file

@ -271,7 +271,7 @@ class CuraApplication(QtApplication):
file_name = urllib.parse.quote_plus(stack.getId()) + ".stack.cfg"
stack_type = stack.getMetaDataEntry("type", None)
path = None
if stack_type == "machine":
if not stack_type or stack_type == "machine":
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
elif stack_type == "extruder":
path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name)

View file

@ -23,7 +23,7 @@ class CuraSplashScreen(QSplashScreen):
version = Application.getInstance().getVersion().split("-")
buildtype = Application.getInstance().getBuildType()
if buildtype:
version += " (%s)" %(buildtype)
version[0] += " (%s)" %(buildtype)
painter.setFont(QFont("Proxima Nova Rg", 20 ))
painter.drawText(0, 0, 330 * self._scale, 230 * self._scale, Qt.AlignHCenter | Qt.AlignBottom, version[0])

View file

@ -25,7 +25,7 @@ class Extruder:
self._nozzles += container_registry.findInstanceContainers(type = "nozzle", definitions = self._definition.getId())
#Create a container stack for this extruder.
self._name = self._uniqueName(self._definition.getId())
self._name = self._uniqueName(self._definition)
self._container_stack = UM.Settings.ContainerStack(self._name)
self._container_stack.addMetaDataEntry("type", "extruder_train")
self._container_stack.addContainer(self._definition)

View file

@ -27,6 +27,7 @@ class ExtruderManager:
self._next_item = 0 #For when you use this class as iterator.
UM.Application.getInstance().globalContainerStackChanged.connect(self._reconnectExtruderReload) #When the current machine changes, we need to reload all extruders belonging to the new machine.
self._reconnectExtruderReload()
## Gets an instance of this extruder manager.
#
@ -51,6 +52,7 @@ class ExtruderManager:
self._global_container_stack.containersChanged.disconnect(self._reloadExtruders) #Disconnect from the old global container stack.
self._global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
self._global_container_stack.containersChanged.connect(self._reloadExtruders) #When the current machine changes, we need to reload all extruders belonging to the new machine.
self._reloadExtruders()
## (Re)loads all extruders of the currently active machine.
#
@ -66,7 +68,7 @@ class ExtruderManager:
#Get the extruder definitions belonging to the current machine.
machine = self._global_container_stack.getBottom()
extruder_train_ids = machine.getMetaDataEntry("machine_extruder_trains")
for extruder_train_id in extruder_train_ids:
for _,extruder_train_id in extruder_train_ids.items():
extruder_definitions = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id = extruder_train_id) #Should be only 1 definition if IDs are unique, but add the whole list anyway.
if not extruder_definitions: #Empty list or error.
UM.Logger.log("w", "Machine definition %s refers to an extruder train \"%s\", but no such extruder was found.", machine.getId(), extruder_train_id)

View file

@ -179,8 +179,8 @@ class MachineManagerModel(QObject):
i = 1
# Check both the id and the name, because they may not be the same and it is better if they are both unique
while UM.Settings.ContainerRegistry.getInstance().findContainers(None, id = unique_name) or \
UM.Settings.ContainerRegistry.getInstance().findContainers(None, name = unique_name):
while UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = unique_name, type = "machine") or \
UM.Settings.ContainerRegistry.getInstance().findContainerStacks(name = unique_name, type = "machine"):
i += 1
unique_name = "%s #%d" % (name, i)
@ -405,11 +405,13 @@ class MachineManagerModel(QObject):
@pyqtSlot(str)
def removeMachine(self, machine_id):
# If the machine that is being removed is the currently active machine, set another machine as the active machine
if self._global_container_stack and self._global_container_stack.getId() == machine_id:
containers = UM.Settings.ContainerRegistry.getInstance().findContainerStacks()
if containers:
Application.getInstance().setGlobalContainerStack(containers[0])
activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id)
UM.Settings.ContainerRegistry.getInstance().removeContainer(machine_id)
if activate_new_machine:
stacks = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(type = "machine")
if stacks:
Application.getInstance().setGlobalContainerStack(stacks[0])
@pyqtProperty(bool, notify = globalContainerChanged)
def hasMaterials(self):

View file

@ -51,6 +51,8 @@ class PrintInformation(QObject):
self._backend.printDurationMessage.connect(self._onPrintDurationMessage)
self._job_name = ""
self._abbr_machine = ""
Application.getInstance().globalContainerStackChanged.connect(self._setAbbreviatedMachineName)
Application.getInstance().fileLoaded.connect(self.setJobName)

View file

@ -56,7 +56,7 @@ Item {
//Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989
//In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes,
//causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely.
asynchronous: model.type != "enum"
asynchronous: model.type != "enum" && model.type != "extruder"
onLoaded: {
settingLoader.item.showRevertButton = false

View file

@ -16,17 +16,18 @@ SettingItem
{
id: control
model: Cura.ExtrudersModel {
model: Cura.ExtrudersModel
{
id: extruders_model
}
textRole: "name";
textRole: "name"
anchors.fill: parent
MouseArea
{
anchors.fill: parent;
acceptedButtons: Qt.NoButton;
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: wheel.accepted = true;
}
@ -38,44 +39,44 @@ SettingItem
{
if (!enabled)
{
return UM.Theme.getColor("setting_control_disabled")
return UM.Theme.getColor("setting_control_disabled");
}
if(control.hovered || base.activeFocus)
{
return UM.Theme.getColor("setting_control_highlight")
return UM.Theme.getColor("setting_control_highlight");
}
else
{
return UM.Theme.getColor("setting_control")
return extruders_model.getItem(index).colour;
}
}
border.width: UM.Theme.getSize("default_lining").width;
border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border");
border.width: UM.Theme.getSize("default_lining").width
border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
}
label: Item
{
Label
{
anchors.left: parent.left;
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_lining").width
anchors.right: downArrow.left;
anchors.rightMargin: UM.Theme.getSize("default_lining").width;
anchors.verticalCenter: parent.verticalCenter;
anchors.right: downArrow.left
anchors.rightMargin: UM.Theme.getSize("default_lining").width
anchors.verticalCenter: parent.verticalCenter
text: control.currentText;
font: UM.Theme.getFont("default");
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text");
text: control.currentText
font: UM.Theme.getFont("default")
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : extruders_model.getItem(index).colour
elide: Text.ElideRight;
verticalAlignment: Text.AlignVCenter;
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
UM.RecolorImage
{
id: downArrow
anchors.right: parent.right;
anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2;
anchors.verticalCenter: parent.verticalCenter;
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
anchors.verticalCenter: parent.verticalCenter
source: UM.Theme.getIcon("arrow_bottom")
width: UM.Theme.getSize("standard_arrow").width
@ -83,29 +84,30 @@ SettingItem
sourceSize.width: width + 5
sourceSize.height: width + 5
color: UM.Theme.getColor("setting_control_text");
color: UM.Theme.getColor("setting_control_text")
}
}
}
onActivated: provider.setPropertyValue("value", extruders_model.getItem(index).index)
onActivated: provider.setPropertyValue("value", extruders_model.getItem(index).index);
onModelChanged: updateCurrentIndex();
Connections
{
target: provider
onPropertiesChanged: control.updateCurrentIndex()
onPropertiesChanged: control.updateCurrentIndex();
}
function updateCurrentIndex() {
for(var i = 0; i < extruders_model.rowCount(); ++i) {
if(extruders_model.getItem(i).index == provider.properties.value) {
function updateCurrentIndex()
{
for(var i = 0; i < extruders_model.rowCount(); ++i)
{
if(extruders_model.getItem(i).index == provider.properties.value)
{
currentIndex = i;
return;
}
}
currentIndex = -1;
}
}

View file

@ -49,7 +49,7 @@ ScrollView
//Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989
//In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes,
//causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely.
asynchronous: model.type != "enum"
asynchronous: model.type != "enum" && model.type != "extruder"
active: model.type != undefined
source: