feat: Add "Enable" button to all SF/GF (#3024) (#3601)

Co-authored-by: eshifri <eshifri@hotmail.com>
Co-authored-by: philmoz <philmoz@users.noreply.github.com>
This commit is contained in:
Peter Feerick
2023-12-03 12:23:34 +10:00
committed by GitHub
co-authored by eshifri philmoz
parent 878a365e72
commit ee73fa47f0
33 changed files with 262 additions and 194 deletions
+16 -19
View File
@@ -112,7 +112,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
playIcon.addImage("stop.png", QIcon::Normal, QIcon::On);
QStringList headerLabels;
headerLabels << "#" << tr("Switch") << tr("Action") << tr("Parameters") << "";
headerLabels << "#" << tr("Switch") << tr("Action") << tr("Parameters") << tr("Repeat") << tr("Enable");
TableLayout * tableLayout = new TableLayout(this, fswCapability, headerLabels);
for (int i = 0; i < fswCapability; i++) {
@@ -215,11 +215,12 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
repeatLayout->addWidget(fswtchRepeat[i], i + 1);
connect(fswtchRepeat[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
QHBoxLayout *enableLayout = new QHBoxLayout();
tableLayout->addLayout(i, 5, enableLayout);
fswtchEnable[i] = new QCheckBox(this);
fswtchEnable[i]->setProperty("index", i);
fswtchEnable[i]->setText(tr("ON"));
fswtchEnable[i]->setFixedWidth(200);
repeatLayout->addWidget(fswtchEnable[i], i + 1);
enableLayout->addWidget(fswtchEnable[i], i + 1);
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
}
@@ -351,6 +352,7 @@ void CustomFunctionsPanel::functionEdited()
functions[index].clear();
functions[index].swtch = swtch;
functions[index].func = (AssignFunc)fswtchFunc[index]->currentData().toInt();
functions[index].enabled = true;
if (functions[index].func == FuncPlayScript || functions[index].func == FuncRGBLed)
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatLuaId));
else
@@ -375,10 +377,11 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
else {
fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(cfn.swtch.toValue()));
fswtchFunc[i]->setCurrentIndex(fswtchFunc[i]->findData(cfn.func));
fswtchEnable[i]->setChecked(cfn.enabled);
}
if (!cfn.isEmpty()) {
widgetsMask |= CUSTOM_FUNCTION_SHOW_FUNC;
widgetsMask |= CUSTOM_FUNCTION_SHOW_FUNC | CUSTOM_FUNCTION_ENABLE;
if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32) {
if (model) {
@@ -391,7 +394,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
cfn.param = fswtchParam[i]->value();
}
fswtchParam[i]->setValue(cfn.param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM | CUSTOM_FUNCTION_ENABLE;
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
}
}
else if (func == FuncLogs) {
@@ -409,7 +412,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
if (modified)
cfn.adjustMode = fswtchGVmode[i]->currentData().toInt();
fswtchGVmode[i]->setCurrentIndex(fswtchGVmode[i]->findData(cfn.adjustMode));
widgetsMask |= CUSTOM_FUNCTION_GV_MODE | CUSTOM_FUNCTION_ENABLE;
widgetsMask |= CUSTOM_FUNCTION_GV_MODE;
if (cfn.adjustMode == FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode == FUNC_ADJUST_GVAR_INCDEC) {
if (modified)
cfn.param = fswtchParam[i]->value() * model->gvarData[gvidx].multiplierSet();
@@ -440,7 +443,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
if (modified)
cfn.param = fswtchParamT[i]->currentData().toInt();
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE;
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
else if (func >= FuncSetTimer1 && func <= FuncSetTimer3) {
if (modified)
@@ -448,16 +451,13 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
RawSourceRange range = RawSource(SOURCE_TYPE_SPECIAL, func - FuncSetTimer1 + 2).getRange(model, generalSettings);
fswtchParamTime[i]->setTimeRange((int)range.min, (int)range.max);
fswtchParamTime[i]->setTime(cfn.param);
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM | CUSTOM_FUNCTION_ENABLE;
}
else if (func >= FuncSetFailsafe && func <= FuncBindExternalModule) {
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM;
}
else if (func == FuncVolume || func == FuncBacklight) {
if (modified)
cfn.param = fswtchParamT[i]->currentData().toInt();
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE;
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
else if (func == FuncPlaySound || func == FuncPlayHaptic || func == FuncPlayValue || func == FuncPlayPrompt || func == FuncPlayBoth || func == FuncBackgroundMusic || func == FuncSetScreen) {
if (func != FuncBackgroundMusic) {
@@ -568,11 +568,12 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setValue(cfn.param);
if (func <= FuncInstantTrim) {
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
}
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
}
}
else {
cfn.enabled = true;
}
fswtchFunc[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SHOW_FUNC);
fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM);
@@ -581,10 +582,6 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM);
fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM);
fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE);
if (widgetsMask & CUSTOM_FUNCTION_ENABLE)
fswtchEnable[i]->setChecked(cfn.enabled);
else
fswtchEnable[i]->setChecked(false);
fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT);
fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE);
playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY);