mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Per object settings can now be added & changed
CURA-1278
This commit is contained in:
parent
d5dbd0f77b
commit
89c1136d7f
5 changed files with 85 additions and 30 deletions
|
@ -13,23 +13,16 @@ class PerObjectSettingsTool(Tool):
|
|||
super().__init__()
|
||||
self._model = None
|
||||
|
||||
self.setExposedProperties("Model", "SelectedIndex")
|
||||
self.setExposedProperties("SelectedObjectId","ContainerID")
|
||||
|
||||
Preferences.getInstance().preferenceChanged.connect(self._onPreferenceChanged)
|
||||
Selection.selectionChanged.connect(self.propertyChanged)
|
||||
self._onPreferenceChanged("cura/active_mode")
|
||||
|
||||
def event(self, event):
|
||||
return False
|
||||
|
||||
def getModel(self):
|
||||
if not self._model:
|
||||
self._model = PerObjectSettingsModel.PerObjectSettingsModel()
|
||||
|
||||
#For some reason, casting this model to itself causes the model to properly be cast to a QVariant, even though it ultimately inherits from QVariant.
|
||||
#Yeah, we have no idea either...
|
||||
return PerObjectSettingsModel.PerObjectSettingsModel(self._model)
|
||||
|
||||
def getSelectedIndex(self):
|
||||
def getSelectedObjectId(self):
|
||||
try:
|
||||
selected_object = Selection.getSelectedObject(0)
|
||||
if selected_object.getParent().callDecoration("isGroup"):
|
||||
|
@ -37,8 +30,24 @@ class PerObjectSettingsTool(Tool):
|
|||
except:
|
||||
selected_object = None
|
||||
selected_object_id = id(selected_object)
|
||||
index = self.getModel().find("id", selected_object_id)
|
||||
return index
|
||||
return selected_object_id
|
||||
|
||||
def getContainerID(self):
|
||||
try:
|
||||
selected_object = Selection.getSelectedObject(0)
|
||||
if selected_object.getParent().callDecoration("isGroup"):
|
||||
selected_object = selected_object.getParent()
|
||||
try:
|
||||
return selected_object.callDecoration("getStack").getId()
|
||||
except:
|
||||
print(":(")
|
||||
return
|
||||
except:
|
||||
print(":((")
|
||||
return
|
||||
|
||||
def setContainerID(self, value):
|
||||
pass
|
||||
|
||||
def _onPreferenceChanged(self, preference):
|
||||
if preference == "cura/active_mode":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue