Exemplo n.º 1
0
void CustomFunctionsPanel::update()
{
  lock = true;
  for (int i=0; i<firmware->getCapability(CustomFunctions); i++) {
    if (!initialized) {
      populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, generalSettings, CustomFunctionsContext);
      populateFuncCB(fswtchFunc[i], model.funcSw[i].func);
      populateGVmodeCB(fswtchGVmode[i], model.funcSw[i].adjustMode);
      populateFuncParamCB(fswtchParamT[i], model, model.funcSw[i].func, model.funcSw[i].param, model.funcSw[i].adjustMode);
    }
    refreshCustomFunction(i);
  }
  initialized = true;
  lock = false;
}
Exemplo n.º 2
0
void CustomFunctionsPanel::update()
{
  lock = true;
  int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
  for (int i=0; i<num_fsw; i++) {
    if (!initialized) {
      populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext);
      populateFuncCB(fswtchFunc[i], functions[i].func);
      populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode);
      populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode);
    }
    refreshCustomFunction(i);
  }
  initialized = true;
  lock = false;
}
Exemplo n.º 3
0
void CustomFunctionsPanel::fswPaste()
{
  const QClipboard *clipboard = QApplication::clipboard();
  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));
    lock = true;
    populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
    populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
    populateGVmodeCB(fswtchGVmode[selectedFunction], model.funcSw[selectedFunction].adjustMode);
    populateFuncParamCB(fswtchParamT[selectedFunction], model, model.funcSw[selectedFunction].func, model.funcSw[selectedFunction].param, model.funcSw[selectedFunction].adjustMode);
    refreshCustomFunction(selectedFunction);
    lock = false;
    emit modified();
  }
}
Exemplo n.º 4
0
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware):
  GenericPanel(parent, model, generalSettings, firmware),
  functions(model ? model->customFn : generalSettings.customFn)
#if defined(PHONON)
  ,
  phononCurrent(-1),
  clickObject(NULL),
  clickOutput(NULL)
#endif
{
  Stopwatch s1("CustomFunctionsPanel - populate"); 
  lock = true;
  int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);

  if (!firmware->getCapability(VoicesAsNumbers)) {
    tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength));
    for (int i=0; i<num_fsw; i++) {
      if (functions[i].func==FuncPlayPrompt || functions[i].func==FuncBackgroundMusic) {
        QString temp = functions[i].paramarm;
        if (!temp.isEmpty()) {
          tracksSet.insert(temp);
        }
      }
    }
  }

  s1.report("get tracks");

  if (IS_TARANIS(firmware->getBoard())) {
    scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/FUNCTIONS", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength));
    for (int i=0; i<num_fsw; i++) {
      if (functions[i].func==FuncPlayScript) {
        QString temp = functions[i].paramarm;
        if (!temp.isEmpty()) {
          scriptsSet.insert(temp);
        }
      }
    }
  }
  s1.report("get scripts");

  CompanionIcon playIcon("play.png");

  QStringList headerLabels;
  headerLabels << "#" << tr("Switch") << tr("Action") << tr("Parameters") << tr("Enable");
  TableLayout * tableLayout = new TableLayout(this, num_fsw, headerLabels);

  for (int i=0; i<num_fsw; i++) {
    // The label
    QLabel * label = new QLabel(this);
    label->setContextMenuPolicy(Qt::CustomContextMenu);
    label->setMouseTracking(true);
    label->setProperty("index", i);
    if (model)
      label->setText(tr("SF%1").arg(i+1));
    else
      label->setText(tr("GF%1").arg(i+1));
    label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
    connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
    tableLayout->addWidget(i, 0, label);
    // s1.report("label");

    // The switch
    fswtchSwtch[i] = new QComboBox(this);
    fswtchSwtch[i]->setProperty("index", i);
    populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext);
    fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
    fswtchSwtch[i]->setMaxVisibleItems(10);
    connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
    tableLayout->addWidget(i, 1, fswtchSwtch[i]);
    // s1.report("switch");

    // The function
    fswtchFunc[i] = new QComboBox(this);
    fswtchFunc[i]->setProperty("index", i);
    populateFuncCB(fswtchFunc[i], functions[i].func);
    connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited()));
    tableLayout->addWidget(i, 2, fswtchFunc[i]);
    // s1.report("func");

    // The parameters
    QHBoxLayout * paramLayout = new QHBoxLayout();
    tableLayout->addLayout(i, 3, paramLayout);

    fswtchGVmode[i] = new QComboBox(this);
    fswtchGVmode[i]->setProperty("index", i);
    populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode);
    fswtchGVmode[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchGVmode[i]);

    fswtchParamGV[i] = new QCheckBox(this);
    fswtchParamGV[i]->setProperty("index", i);
    fswtchParamGV[i]->setText("GV");
    fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
    connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchParamGV[i]);

    fswtchParam[i] = new QDoubleSpinBox(this);
    fswtchParam[i]->setProperty("index", i);
    fswtchParam[i]->setAccelerated(true);
    fswtchParam[i]->setDecimals(0);
    connect(fswtchParam[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchParam[i]);

    fswtchParamTime[i] = new QTimeEdit(this);
    fswtchParamTime[i]->setProperty("index", i);
    fswtchParamTime[i]->setAccelerated(true);
    fswtchParamTime[i]->setDisplayFormat("hh:mm:ss");
    connect(fswtchParamTime[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchParamTime[i]);

    fswtchParamT[i] = new QComboBox(this);
    fswtchParamT[i]->setProperty("index", i);
    populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode);
    paramLayout->addWidget(fswtchParamT[i]);
    fswtchParamT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));

    fswtchParamArmT[i] = new QComboBox(this);
    fswtchParamArmT[i]->setProperty("index", i);
    fswtchParamArmT[i]->setEditable(true);
    fswtchParamArmT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    paramLayout->addWidget(fswtchParamArmT[i]);

    connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
    connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));

    fswtchBLcolor[i] = new QSlider(this);
    fswtchBLcolor[i]->setProperty("index", i);
    fswtchBLcolor[i]->setMinimum(0);
    fswtchBLcolor[i]->setMaximum(100);
    fswtchBLcolor[i]->setSingleStep(1);
    fswtchBLcolor[i]->setOrientation(Qt::Horizontal);
    paramLayout->addWidget(fswtchBLcolor[i]);
    connect(fswtchBLcolor[i], SIGNAL(sliderReleased()), this, SLOT(customFunctionEdited()));

#ifdef PHONON
    playBT[i] = new QPushButton(this);
    playBT[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    playBT[i]->setProperty("index", i);
    playBT[i]->setIcon(playIcon);
    paramLayout->addWidget(playBT[i]);
    connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
#endif

    QHBoxLayout * repeatLayout = new QHBoxLayout();
    tableLayout->addLayout(i, 4, repeatLayout);
    fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam);
    repeatLayout->addWidget(fswtchRepeat[i], i+1);
    connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified()));

    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);
    connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
  }
  s1.report("add items");

  disableMouseScrolling();
  s1.report("disableMouseScrolling");

  lock = false;

  update();
  s1.report("update");
  tableLayout->resizeColumnsToContents();
  s1.report("resizeColumnsToContents");
  tableLayout->setColumnWidth(3, 300);
  tableLayout->pushRowsUp(num_fsw+1);
  s1.report("end");
}