mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 08:15:17 +03:00
'next' support continued: Repeat param for Play functions
This commit is contained in:
parent
ccd8d9d1fd
commit
3d91abbd5b
6 changed files with 64 additions and 29 deletions
|
@ -646,7 +646,7 @@ class FuncSwData { // Function Switches data
|
|||
char paramarm[10];
|
||||
unsigned int enabled; // TODO perhaps not any more the right name
|
||||
unsigned int adjustMode;
|
||||
unsigned int repeatParam;
|
||||
int repeatParam;
|
||||
void clear() { memset(this, 0, sizeof(FuncSwData)); }
|
||||
};
|
||||
|
||||
|
|
|
@ -1338,10 +1338,10 @@ class CustomFunctionField: public TransformedField {
|
|||
internalField.Append(new CharField<6>(_arm_param));
|
||||
if (version >= 214) {
|
||||
internalField.Append(new UnsignedField<2>(_mode));
|
||||
internalField.Append(new UnsignedField<6>(_delay));
|
||||
internalField.Append(new SignedField<6>(_delay));
|
||||
}
|
||||
else {
|
||||
internalField.Append(new UnsignedField<8>(_delay));
|
||||
internalField.Append(new UnsignedField<8>((unsigned int &)_delay));
|
||||
}
|
||||
if (version < 214)
|
||||
internalField.Append(new SpareBitsField<8>());
|
||||
|
@ -1364,7 +1364,7 @@ class CustomFunctionField: public TransformedField {
|
|||
if (IS_ARM(board)) {
|
||||
_mode = 0;
|
||||
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue)
|
||||
_delay = fn.repeatParam / 5;
|
||||
_delay = (version >= 216 ? fn.repeatParam : (fn.repeatParam/5));
|
||||
else
|
||||
_delay = (fn.enabled ? 1 : 0);
|
||||
if (fn.func <= FuncInstantTrim) {
|
||||
|
@ -1439,7 +1439,7 @@ class CustomFunctionField: public TransformedField {
|
|||
{
|
||||
if (IS_ARM(board)) {
|
||||
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue)
|
||||
fn.repeatParam = _delay * 5;
|
||||
fn.repeatParam = (version >= 216 ? _delay : (_delay*5));
|
||||
else
|
||||
fn.enabled = (_delay & 0x01);
|
||||
|
||||
|
@ -1529,7 +1529,7 @@ class CustomFunctionField: public TransformedField {
|
|||
SourcesConversionTable * sourcesConversionTable;
|
||||
char _arm_param[10];
|
||||
unsigned int _param;
|
||||
unsigned int _delay;
|
||||
int _delay;
|
||||
unsigned int _mode;
|
||||
unsigned int _union_param;
|
||||
};
|
||||
|
|
|
@ -449,17 +449,6 @@ void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, u
|
|||
}
|
||||
}
|
||||
|
||||
void populateRepeatCB(QComboBox *b, unsigned int value)
|
||||
{
|
||||
b->clear();
|
||||
b->addItem(QObject::tr("No repeat", 0));
|
||||
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
|
||||
for (unsigned int i=step; i<=60; i+=step) {
|
||||
b->addItem(QObject::tr("%1s").arg(i), i);
|
||||
if (i==value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
|
||||
void populateGVmodeCB(QComboBox *b, unsigned int value)
|
||||
{
|
||||
b->clear();
|
||||
|
|
|
@ -84,7 +84,6 @@ class CurveGroup : public QObject {
|
|||
#define POPULATE_AND_SWITCHES 0x04
|
||||
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
|
||||
void populateFuncCB(QComboBox *b, unsigned int value);
|
||||
void populateRepeatCB(QComboBox *b, unsigned int value);
|
||||
void populateGVmodeCB(QComboBox *b, unsigned int value);
|
||||
QString FuncParam(uint function, int value, QString paramT="",unsigned int adjustmode=0);
|
||||
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
|
||||
|
|
|
@ -7,6 +7,35 @@
|
|||
#include <QDoubleSpinBox>
|
||||
#include "helpers.h"
|
||||
|
||||
RepeatComboBox::RepeatComboBox(QWidget *parent, int & repeatParam):
|
||||
QComboBox(parent),
|
||||
repeatParam(repeatParam)
|
||||
{
|
||||
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10;
|
||||
int value = repeatParam/step;
|
||||
|
||||
if (step == 1) {
|
||||
addItem(QObject::tr("Played once, not during startup"), -1);
|
||||
value++;
|
||||
}
|
||||
|
||||
addItem(QObject::tr("No repeat"), 0);
|
||||
|
||||
for (unsigned int i=step; i<=60; i+=step) {
|
||||
addItem(QObject::tr("%1s").arg(i), i);
|
||||
}
|
||||
|
||||
setCurrentIndex(value);
|
||||
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)));
|
||||
}
|
||||
|
||||
void RepeatComboBox::onIndexChanged(int index)
|
||||
{
|
||||
repeatParam = itemData(index).toInt();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
|
||||
ModelPanel(parent, model),
|
||||
generalSettings(generalSettings),
|
||||
|
@ -132,12 +161,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||
|
||||
QHBoxLayout *repeatLayout = new QHBoxLayout();
|
||||
gridLayout->addLayout(repeatLayout, i+1, 4);
|
||||
|
||||
fswtchRepeat[i] = new QComboBox(this);
|
||||
fswtchRepeat[i]->setProperty("index", i);
|
||||
connect(fswtchRepeat[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
||||
fswtchRepeat[i] = new RepeatComboBox(this, model.funcSw[i].repeatParam);
|
||||
repeatLayout->addWidget(fswtchRepeat[i], i+1);
|
||||
populateRepeatCB(fswtchRepeat[i], model.funcSw[i].repeatParam);
|
||||
connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified()));
|
||||
|
||||
fswtchEnable[i] = new QCheckBox(this);
|
||||
fswtchEnable[i]->setProperty("index", i);
|
||||
|
@ -252,6 +278,11 @@ void CustomFunctionsPanel::customFunctionEdited()
|
|||
}
|
||||
}
|
||||
|
||||
void CustomFunctionsPanel::onChildModified()
|
||||
{
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||
{
|
||||
unsigned int widgetsMask = 0;
|
||||
|
@ -259,7 +290,6 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||
model.funcSw[i].swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt());
|
||||
model.funcSw[i].func = (AssignFunc)fswtchFunc[i]->currentIndex();
|
||||
model.funcSw[i].enabled = fswtchEnable[i]->isChecked();
|
||||
model.funcSw[i].repeatParam = (AssignFunc)fswtchRepeat[i]->currentIndex();
|
||||
model.funcSw[i].adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex();
|
||||
}
|
||||
|
||||
|
@ -314,12 +344,9 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE;
|
||||
}
|
||||
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
|
||||
if (modified) model.funcSw[i].repeatParam = fswtchRepeat[i]->itemData(fswtchRepeat[i]->currentIndex()).toInt();
|
||||
if (index != FuncBackgroundMusic) {
|
||||
if (GetEepromInterface()->getCapability(HasFuncRepeat)) {
|
||||
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
|
||||
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
||||
}
|
||||
}
|
||||
if (index==FuncPlayValue) {
|
||||
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
||||
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
|
||||
|
@ -422,9 +449,11 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||
|
||||
void CustomFunctionsPanel::update()
|
||||
{
|
||||
lock = true;
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
|
||||
refreshCustomFunction(i);
|
||||
}
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void CustomFunctionsPanel::fswPaste()
|
||||
|
|
|
@ -13,6 +13,23 @@
|
|||
#include <phonon/mediasource.h>
|
||||
#endif
|
||||
|
||||
class RepeatComboBox: public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RepeatComboBox(QWidget *parent, int & repeatParam);
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void onIndexChanged(int);
|
||||
|
||||
protected:
|
||||
int & repeatParam;
|
||||
};
|
||||
|
||||
class CustomFunctionsPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -28,6 +45,7 @@ class CustomFunctionsPanel : public ModelPanel
|
|||
void fsw_customContextMenuRequested(QPoint pos);
|
||||
void refreshCustomFunction(int index, bool modified=false);
|
||||
void playMusic();
|
||||
void onChildModified();
|
||||
#ifdef PHONON
|
||||
void mediaPlayer_state(Phonon::State newState, Phonon::State oldState);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue