from UM.Settings.Setting import Setting
class SettingsCategory(object):
    def __init__(self, key, catalog, parent, icon = None, order = 0):
        self._key = key
        self._i18n_catalog = catalog
        self._label = key
        self._parent = parent
        self._tooltip = ''
        self._icon = icon if icon else "category_unknown"
        self._order = order
        self._visible = True
        self._settings = []
        self._depth = 0 #Depth of category is 0 by definition (used for display purposes)
        
    ##  Set values of the setting by providing it with a dict object (as decoded by JSON parser)
    #   \param data Decoded JSON dict
    def fillByDict(self, data):
        if "label" in data:
            self._label = self._i18n_catalog.i18nc("{0} label".format(self._key), data["label"])
        if "visible" in data:
            self._visible = data["visible"]
        if "icon" in data:
            self._icon = data["icon"]
        if "settings" in data:
            for key, value in data["settings"].items():
                if "default" in value and "type" in value:
                    temp_setting = Setting(key, self._i18n_catalog, default = value["default"], type = value["type"])
                    temp_setting.setCategory(self)
                    temp_setting.setParent(self)
                    temp_setting.fillByDict(value)
                    self._settings.append(temp_setting)

    def isActive(self):
        return True
    
    def setLabel(self, label):
        self._label = label
    
    def getDepth(self):
        return self._depth
    
    def setVisible(self, visible):
        self._visible = visible

    def isVisible(self):
        return self._visible

    def addSetting(self, setting):
        self._settings.append(setting)

    def getSettingByKey(self, key):
        for s in self._settings:
            ret = s.getSettingByKey(key)
            if ret is not None:
                return ret
        return None # No setting was found

    def getLabel(self):
        return self._label

    def getKey(self):
        return self._key

    def getIcon(self):
        return self._icon

    def getParent(self):
        return self._parent

    def __cmp__(self, other):
        return self._order - other._order

    def getAllSettings(self):
        all_settings = []
        for s in self._settings:
            all_settings.append(s)
            all_settings.extend(s.getAllChildren())
        return all_settings

    def getChildren(self):
        return self._settings

    def __repr__(self):
        return '<SettingCategory: %s %d>' % (self._key, self._order)

@@ -33,16 +33,61 @@
 Setting%0A
+from UM.Signal import Signal, SignalEmitter%0A%0A
 class Se
@@ -101,22 +101,29 @@
 ategory(
-object
+SignalEmitter
 ):%0A    d
@@ -442,24 +442,63 @@
 ible = True%0A
+        self._children_visible = False%0A
         self
@@ -1458,16 +1458,103 @@
 (value)%0A
+                    temp_setting.visibleChanged.connect(self._onSettingVisibleChanged)%0A
         
@@ -1594,32 +1594,77 @@
 (temp_setting)%0A%0A
+        self._onSettingVisibleChanged(None)%0A%0A
     def isActive
@@ -1863,86 +1863,258 @@
     
-self._visible = visible%0A%0A    def isVisible(self):%0A        return self._visible
+if visible != self._visible:%0A            self._visible = visible%0A            self.visibleChanged.emit()%0A%0A    def isVisible(self):%0A        if self._visible:%0A            return self._children_visible%0A%0A        return False%0A%0A    visibleChanged = Signal()
 %0A%0A  
@@ -3028,12 +3028,309 @@
 elf._order)%0A
+%0A    def _onSettingVisibleChanged(self, setting):%0A        for setting in self.getAllSettings():%0A            if setting.isVisible():%0A                self._children_visible = True%0A                break%0A        else:%0A            self._children_visible = False%0A%0A        self.visibleChanged.emit(self)%0A

Add a visibleChanged signal to SettingsCategory and handle children's visibleChanged