Make settings visible too after adding them

Contributes to issue CURA-7211.
This commit is contained in:
Ghostkeeper 2020-02-13 13:08:32 +01:00
parent 53e1742d27
commit 3b235d5536
No known key found for this signature in database
GPG key ID: 37E2020986774393
2 changed files with 11 additions and 5 deletions

View file

@ -1,10 +1,11 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import pyqtProperty from PyQt5.QtCore import pyqtProperty
from UM.FlameProfiler import pyqtSlot from UM.FlameProfiler import pyqtSlot
from UM.Application import Application from UM.Application import Application
from UM.PluginRegistry import PluginRegistry
from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.SettingInstance import SettingInstance from UM.Settings.SettingInstance import SettingInstance
from UM.Logger import Logger from UM.Logger import Logger
@ -24,6 +25,8 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand
self._node = None self._node = None
self._stack = None self._stack = None
PluginRegistry.getInstance().getPluginObject("PerObjectSettingsTool").visibility_handler = self
# this is a set of settings that will be skipped if the user chooses to reset. # this is a set of settings that will be skipped if the user chooses to reset.
self._skip_reset_setting_set = set() self._skip_reset_setting_set = set()

View file

@ -1,5 +1,6 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2020 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from UM.Logger import Logger from UM.Logger import Logger
from UM.Tool import Tool from UM.Tool import Tool
from UM.Scene.Selection import Selection from UM.Scene.Selection import Selection
@ -22,14 +23,13 @@ class PerObjectSettingsTool(Tool):
self._multi_extrusion = False self._multi_extrusion = False
self._single_model_selected = False self._single_model_selected = False
self.visibility_handler = None
Selection.selectionChanged.connect(self.propertyChanged) Selection.selectionChanged.connect(self.propertyChanged)
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged) Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
self._onGlobalContainerChanged() self._onGlobalContainerChanged()
Selection.selectionChanged.connect(self._updateEnabled) Selection.selectionChanged.connect(self._updateEnabled)
def event(self, event): def event(self, event):
super().event(event) super().event(event)
if event.type == Event.MousePressEvent and self._controller.getToolsEnabled(): if event.type == Event.MousePressEvent and self._controller.getToolsEnabled():
@ -103,6 +103,9 @@ class PerObjectSettingsTool(Tool):
new_instance.setProperty("value", 0) new_instance.setProperty("value", 0)
new_instance.resetState() # Ensure that the state is not seen as a user state. new_instance.resetState() # Ensure that the state is not seen as a user state.
settings.addInstance(new_instance) settings.addInstance(new_instance)
visible = self.visibility_handler.getVisible()
visible.add(property_key)
self.visibility_handler.setVisible(visible)
elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and settings.getProperty(property_key, "value") == 0: elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and settings.getProperty(property_key, "value") == 0:
settings.removeInstance(property_key) settings.removeInstance(property_key)