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

This commit is contained in:
Jaime van Kessel 2016-06-09 19:17:57 +02:00
commit ceef6a003e
7 changed files with 22 additions and 34 deletions

View File

@ -274,38 +274,18 @@ class MachineManagerModel(QObject):
return containers[0].isReadOnly() return containers[0].isReadOnly()
@pyqtSlot(result = str) @pyqtSlot(result = str)
def convertUserContainerToQuality(self): def newQualityContainerFromQualityAndUser(self):
if not self._global_container_stack: new_container_id = self.duplicateContainer(self.activeQualityId)
if new_container_id == "":
return return
self.setActiveQuality(new_container_id)
self.updateQualityContainerFromUserContainer()
new_quality_container = InstanceContainer("")
name = self._createUniqueName("quality", "", self.activeQualityName, catalog.i18nc("@label", "Custom profile"))
user_settings = self._global_container_stack.getTop()
## Copy all values
new_quality_container.deserialize(user_settings.serialize())
## If the currently active machine does not have quality profiles of its own,
# make the new quality profile available for all machines that don't have
# unique quality profiles (including the current machine)
if not self.filterQualityByMachine:
new_quality_container.setDefinition(UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id = "fdmprinter")[0])
## Change type / id / name
new_quality_container.setMetaDataEntry("type", "quality")
new_quality_container.setReadOnly(False)
new_quality_container.setName(name)
new_quality_container._id = name
UM.Settings.ContainerRegistry.getInstance().addContainer(new_quality_container)
self.clearUserSettings() # As all users settings are now transfered to the new quality profile, remove them.
self.setActiveQuality(name)
return name
@pyqtSlot(str, result=str) @pyqtSlot(str, result=str)
def duplicateContainer(self, container_id): def duplicateContainer(self, container_id):
if not self._global_container_stack: if not self._global_container_stack:
return return ""
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id=container_id) containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id=container_id)
if containers: if containers:
new_name = self._createUniqueName("quality", "", containers[0].getName(), catalog.i18nc("@label", "Custom profile")) new_name = self._createUniqueName("quality", "", containers[0].getName(), catalog.i18nc("@label", "Custom profile"))
@ -364,7 +344,7 @@ class MachineManagerModel(QObject):
@pyqtSlot() @pyqtSlot()
def updateUserContainerToQuality(self): def updateQualityContainerFromUserContainer(self):
if not self._global_container_stack: if not self._global_container_stack:
return return
user_settings = self._global_container_stack.getTop() user_settings = self._global_container_stack.getTop()

View File

@ -8,6 +8,7 @@ from UM.Signal import Signal, signalemitter
from UM.Settings.ContainerStack import ContainerStack from UM.Settings.ContainerStack import ContainerStack
from UM.Settings.InstanceContainer import InstanceContainer from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.ContainerRegistry import ContainerRegistry
import UM.Logger
from UM.Application import Application from UM.Application import Application
@ -58,7 +59,11 @@ class SettingOverrideDecorator(SceneNodeDecorator):
# kept up to date. # kept up to date.
def _updateNextStack(self): def _updateNextStack(self):
if self._extruder_stack: if self._extruder_stack:
self._stack.setNextStack(ContainerRegistry.getInstance().findContainerStack(id = self._extruder_stack)) extruder_stack = ContainerRegistry.getInstance().findContainerStacks(id = self._extruder_stack)
if extruder_stack:
self._stack.setNextStack(extruder_stack)
else:
UM.Logger.log("e", "Extruder stack %s below per-object settings does not exist.", self._extruder_stack)
else: else:
self._stack.setNextStack(Application.getInstance().getGlobalContainerStack()) self._stack.setNextStack(Application.getInstance().getGlobalContainerStack())

View File

@ -101,7 +101,7 @@ Item {
} }
} }
onActivated: UM.ActiveTool.properties.setValue("SelectedActiveExtruder", extruders_model.getItem(index).id); onActivated: UM.ActiveTool.setProperty("SelectedActiveExtruder", extruders_model.getItem(index).id);
onModelChanged: updateCurrentIndex(); onModelChanged: updateCurrentIndex();
function updateCurrentIndex() function updateCurrentIndex()

View File

@ -5,7 +5,7 @@ from UM.Tool import Tool
from UM.Scene.Selection import Selection from UM.Scene.Selection import Selection
from UM.Application import Application from UM.Application import Application
from UM.Preferences import Preferences from UM.Preferences import Preferences
from cura.SettingOverrideDecorator import SettingOverrideDecorator
## This tool allows the user to add & change settings per node in the scene. ## This tool allows the user to add & change settings per node in the scene.
# The settings per object are kept in a ContainerStack, which is linked to a node by decorator. # The settings per object are kept in a ContainerStack, which is linked to a node by decorator.
@ -55,6 +55,9 @@ class PerObjectSettingsTool(Tool):
# selected object with. # selected object with.
def setSelectedActiveExtruder(self, extruder_stack_id): def setSelectedActiveExtruder(self, extruder_stack_id):
selected_object = Selection.getSelectedObject(0) selected_object = Selection.getSelectedObject(0)
stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway.
if not stack:
selected_object.addDecorator(SettingOverrideDecorator())
selected_object.callDecoration("setActiveExtruder", extruder_stack_id) selected_object.callDecoration("setActiveExtruder", extruder_stack_id)
def _onPreferenceChanged(self, preference): def _onPreferenceChanged(self, preference):

View File

@ -112,7 +112,7 @@ Item
id: updateProfileAction; id: updateProfileAction;
enabled: Cura.MachineManager.isGlobalStackValid && Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId) enabled: Cura.MachineManager.isGlobalStackValid && Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId)
text: catalog.i18nc("@action:inmenu menubar:profile","&Update Current Profile"); text: catalog.i18nc("@action:inmenu menubar:profile","&Update Current Profile");
onTriggered: Cura.MachineManager.updateUserContainerToQuality() onTriggered: Cura.MachineManager.updateQualityContainerFromUserContainer()
} }
Action Action

View File

@ -582,7 +582,7 @@ UM.MainWindow
target: Cura.Actions.addProfile target: Cura.Actions.addProfile
onTriggered: onTriggered:
{ {
Cura.MachineManager.convertUserContainerToQuality(); Cura.MachineManager.newQualityContainerFromQualityAndUser();
preferences.setPage(5); preferences.setPage(5);
preferences.show(); preferences.show();

View File

@ -65,7 +65,7 @@ UM.ManagementPage
onAddObject: { onAddObject: {
var selectedContainer; var selectedContainer;
if (objectList.currentItem.id == Cura.MachineManager.activeQualityId) { if (objectList.currentItem.id == Cura.MachineManager.activeQualityId) {
selectedContainer = Cura.MachineManager.convertUserContainerToQuality(); selectedContainer = Cura.MachineManager.newQualityContainerFromQualityAndUser();
} else { } else {
selectedContainer = Cura.MachineManager.duplicateContainer(base.currentItem.id); selectedContainer = Cura.MachineManager.duplicateContainer(base.currentItem.id);
} }
@ -121,7 +121,7 @@ UM.ManagementPage
return catalog.i18nc("@action:button", "Update \"%1\"".arg(profileName)); return catalog.i18nc("@action:button", "Update \"%1\"".arg(profileName));
} }
enabled: Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId) enabled: Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId)
onClicked: Cura.MachineManager.updateUserContainerToQuality() onClicked: Cura.MachineManager.updateQualityContainerFromUserContainer()
} }
Button Button