diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 98c331f5d..d2468bc19 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -36,6 +36,16 @@ void RepeatComboBox::onIndexChanged(int index) emit modified(); } +void RepeatComboBox::update() +{ + unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10; + int value = repeatParam/step; + if (step == 1) { + value++; + } + setCurrentIndex(value); +} + CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings): ModelPanel(parent, model), generalSettings(generalSettings), @@ -52,7 +62,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, lock = true; int num_fsw = GetEepromInterface()->getCapability(CustomFunctions); - QStringList paramarmList; if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) { for (int i=0; isetContextMenuPolicy(Qt::CustomContextMenu); + label->setMouseTracking(true); + label->setProperty("index", i); + label->setText(tr("CF%1").arg(i+1)); + gridLayout->addWidget(label, i+1, 0); + connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint))); + // The switch fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i]->setProperty("index", i); @@ -135,7 +153,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, fswtchParamArmT[i] = new QComboBox(this); fswtchParamArmT[i]->setProperty("index", i); - populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList); + populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList); fswtchParamArmT[i]->setEditable(true); paramLayout->addWidget(fswtchParamArmT[i]); @@ -337,6 +355,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) { widgetsMask |= CUSTOM_FUNCTION_REPEAT; + fswtchRepeat[i]->update(); } if (index==FuncPlayValue) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); @@ -381,14 +400,20 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); - int vml=GetEepromInterface()->getCapability(VoicesMaxLength); + int vml = GetEepromInterface()->getCapability(VoicesMaxLength); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; - for (int j=0; jcurrentText().length(),vml); j++) { + for (int j=0; jcurrentText().length(), vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } + else { + populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList); + if (fswtchParamArmT[i]->currentText() != "----") { + widgetsMask |= CUSTOM_FUNCTION_PLAY; + } + } } } else if (index==FuncBackgroundMusic) { @@ -453,13 +478,13 @@ void CustomFunctionsPanel::fswPaste() const QMimeData *mimeData = clipboard->mimeData(); if (mimeData->hasFormat("application/x-companion-fsw")) { QByteArray fswData = mimeData->data("application/x-companion-fsw"); - FuncSwData *fsw = &model.funcSw[selectedFunction]; memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData)); - // TODO update switch and func + lock = true; populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); refreshCustomFunction(selectedFunction); + lock = false; emit modified(); } } @@ -476,17 +501,17 @@ void CustomFunctionsPanel::fswDelete() void CustomFunctionsPanel::fswCopy() { - QByteArray fswData; - fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData)); - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-companion-fsw", fswData); - QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); + QByteArray fswData; + fswData.append((char*)&model.funcSw[selectedFunction], sizeof(FuncSwData)); + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-companion-fsw", fswData); + QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); } void CustomFunctionsPanel::fswCut() { - fswCopy(); - fswDelete(); + fswCopy(); + fswDelete(); } void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) @@ -551,18 +576,25 @@ void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value) b->setCurrentIndex(value); } -void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList) +void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList) { b->clear(); b->addItem("----"); + bool added = false; QString currentvalue(value); foreach ( QString entry, paramsList ) { b->addItem(entry); if (entry==currentvalue) { b->setCurrentIndex(b->count()-1); + added = true; } } + + if (!added && strlen(value)) { + b->addItem(value); + b->setCurrentIndex(b->count()-1); + } } void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode) diff --git a/companion/src/modeledit/customfunctions.h b/companion/src/modeledit/customfunctions.h index bb109d9e1..0730e46c6 100644 --- a/companion/src/modeledit/customfunctions.h +++ b/companion/src/modeledit/customfunctions.h @@ -19,6 +19,7 @@ class RepeatComboBox: public QComboBox public: RepeatComboBox(QWidget *parent, int & repeatParam); + void update(); signals: void modified(); @@ -58,9 +59,10 @@ class CustomFunctionsPanel : public ModelPanel void populateFuncCB(QComboBox *b, unsigned int value); void populateGVmodeCB(QComboBox *b, unsigned int value); void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0); - void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList); + void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList); GeneralSettings & generalSettings; + QStringList paramarmList; bool phononLock; QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS]; @@ -70,7 +72,7 @@ class CustomFunctionsPanel : public ModelPanel QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS]; QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; + RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS]; #ifdef PHONON Phonon::MediaObject *clickObject;