[Companion] Fixes #3858 (#3958)

This commit is contained in:
Bertrand Songis
2016-10-27 20:12:45 +02:00
committed by Damjan Adamic
parent 0b0059908c
commit 8626c0728c
4 changed files with 21 additions and 8 deletions
+4 -4
View File
@@ -908,12 +908,12 @@ QString CustomFunctionData::paramToString(const ModelData * model) const
} }
else if ((func>=FuncAdjustGV1) && (func<FuncCount)) { else if ((func>=FuncAdjustGV1) && (func<FuncCount)) {
switch (adjustMode) { switch (adjustMode) {
case 0: case FUNC_ADJUST_GVAR_CONSTANT:
return QObject::tr("Value ")+QString("%1").arg(param); return QObject::tr("Value ")+QString("%1").arg(param);
case 1: case FUNC_ADJUST_GVAR_SOURCE:
case 2: case FUNC_ADJUST_GVAR_GVAR:
return RawSource(param).toString(); return RawSource(param).toString();
case 3: case FUNC_ADJUST_GVAR_INCDEC:
if (param==0) return QObject::tr("Decr:") + " -1"; if (param==0) return QObject::tr("Decr:") + " -1";
else return QObject::tr("Incr:") + " +1"; else return QObject::tr("Incr:") + " +1";
} }
+8
View File
@@ -608,6 +608,14 @@ enum AssignFunc {
FuncReserve = -1 FuncReserve = -1
}; };
enum GVarAdjustModes
{
FUNC_ADJUST_GVAR_CONSTANT,
FUNC_ADJUST_GVAR_SOURCE,
FUNC_ADJUST_GVAR_GVAR,
FUNC_ADJUST_GVAR_INCDEC
};
class CustomFunctionData { // Function Switches data class CustomFunctionData { // Function Switches data
public: public:
CustomFunctionData(AssignFunc func=FuncOverrideCH1) { clear(); this->func = func; } CustomFunctionData(AssignFunc func=FuncOverrideCH1) { clear(); this->func = func; }
@@ -2115,12 +2115,17 @@ class ArmCustomFunctionField: public TransformedField {
} }
} }
static bool hasRepeatParam(const CustomFunctionData & fn)
{
return (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue || fn.func == FuncPlayHaptic);
}
virtual void beforeExport() virtual void beforeExport()
{ {
if (fn.swtch.type != SWITCH_TYPE_NONE) { if (fn.swtch.type != SWITCH_TYPE_NONE) {
_func = fn.func; _func = fn.func;
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue || fn.func == FuncPlayHaptic || (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast)) if (hasRepeatParam(fn))
_active = (version >= 216 ? fn.repeatParam : (fn.repeatParam/5)); _active = (version >= 216 ? fn.repeatParam : (fn.repeatParam/5));
else else
_active = (fn.enabled ? 1 : 0); _active = (fn.enabled ? 1 : 0);
@@ -2216,7 +2221,7 @@ class ArmCustomFunctionField: public TransformedField {
{ {
fn.func = (AssignFunc)_func; fn.func = (AssignFunc)_func;
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue || fn.func == FuncPlayHaptic || (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast)) if (hasRepeatParam(fn))
fn.repeatParam = (version >= 216 ? _active : (_active*5)); fn.repeatParam = (version >= 216 ? _active : (_active*5));
else else
fn.enabled = (_active & 0x01); fn.enabled = (_active & 0x01);
+2 -2
View File
@@ -367,8 +367,8 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
} }
else if (func>=FuncAdjustGV1 && func<=FuncAdjustGVLast) { else if (func>=FuncAdjustGV1 && func<=FuncAdjustGVLast) {
if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex(); if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex();
widgetsMask |= CUSTOM_FUNCTION_GV_MODE | (IS_ARM(firmware->getBoard()) ? CUSTOM_FUNCTION_REPEAT : CUSTOM_FUNCTION_ENABLE); widgetsMask |= CUSTOM_FUNCTION_GV_MODE | CUSTOM_FUNCTION_ENABLE;
if (cfn.adjustMode==0 || cfn.adjustMode==3) { if (cfn.adjustMode==FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode==FUNC_ADJUST_GVAR_INCDEC) {
if (modified) cfn.param = fswtchParam[i]->value(); if (modified) cfn.param = fswtchParam[i]->value();
fswtchParam[i]->setDecimals(0); fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setSingleStep(1);