mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-30 01:55:55 +08:00
Store customized settings in variant instead of user profile
This commit is contained in:
parent
4e62d7d951
commit
09c95001ed
@ -2,9 +2,11 @@ from cura.MachineAction import MachineAction
|
||||
import cura.Settings.CuraContainerRegistry
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer
|
||||
from UM.Application import Application
|
||||
|
||||
import UM.Settings.InstanceContainer
|
||||
import UM.Settings.DefinitionContainer
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, QObject
|
||||
|
||||
|
||||
@ -17,15 +19,26 @@ class MachineSettingsAction(MachineAction, QObject):
|
||||
|
||||
cura.Settings.CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
||||
|
||||
def _execute(self):
|
||||
pass
|
||||
|
||||
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):
|
||||
# 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())
|
||||
|
||||
@pyqtSlot()
|
||||
|
@ -209,7 +209,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_width"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -219,7 +219,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_depth"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -229,7 +229,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_height"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -239,7 +239,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_nozzle_size"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -249,7 +249,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_heated_bed"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -259,7 +259,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_center_is_zero"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
|
||||
@ -270,7 +270,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_start_gcode"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -280,7 +280,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_end_gcode"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
storeIndex: 3
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user