@@ -109,40 +109,49 @@ namespace fw16led::ui
109
109
settings->setValue (QString (" panel_%1_preset" ).arg (panelId), presetKey);
110
110
settings->setValue (QString (" panel_%1_brightness" ).arg (panelId), brightnessSlider->value ());
111
111
112
- // Save dynamic settings
113
- for ( int i = 0 ; i < dynamicSettingsLayout-> count (); i++ )
112
+ // Recursive function to save dynamic settings
113
+ std::function< void (QLayout*)> saveSettings = [&](QLayout* layout )
114
114
{
115
- QLayoutItem* item = dynamicSettingsLayout->itemAt (i);
116
- if (item->widget () == nullptr )
117
- continue ;
118
-
119
- QWidget* widget = item->widget ();
120
- if (widget->property (" controlsSetting" ).isValid ())
115
+ for (int i = 0 ; i < layout->count (); i++)
121
116
{
122
- QString controlsSetting = widget->property (" controlsSetting" ).toString ();
123
- if (QCheckBox* checkbox = qobject_cast<QCheckBox*>(widget))
124
- {
125
- settings->setValue (controlsSetting, checkbox->isChecked ());
126
- }
127
- else if (QLineEdit* textEdit = qobject_cast<QLineEdit*>(widget))
117
+ QLayoutItem* item = layout->itemAt (i);
118
+ if (item->widget ())
128
119
{
129
- settings->setValue (controlsSetting, textEdit->text ());
130
- }
131
- else if (QComboBox* dropdown = qobject_cast<QComboBox*>(widget))
132
- {
133
- auto selectedKey = dropdown->currentData ().value <int >();
134
- settings->setValue (controlsSetting, selectedKey);
135
- }
136
- else if (QSpinBox* spinBox = qobject_cast<QSpinBox*>(widget))
137
- {
138
- settings->setValue (controlsSetting, spinBox->value ());
120
+ QWidget* widget = item->widget ();
121
+ if (widget->property (" controlsSetting" ).isValid ())
122
+ {
123
+ QString controlsSetting = widget->property (" controlsSetting" ).toString ();
124
+ if (QCheckBox* checkbox = qobject_cast<QCheckBox*>(widget))
125
+ {
126
+ settings->setValue (controlsSetting, checkbox->isChecked ());
127
+ }
128
+ else if (QLineEdit* textEdit = qobject_cast<QLineEdit*>(widget))
129
+ {
130
+ settings->setValue (controlsSetting, textEdit->text ());
131
+ }
132
+ else if (QComboBox* dropdown = qobject_cast<QComboBox*>(widget))
133
+ {
134
+ settings->setValue (controlsSetting, dropdown->currentData ().value <int >());
135
+ }
136
+ else if (QSpinBox* spinBox = qobject_cast<QSpinBox*>(widget))
137
+ {
138
+ settings->setValue (controlsSetting, spinBox->value ());
139
+ }
140
+ else if (QDoubleSpinBox* doubleSpinBox = qobject_cast<QDoubleSpinBox*>(widget))
141
+ {
142
+ settings->setValue (controlsSetting, doubleSpinBox->value ());
143
+ }
144
+ }
139
145
}
140
- else if (QDoubleSpinBox* doubleSpinBox = qobject_cast<QDoubleSpinBox*>(widget ))
146
+ else if (item-> layout ( ))
141
147
{
142
- settings-> setValue (controlsSetting, doubleSpinBox-> value ());
148
+ saveSettings (item-> layout ());
143
149
}
144
150
}
145
- }
151
+ };
152
+
153
+ // Save dynamic settings
154
+ saveSettings (dynamicSettingsLayout);
146
155
147
156
usb_manager->applyConfig (panelId);
148
157
}
0 commit comments