Store customized settings in variant instead of user profile

This commit is contained in:
fieldOfView 2016-07-13 22:45:58 +02:00
parent 4e62d7d951
commit 09c95001ed
2 changed files with 27 additions and 14 deletions

View File

@ -2,9 +2,11 @@ from cura.MachineAction import MachineAction
import cura.Settings.CuraContainerRegistry import cura.Settings.CuraContainerRegistry
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
from UM.Settings.DefinitionContainer import DefinitionContainer
from UM.Application import Application from UM.Application import Application
import UM.Settings.InstanceContainer
import UM.Settings.DefinitionContainer
from PyQt5.QtCore import pyqtSlot, QObject from PyQt5.QtCore import pyqtSlot, QObject
@ -17,15 +19,26 @@ class MachineSettingsAction(MachineAction, QObject):
cura.Settings.CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded) cura.Settings.CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
def _execute(self):
pass
def _reset(self): def _reset(self):
pass global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack:
variant = global_container_stack.findContainer({"type": "variant"})
if variant and variant.getId() == "empty_variant":
variant_index = global_container_stack.getContainerIndex(variant)
self._createVariant(global_container_stack, variant_index)
def _createVariant(self, global_container_stack, variant_index):
new_variant = UM.Settings.InstanceContainer(global_container_stack.getName() + "_machinesettings")
new_variant.addMetaDataEntry("type", "variant")
new_variant.addMetaDataEntry("purpose", "machinesettings")
new_variant.setDefinition(global_container_stack.getBottom())
UM.Settings.ContainerRegistry.getInstance().addContainer(new_variant)
global_container_stack.replaceContainer(variant_index, new_variant)
def _onContainerAdded(self, container): def _onContainerAdded(self, container):
# Add this action as a supported action to all machine definitions # Add this action as a supported action to all machine definitions
if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine": if isinstance(container, UM.Settings.DefinitionContainer) and container.getMetaDataEntry("type") == "machine":
Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey()) Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
@pyqtSlot() @pyqtSlot()

View File

@ -209,7 +209,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_width" key: "machine_width"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
UM.SettingPropertyProvider UM.SettingPropertyProvider
@ -219,7 +219,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_depth" key: "machine_depth"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
UM.SettingPropertyProvider UM.SettingPropertyProvider
@ -229,7 +229,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_height" key: "machine_height"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
UM.SettingPropertyProvider UM.SettingPropertyProvider
@ -239,7 +239,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_nozzle_size" key: "machine_nozzle_size"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
UM.SettingPropertyProvider UM.SettingPropertyProvider
@ -249,7 +249,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_heated_bed" key: "machine_heated_bed"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
UM.SettingPropertyProvider UM.SettingPropertyProvider
@ -259,7 +259,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_center_is_zero" key: "machine_center_is_zero"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
@ -270,7 +270,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_start_gcode" key: "machine_start_gcode"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
UM.SettingPropertyProvider UM.SettingPropertyProvider
@ -280,7 +280,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_end_gcode" key: "machine_end_gcode"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 3
} }
} }