implement the new preferences in the backend
This commit is contained in:
@@ -417,10 +417,20 @@ class ParamSection(QWidget):
|
||||
widget.textChanged.connect(lambda val, p=param["name"]: self.check_if_changed(p, val))
|
||||
|
||||
if "depends_on" in param:
|
||||
deps_list = []
|
||||
|
||||
if isinstance(param["depends_on"], list):
|
||||
deps_list = param["depends_on"]
|
||||
|
||||
else:
|
||||
deps_list.append({
|
||||
"parent_name": param["depends_on"],
|
||||
"depends_value": param.get("depends_value", "True")
|
||||
})
|
||||
|
||||
self.dependencies.append({
|
||||
"child_name": param["name"],
|
||||
"parent_name": param["depends_on"],
|
||||
"depends_value": param.get("depends_value", "True")
|
||||
"conditions": deps_list
|
||||
})
|
||||
|
||||
widget.setToolTip(help_text)
|
||||
@@ -532,23 +542,44 @@ class ParamSection(QWidget):
|
||||
"""Disables/Enables widgets based on parent selection values."""
|
||||
for dep in self.dependencies:
|
||||
child_info = self.widgets.get(dep["child_name"])
|
||||
parent_info = self.widgets.get(dep["parent_name"])
|
||||
if not child_info:
|
||||
continue
|
||||
|
||||
# Default to enabled until a condition fails
|
||||
all_conditions_met = True
|
||||
|
||||
for cond in dep["conditions"]:
|
||||
parent_name = cond.get("parent_name") or cond.get("parent")
|
||||
required_value = str(cond.get("depends_value") if "depends_value" in cond else cond.get("value", "True"))
|
||||
|
||||
parent_info = self.widgets.get(parent_name)
|
||||
if not parent_info:
|
||||
all_conditions_met = False
|
||||
break
|
||||
|
||||
if child_info and parent_info:
|
||||
parent_widget = parent_info["widget"]
|
||||
|
||||
# Extract current parent value based on widget type
|
||||
if isinstance(parent_widget, QComboBox):
|
||||
current_parent_value = parent_widget.currentText()
|
||||
elif isinstance(parent_widget, QLineEdit):
|
||||
current_parent_value = parent_widget.text()
|
||||
elif isinstance(parent_widget, QSpinBox):
|
||||
current_parent_value = str(parent_widget.value())
|
||||
else:
|
||||
current_parent_value = str(parent_widget)
|
||||
|
||||
# If any condition fails, flag as false
|
||||
if current_parent_value != required_value:
|
||||
all_conditions_met = False
|
||||
break
|
||||
|
||||
# Get current value of parent (works for both bool-combos and list-combos)
|
||||
current_parent_value = parent_widget.currentText()
|
||||
|
||||
# Check if it matches the required value
|
||||
is_active = (current_parent_value == dep["depends_value"])
|
||||
|
||||
# Toggle the entire row (Button, Label, and Input)
|
||||
h_layout = child_info["h_layout"]
|
||||
for i in range(h_layout.count()):
|
||||
item = h_layout.itemAt(i).widget()
|
||||
if item:
|
||||
item.setEnabled(is_active)
|
||||
# Toggle the entire row (Button, Label, and Input)
|
||||
h_layout = child_info["h_layout"]
|
||||
for i in range(h_layout.count()):
|
||||
item = h_layout.itemAt(i).widget()
|
||||
if item:
|
||||
item.setEnabled(all_conditions_met)
|
||||
|
||||
def _create_multiselect_dropdown(self, items):
|
||||
combo = FullClickComboBox()
|
||||
|
||||
Reference in New Issue
Block a user