fix(cpn): special function adjust global variable ensure value within configured range (#7006)
This commit is contained in:
@@ -386,7 +386,7 @@ QString CustomFunctionData::gvarAdjustModeToString(const int value)
|
|||||||
{
|
{
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case FUNC_ADJUST_GVAR_CONSTANT:
|
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||||
return tr("Value");
|
return tr("Constant");
|
||||||
case FUNC_ADJUST_GVAR_SOURCE:
|
case FUNC_ADJUST_GVAR_SOURCE:
|
||||||
return tr("Source (%)");
|
return tr("Source (%)");
|
||||||
case FUNC_ADJUST_GVAR_SOURCERAW:
|
case FUNC_ADJUST_GVAR_SOURCERAW:
|
||||||
|
|||||||
@@ -371,13 +371,13 @@ void CustomFunctionsPanel::functionEdited()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
void CustomFunctionsPanel::refreshCustomFunction(int i, bool changed)
|
||||||
{
|
{
|
||||||
CustomFunctionData & cfn = functions[i];
|
CustomFunctionData & cfn = functions[i];
|
||||||
AssignFunc func = (AssignFunc)fswtchFunc[i]->currentData().toInt();
|
AssignFunc func = (AssignFunc)fswtchFunc[i]->currentData().toInt();
|
||||||
|
|
||||||
unsigned int widgetsMask = 0;
|
unsigned int widgetsMask = 0;
|
||||||
if (modified) {
|
if (changed) {
|
||||||
cfn.swtch = RawSwitch(fswtchSwtch[i]->currentData().toInt());
|
cfn.swtch = RawSwitch(fswtchSwtch[i]->currentData().toInt());
|
||||||
cfn.func = func;
|
cfn.func = func;
|
||||||
cfn.enabled = fswtchEnable[i]->isChecked();
|
cfn.enabled = fswtchEnable[i]->isChecked();
|
||||||
@@ -398,7 +398,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
fswtchParam[i]->setSingleStep(1);
|
fswtchParam[i]->setSingleStep(1);
|
||||||
fswtchParam[i]->setMinimum(-channelsMax);
|
fswtchParam[i]->setMinimum(-channelsMax);
|
||||||
fswtchParam[i]->setMaximum(channelsMax);
|
fswtchParam[i]->setMaximum(channelsMax);
|
||||||
if (modified) {
|
if (changed) {
|
||||||
cfn.param = fswtchParam[i]->value();
|
cfn.param = fswtchParam[i]->value();
|
||||||
}
|
}
|
||||||
fswtchParam[i]->setValue(cfn.param);
|
fswtchParam[i]->setValue(cfn.param);
|
||||||
@@ -410,7 +410,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
fswtchParam[i]->setMinimum(0.1);
|
fswtchParam[i]->setMinimum(0.1);
|
||||||
fswtchParam[i]->setMaximum(25.5);
|
fswtchParam[i]->setMaximum(25.5);
|
||||||
fswtchParam[i]->setSingleStep(0.1);
|
fswtchParam[i]->setSingleStep(0.1);
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParam[i]->value() * 10.0;
|
cfn.param = fswtchParam[i]->value() * 10.0;
|
||||||
fswtchParam[i]->setValue(cfn.param / 10.0);
|
fswtchParam[i]->setValue(cfn.param / 10.0);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
||||||
@@ -420,19 +420,19 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
fswtchParam[i]->setMinimum(0);
|
fswtchParam[i]->setMinimum(0);
|
||||||
fswtchParam[i]->setMaximum(25.5);
|
fswtchParam[i]->setMaximum(25.5);
|
||||||
fswtchParam[i]->setSingleStep(0.1);
|
fswtchParam[i]->setSingleStep(0.1);
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParam[i]->value() * 10.0;
|
cfn.param = fswtchParam[i]->value() * 10.0;
|
||||||
fswtchParam[i]->setValue(cfn.param / 10.0);
|
fswtchParam[i]->setValue(cfn.param / 10.0);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
||||||
}
|
}
|
||||||
else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) {
|
else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) {
|
||||||
int gvidx = func - FuncAdjustGV1;
|
int gvidx = func - FuncAdjustGV1;
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.adjustMode = fswtchGVmode[i]->currentData().toInt();
|
cfn.adjustMode = fswtchGVmode[i]->currentData().toInt();
|
||||||
fswtchGVmode[i]->setCurrentIndex(fswtchGVmode[i]->findData(cfn.adjustMode));
|
fswtchGVmode[i]->setCurrentIndex(fswtchGVmode[i]->findData(cfn.adjustMode));
|
||||||
widgetsMask |= CUSTOM_FUNCTION_GV_MODE;
|
widgetsMask |= CUSTOM_FUNCTION_GV_MODE;
|
||||||
if (cfn.adjustMode == FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode == FUNC_ADJUST_GVAR_INCDEC) {
|
if (cfn.adjustMode == FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode == FUNC_ADJUST_GVAR_INCDEC) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParam[i]->value() * model->gvarData[gvidx].multiplierSet();
|
cfn.param = fswtchParam[i]->value() * model->gvarData[gvidx].multiplierSet();
|
||||||
fswtchParam[i]->setDecimals(model->gvarData[gvidx].prec);
|
fswtchParam[i]->setDecimals(model->gvarData[gvidx].prec);
|
||||||
fswtchParam[i]->setSingleStep(model->gvarData[gvidx].multiplierGet());
|
fswtchParam[i]->setSingleStep(model->gvarData[gvidx].multiplierGet());
|
||||||
@@ -442,29 +442,40 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
rng *= model->gvarData[gvidx].multiplierGet();
|
rng *= model->gvarData[gvidx].multiplierGet();
|
||||||
fswtchParam[i]->setMinimum(-rng);
|
fswtchParam[i]->setMinimum(-rng);
|
||||||
fswtchParam[i]->setMaximum(rng);
|
fswtchParam[i]->setMaximum(rng);
|
||||||
|
fswtchParam[i]->setValue(cfn.param * model->gvarData[gvidx].multiplierGet());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fswtchParam[i]->setMinimum(model->gvarData[gvidx].getMinPrec());
|
fswtchParam[i]->setMinimum(model->gvarData[gvidx].getMinPrec());
|
||||||
fswtchParam[i]->setMaximum(model->gvarData[gvidx].getMaxPrec());
|
fswtchParam[i]->setMaximum(model->gvarData[gvidx].getMaxPrec());
|
||||||
|
|
||||||
|
if (cfn.param < model->gvarData[gvidx].getMin()) {
|
||||||
|
cfn.param = model->gvarData[gvidx].getMin();
|
||||||
|
emit modified();
|
||||||
|
} else if (cfn.param > model->gvarData[gvidx].getMax()) {
|
||||||
|
cfn.param = model->gvarData[gvidx].getMax();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
|
||||||
|
fswtchParam[i]->setValue(cfn.param * model->gvarData[gvidx].multiplierGet());
|
||||||
}
|
}
|
||||||
fswtchParam[i]->setValue(cfn.param * model->gvarData[gvidx].multiplierGet());
|
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParamT[i]->currentData().toInt();
|
cfn.param = fswtchParamT[i]->currentData().toInt();
|
||||||
populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (func == FuncReset) {
|
else if (func == FuncReset) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParamT[i]->currentData().toInt();
|
cfn.param = fswtchParamT[i]->currentData().toInt();
|
||||||
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||||
}
|
}
|
||||||
else if (func >= FuncSetTimer1 && func <= FuncSetTimerLast) {
|
else if (func >= FuncSetTimer1 && func <= FuncSetTimerLast) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParamTime[i]->timeInSeconds();
|
cfn.param = fswtchParamTime[i]->timeInSeconds();
|
||||||
RawSourceRange range = RawSource(SOURCE_TYPE_TIMER, func - FuncSetTimer1 + 1).getRange(model, generalSettings);
|
RawSourceRange range = RawSource(SOURCE_TYPE_TIMER, func - FuncSetTimer1 + 1).getRange(model, generalSettings);
|
||||||
fswtchParamTime[i]->setTimeRange((int)range.min, (int)range.max);
|
fswtchParamTime[i]->setTimeRange((int)range.min, (int)range.max);
|
||||||
@@ -472,21 +483,21 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM;
|
||||||
}
|
}
|
||||||
else if (func == FuncVolume || func == FuncBacklight) {
|
else if (func == FuncVolume || func == FuncBacklight) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParamT[i]->currentData().toInt();
|
cfn.param = fswtchParamT[i]->currentData().toInt();
|
||||||
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||||
}
|
}
|
||||||
else if (func == FuncPlaySound || func == FuncPlayHaptic || func == FuncPlayValue || func == FuncPlayPrompt || func == FuncPlayBoth || func == FuncBackgroundMusic || func == FuncSetScreen) {
|
else if (func == FuncPlaySound || func == FuncPlayHaptic || func == FuncPlayValue || func == FuncPlayPrompt || func == FuncPlayBoth || func == FuncBackgroundMusic || func == FuncSetScreen) {
|
||||||
if (func != FuncBackgroundMusic) {
|
if (func != FuncBackgroundMusic) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
||||||
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
||||||
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId));
|
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId));
|
||||||
fswtchRepeat[i]->setCurrentIndex(fswtchRepeat[i]->findData(cfn.repeatParam));
|
fswtchRepeat[i]->setCurrentIndex(fswtchRepeat[i]->findData(cfn.repeatParam));
|
||||||
}
|
}
|
||||||
if (func == FuncPlayValue) {
|
if (func == FuncPlayValue) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParamT[i]->currentData().toInt();
|
cfn.param = fswtchParamT[i]->currentData().toInt();
|
||||||
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_REPEAT;
|
||||||
@@ -504,7 +515,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
fswtchParamGV[i]->setChecked(false);
|
fswtchParamGV[i]->setChecked(false);
|
||||||
}
|
}
|
||||||
fswtchParam[i]->setMaximum(func == FuncPlayBoth ? 254 : 255);
|
fswtchParam[i]->setMaximum(func == FuncPlayBoth ? 254 : 255);
|
||||||
if (modified) {
|
if (changed) {
|
||||||
if (fswtchParamGV[i]->isChecked()) {
|
if (fswtchParamGV[i]->isChecked()) {
|
||||||
fswtchParam[i]->setMinimum(1);
|
fswtchParam[i]->setMinimum(1);
|
||||||
cfn.param = std::min(fswtchParam[i]->value(), 5.0) + (fswtchParamGV[i]->isChecked() ? 250 : 0);
|
cfn.param = std::min(fswtchParam[i]->value(), 5.0) + (fswtchParamGV[i]->isChecked() ? 250 : 0);
|
||||||
@@ -527,7 +538,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
||||||
if (modified) {
|
if (changed) {
|
||||||
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
|
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
|
||||||
}
|
}
|
||||||
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
|
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
|
||||||
@@ -538,7 +549,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
}
|
}
|
||||||
else if (func == FuncBackgroundMusic) {
|
else if (func == FuncBackgroundMusic) {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
||||||
if (modified) {
|
if (changed) {
|
||||||
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
|
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
|
||||||
}
|
}
|
||||||
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
|
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
|
||||||
@@ -547,19 +558,19 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (func == FuncPlaySound) {
|
else if (func == FuncPlaySound) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
||||||
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_PLAY;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_PLAY;
|
||||||
}
|
}
|
||||||
else if (func == FuncPlayHaptic) {
|
else if (func == FuncPlayHaptic) {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
||||||
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||||
}
|
}
|
||||||
else if (func == FuncSetScreen) {
|
else if (func == FuncSetScreen) {
|
||||||
if (modified) {
|
if (changed) {
|
||||||
cfn.param = (uint8_t)fswtchParam[i]->value();
|
cfn.param = (uint8_t)fswtchParam[i]->value();
|
||||||
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
||||||
}
|
}
|
||||||
@@ -584,7 +595,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
}
|
}
|
||||||
else if (func == FuncPlayScript || func == FuncRGBLed) {
|
else if (func == FuncPlayScript || func == FuncRGBLed) {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM | CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM | CUSTOM_FUNCTION_REPEAT;
|
||||||
if (modified) {
|
if (changed) {
|
||||||
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8);
|
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8);
|
||||||
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
||||||
}
|
}
|
||||||
@@ -593,7 +604,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
fswtchRepeat[i]->setCurrentIndex(fswtchRepeat[i]->findData(cfn.repeatParam));
|
fswtchRepeat[i]->setCurrentIndex(fswtchRepeat[i]->findData(cfn.repeatParam));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (modified)
|
if (changed)
|
||||||
cfn.param = fswtchParam[i]->value();
|
cfn.param = fswtchParam[i]->value();
|
||||||
fswtchParam[i]->setDecimals(0);
|
fswtchParam[i]->setDecimals(0);
|
||||||
fswtchParam[i]->setSingleStep(1);
|
fswtchParam[i]->setSingleStep(1);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class CustomFunctionsPanel : public GenericPanel
|
|||||||
void customFunctionEdited();
|
void customFunctionEdited();
|
||||||
void functionEdited();
|
void functionEdited();
|
||||||
void onCustomContextMenuRequested(QPoint pos);
|
void onCustomContextMenuRequested(QPoint pos);
|
||||||
void refreshCustomFunction(int index, bool modified=false);
|
void refreshCustomFunction(int index, bool changed = false);
|
||||||
bool playSound(int index);
|
bool playSound(int index);
|
||||||
void stopSound(int index);
|
void stopSound(int index);
|
||||||
void toggleSound(bool play);
|
void toggleSound(bool play);
|
||||||
|
|||||||
Reference in New Issue
Block a user