fix(color): settings for 'Outputs' widget incorrect with older models (#7107)

This commit is contained in:
philmoz
2026-02-19 07:28:00 +10:00
committed by GitHub
parent e5d2dc5ed4
commit 80e26da188
3 changed files with 39 additions and 1 deletions
@@ -377,6 +377,7 @@ Widget* WidgetFactory::create(Window* parent, const rect_t& rect,
parseOptionDefaults();
}
if (options) {
checkOptions(screenNum, zoneNum);
int i = 0;
for (const WidgetOption* option = options; option->name; option++, i++) {
TRACE("WidgetFactory::create() setting option '%s'", option->name);
+1
View File
@@ -156,6 +156,7 @@ class WidgetFactory
const WidgetOption* getDefaultOptions() const { return options; }
virtual const void parseOptionDefaults() const {}
virtual const void checkOptions(int screenNum, int zoneNum) const {}
const char* getDisplayName() const
{
+37 -1
View File
@@ -261,6 +261,42 @@ const WidgetOption OutputsWidget::options[] = {
{STR_COLOR, WidgetOption::Color, COLOR2FLAGS(COLOR_THEME_SECONDARY1_INDEX)},
{nullptr, WidgetOption::Bool}};
BaseWidgetFactory<OutputsWidget> outputsWidget("Outputs",
// Note: Must be a template class otherwise the linker will discard the 'outputsWidget' object
template <class T>
class OutputsWidgetFactory : public WidgetFactory
{
public:
OutputsWidgetFactory(const char* name, const WidgetOption* options,
const char* displayName = nullptr) :
WidgetFactory(name, options, displayName)
{
}
Widget* createNew(Window* parent, const rect_t& rect,
int screenNum, int zoneNum) const override
{
return new T(this, parent, rect, screenNum, zoneNum);
}
// Fix the options loaded from the model file to account for
// addition of the 'last channel' option
const void checkOptions(int screenNum, int zoneNum) const override
{
auto widgetData = g_model.getWidgetData(screenNum, zoneNum);
if (widgetData && widgetData->options.size() >= 4) {
if (widgetData->options[1].type == WOV_Bool) {
widgetData->options[5] = widgetData->options[4];
widgetData->options[4] = widgetData->options[3];
widgetData->options[3] = widgetData->options[2];
widgetData->options[2] = widgetData->options[1];
widgetData->options[1].type = WOV_Signed;
widgetData->options[1].value.signedValue = MAX_OUTPUT_CHANNELS;
storageDirty(EE_MODEL);
}
}
}
};
OutputsWidgetFactory<OutputsWidget> outputsWidget("Outputs",
OutputsWidget::options,
STR_WIDGET_OUTPUTS);