void InputMap::saveDefaults() { QSettings settings; QString key; QString str; for (quint32 i = 0; i < m_universes; i++) { InputPatch* pat = patch(i); Q_ASSERT(pat != NULL); /* Editor universe */ key = QString("/inputmap/editoruniverse/"); settings.setValue(key, m_editorUniverse); /* Plugin name */ key = QString("/inputmap/universe%2/plugin/").arg(i); if (pat->plugin() != NULL) settings.setValue(key, pat->plugin()->name()); else settings.setValue(key, "None"); /* Plugin input */ key = QString("/inputmap/universe%2/input/").arg(i); settings.setValue(key, str.setNum(pat->input())); /* Input profile */ key = QString("/inputmap/universe%2/profile/").arg(i); settings.setValue(key, pat->profileName()); } }
void GrandMasterSlider::sendFeedback() { quint32 universe = VirtualConsole::instance()->properties().grandMasterInputUniverse(); quint32 channel = VirtualConsole::instance()->properties().grandMasterInputChannel(); QString chName; if (universe == InputOutputMap::invalidUniverse() || channel == QLCChannel::invalid()) return; InputPatch* pat = m_ioMap->inputPatch(universe); if (pat != NULL) { QLCInputProfile* profile = pat->profile(); if (profile != NULL) { QLCInputChannel* ich = profile->channel(channel); if (ich != NULL) chName = ich->name(); } } if (m_slider->invertedAppearance()) m_ioMap->sendFeedBack(universe, channel, UCHAR_MAX - m_slider->value(), chName); else m_ioMap->sendFeedBack(universe, channel, m_slider->value(), chName); }
void SelectInputChannel::fillTree() { QLCInputChannel* channel; QTreeWidgetItem* uniItem; QTreeWidgetItem* chItem; QLCInputProfile* profile; quint32 uni; InputPatch* patch; /* Add an option to select no input at all */ chItem = new QTreeWidgetItem(m_tree); chItem->setText(KColumnName, KInputNone); chItem->setText(KColumnUniverse, QString("%1") .arg(InputMap::invalidUniverse())); chItem->setText(KColumnChannel, QString("%1") .arg(KInputChannelInvalid)); for (uni = 0; uni < _app->inputMap()->universes(); uni++) { /* Get the patch associated to the current universe */ patch = _app->inputMap()->patch(uni); Q_ASSERT(patch != NULL); /* Make an item for each universe */ uniItem = new QTreeWidgetItem(m_tree); updateUniverseItem(uniItem, uni, patch); if (patch->plugin() != NULL && patch->input() != KInputInvalid) { /* Add a manual option to each patched universe */ chItem = new QTreeWidgetItem(uniItem); updateChannelItem(chItem, uni, NULL, NULL); } /* Add known channels from profile (if any) */ profile = patch->profile(); if (profile != NULL) { QMapIterator <quint32, QLCInputChannel*> it(profile->channels()); while (it.hasNext() == true) { channel = it.next().value(); Q_ASSERT(channel != NULL); chItem = new QTreeWidgetItem(uniItem); updateChannelItem(chItem, uni, channel, profile); } } } /* Listen to item changed signals so that we can catch user's manual input for <...> nodes. Connect AFTER filling the tree so all the initial item->setText()'s won't get caught here. */ connect(m_tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int))); }
/***************************************************************************** * Input data *****************************************************************************/ void InputMap::slotPluginConfigurationChanged(QLCIOPlugin* plugin) { for (quint32 i = 0; i < universes(); i++) { InputPatch* ip = patch(i); Q_ASSERT(ip != NULL); if (ip->plugin() == plugin) ip->reconnect(); } emit pluginConfigurationChanged(plugin->name()); }
void InputMap::feedBack(t_input_universe universe, t_input_channel channel, t_input_value value) { InputPatch* patch; Q_ASSERT(universe < m_patch.size()); patch = m_patch[universe]; Q_ASSERT(patch != NULL); if (patch->plugin() != NULL) patch->plugin()->feedBack(patch->input(), channel, value); }
InputOutputPatchEditor::InputOutputPatchEditor(QWidget* parent, quint32 universe, InputMap* inputMap, OutputMap* outputMap) : QWidget(parent) , m_inputMap(inputMap) , m_outputMap(outputMap) , m_universe(universe) { Q_ASSERT(universe < m_inputMap->universes()); Q_ASSERT(inputMap != NULL); Q_ASSERT(outputMap != NULL); setupUi(this); m_infoBrowser->setOpenExternalLinks(true); m_infoBrowser->setFixedHeight(250); InputPatch* inputPatch = m_inputMap->patch(universe); OutputPatch* outputPatch = m_outputMap->patch(universe); OutputPatch* feedbackPatch = m_outputMap->feedbackPatch(universe); Q_ASSERT(inputPatch != NULL); Q_ASSERT(outputPatch != NULL); /* Copy these so they can be applied if the user cancels */ m_currentInputPluginName = inputPatch->pluginName(); m_currentInput = inputPatch->input(); m_currentProfileName = inputPatch->profileName(); //m_currentFeedbackEnabled = inputPatch->feedbackEnabled(); m_currentOutputPluginName = outputPatch->pluginName(); m_currentOutput = outputPatch->output(); m_currentFeedbackPluginName = feedbackPatch->pluginName(); m_currentFeedback = feedbackPatch->output(); m_mapTree->header()->setResizeMode(QHeaderView::ResizeToContents); m_mapTree->setSortingEnabled(true); m_mapTree->sortByColumn(KMapColumnPluginName, Qt::AscendingOrder); /* Setup UI controls */ setupMappingPage(); setupProfilePage(); /* Select the top-most "None" item */ m_mapTree->setCurrentItem(m_mapTree->topLevelItem(0)); /* Listen to plugin configuration changes */ connect(m_inputMap, SIGNAL(pluginConfigurationChanged(const QString&)), this, SLOT(slotPluginConfigurationChanged(const QString&))); /* Listen to plugin configuration changes */ connect(m_outputMap, SIGNAL(pluginConfigurationChanged(const QString&)), this, SLOT(slotPluginConfigurationChanged(const QString&))); }
void InputMap::slotConfigurationChanged() { QLCInPlugin* plugin = qobject_cast<QLCInPlugin*> (QObject::sender()); if (plugin == NULL) // The signal comes from a plugin that isn't guaranteed to behave return; for (quint32 i = 0; i < universes(); i++) { InputPatch* ip = patch(i); Q_ASSERT(ip != NULL); if (ip->plugin() == plugin) ip->reconnect(); } emit pluginConfigurationChanged(plugin->name()); }
bool VCPropertiesEditor::inputSourceNames(quint32 universe, quint32 channel, QString& uniName, QString& chName) const { if (universe == InputMap::invalidUniverse() || channel == InputMap::invalidChannel()) { /* Nothing selected for input universe and/or channel */ return false; } InputPatch* patch = m_inputMap->patch(universe); if (patch == NULL || patch->plugin() == NULL) { /* There is no patch for the given universe */ return false; } QLCInputProfile* profile = patch->profile(); if (profile == NULL) { /* There is no profile. Display plugin name and channel number. Boring. */ uniName = patch->plugin()->name(); chName = tr("%1: Unknown").arg(channel + 1); } else { QLCInputChannel* ich; QString name; /* Display profile name for universe */ uniName = QString("%1: %2").arg(universe + 1).arg(profile->name()); /* User can input the channel number by hand, so put something rational to the channel name in those cases as well. */ ich = profile->channel(channel); if (ich != NULL) name = ich->name(); else name = tr("Unknown"); /* Display channel name */ chName = QString("%1: %2").arg(channel + 1).arg(name); } return true; }
bool InputMap::inputSourceNames(const QLCInputSource& src, QString& uniName, QString& chName) const { if (src.isValid() == false) return false; InputPatch* pat = this->patch(src.universe()); if (pat == NULL) { /* There is no patch for the given universe */ return false; } QLCInputProfile* profile = pat->profile(); if (profile == NULL) { /* There is no profile. Display plugin name and channel number. */ if (pat->plugin() != NULL) uniName = QString("%1: %2").arg(src.universe() + 1).arg(pat->plugin()->name()); else uniName = QString("%1: ??").arg(src.universe() + 1); chName = QString("%1: ?").arg(src.channel() + 1); } else { QLCInputChannel* ich; QString name; /* Display profile name for universe */ uniName = QString("%1: %2").arg(src.universe() + 1).arg(profile->name()); /* User can input the channel number by hand, so put something rational to the channel name in those cases as well. */ ich = profile->channel(src.channel()); if (ich != NULL) name = ich->name(); else name = QString("?"); /* Display channel name */ chName = QString("%1: %2").arg(src.channel() + 1).arg(name); } return true; }
bool InputMap::feedBack(quint32 universe, quint32 channel, uchar value) { if (universe >= quint32(m_patch.size())) return false; InputPatch* patch = m_patch[universe]; Q_ASSERT(patch != NULL); if (patch->plugin() != NULL && patch->feedbackEnabled() == true) { patch->plugin()->feedBack(patch->input(), channel, value); return true; } else { return false; } }
bool InputMap::feedBack(t_input_universe universe, t_input_channel channel, t_input_value value) { if (universe >= m_patch.size()) return false; InputPatch* patch = m_patch[universe]; Q_ASSERT(patch != NULL); if (patch->plugin() != NULL && patch->feedbackEnabled() == true) { patch->plugin()->feedBack(patch->input(), channel, value); return true; } else { return false; } }
bool InputOutputMap::setInputPatch(quint32 universe, const QString &pluginName, quint32 input, const QString &profileName) { /* Check that the universe that we're doing mapping for is valid */ if (universe >= universes()) { qWarning() << Q_FUNC_INFO << "Universe" << universe << "out of bounds."; return false; } QMutexLocker locker(&m_universeMutex); InputPatch *currInPatch = m_universeArray.at(universe)->inputPatch(); QLCInputProfile *currProfile = NULL; if (currInPatch != NULL) { currProfile = currInPatch->profile(); disconnect(currInPatch, SIGNAL(inputValueChanged(quint32,quint32,uchar,const QString&)), this, SIGNAL(inputValueChanged(quint32,quint32,uchar,const QString&))); }
void InputSelectionWidget::updateInputSource() { QString uniName; QString chName; if (!m_inputSource || m_doc->inputOutputMap()->inputSourceNames(m_inputSource, uniName, chName) == false) { uniName = KInputNone; chName = KInputNone; m_lowerSpin->setEnabled(false); m_upperSpin->setEnabled(false); } else { m_lowerSpin->blockSignals(true); m_upperSpin->blockSignals(true); uchar min = 0, max = UCHAR_MAX; InputPatch *ip = m_doc->inputOutputMap()->inputPatch(m_inputSource->universe()); if (ip != NULL && ip->profile() != NULL) { QLCInputChannel *ich = ip->profile()->channel(m_inputSource->channel()); if (ich != NULL && ich->type() == QLCInputChannel::Button) { min = ich->lowerValue(); max = ich->upperValue(); } } m_lowerSpin->setValue((m_inputSource->lowerValue() != 0) ? m_inputSource->lowerValue() : min); m_upperSpin->setValue((m_inputSource->upperValue() != UCHAR_MAX) ? m_inputSource->upperValue() : max); if (m_lowerSpin->value() != 0 || m_upperSpin->value() != UCHAR_MAX) m_customFbButton->setChecked(true); m_lowerSpin->blockSignals(false); m_upperSpin->blockSignals(false); m_lowerSpin->setEnabled(true); m_upperSpin->setEnabled(true); } m_inputUniverseEdit->setText(uniName); m_inputChannelEdit->setText(chName); }
bool VCSlider::isButton(quint32 universe, quint32 channel) { InputPatch* patch = NULL; QLCInputProfile* profile = NULL; QLCInputChannel* ch = NULL; patch = m_doc->inputMap()->patch(universe); if (patch != NULL) { profile = patch->profile(); if (profile != NULL) { ch = profile->channels()[channel]; if (ch != NULL) { return (ch->type() == QLCInputChannel::Button); } } } return false; }
void InputOutputManager::updateItem(QTreeWidgetItem* item, quint32 universe) { Q_ASSERT(item != NULL); InputPatch* ip = m_inputMap->patch(universe); OutputPatch* op = m_outputMap->patch(universe); OutputPatch* fp = m_outputMap->feedbackPatch(universe); Q_ASSERT(ip != NULL); item->setText(KColumnUniverse, QString::number(universe + 1)); item->setText(KColumnInput, QString("[%1] %2").arg(ip->pluginName()).arg(ip->inputName())); item->setText(KColumnOutput, QString("[%1] %2").arg(op->pluginName()).arg(op->outputName())); item->setText(KColumnFeedback, QString("[%1] %2").arg(fp->pluginName()).arg(fp->outputName())); item->setText(KColumnProfile, ip->profileName()); item->setText(KColumnInputNum, QString::number(ip->input() + 1)); item->setText(KColumnOutputNum, QString::number(op->output() + 1)); m_tree->resizeColumnToContents(KColumnUniverse); m_tree->resizeColumnToContents(KColumnInput); m_tree->resizeColumnToContents(KColumnOutput); m_tree->resizeColumnToContents(KColumnProfile); }
void InputMap::saveDefaults() { QSettings settings; QString key; QString str; for (t_input_universe i = 0; i < m_universes; i++) { InputPatch* pat = patch(i); Q_ASSERT(pat != NULL); /* Editor universe */ key = QString("/inputmap/editoruniverse/"); settings.setValue(key, m_editorUniverse); if (pat->plugin() != NULL) { /* Plugin name */ key = QString("/inputmap/universe%2/plugin/").arg(i); settings.setValue(key, pat->plugin()->name()); /* Plugin input */ key = QString("/inputmap/universe%2/input/").arg(i); settings.setValue(key, str.setNum(pat->input())); /* Input profile */ key = QString("/inputmap/universe%2/profile/").arg(i); settings.setValue(key, pat->profileName()); /* Feedback enable */ key = QString("/inputmap/universe%2/feedbackEnabled/").arg(i); settings.setValue(key, pat->feedbackEnabled()); } else { /* Plugin name */ key = QString("/inputmap/universe%2/plugin/").arg(i); settings.setValue(key, ""); /* Plugin input */ key = QString("/inputmap/universe%2/input/").arg(i); settings.setValue(key, ""); /* Input profile */ key = QString("/inputmap/universe%2/profile/").arg(i); settings.setValue(key, ""); /* Feedback enable */ key = QString("/inputmap/universe%2/feedbackEnabled/").arg(i); settings.setValue(key, true); } } }
void InputPatch_Test::patch() { InputMap im(m_doc, 4); QCOMPARE(m_doc->ioPluginCache()->plugins().size(), 1); OutputPluginStub* stub = static_cast<OutputPluginStub*> (m_doc->ioPluginCache()->plugins().at(0)); QVERIFY(stub != NULL); QLCInputProfile prof1; prof1.setManufacturer("Foo"); prof1.setManufacturer("Bar"); InputPatch* ip = new InputPatch(0, this); ip->set(stub, 0, &prof1); QVERIFY(ip->m_plugin == stub); QVERIFY(ip->m_input == 0); QVERIFY(ip->m_profile == &prof1); QVERIFY(ip->pluginName() == stub->name()); QVERIFY(ip->inputName() == stub->inputs()[0]); QVERIFY(ip->profileName() == prof1.name()); QVERIFY(stub->m_openInputs.size() == 1); QVERIFY(stub->m_openInputs.at(0) == 0); QLCInputProfile prof2; prof2.setManufacturer("Xyzzy"); prof2.setManufacturer("Foobar"); ip->set(stub, 3, &prof2); QVERIFY(ip->m_plugin == stub); QVERIFY(ip->m_input == 3); QVERIFY(ip->m_profile == &prof2); QVERIFY(ip->pluginName() == stub->name()); QVERIFY(ip->inputName() == stub->inputs()[3]); QVERIFY(ip->profileName() == prof2.name()); QVERIFY(stub->m_openInputs.size() == 1); QVERIFY(stub->m_openInputs.at(0) == 3); ip->reconnect(); QVERIFY(ip->m_plugin == stub); QVERIFY(ip->m_input == 3); QVERIFY(ip->m_profile == &prof2); QVERIFY(ip->pluginName() == stub->name()); QVERIFY(ip->inputName() == stub->inputs()[3]); QVERIFY(ip->profileName() == prof2.name()); QVERIFY(stub->m_openInputs.size() == 1); QVERIFY(stub->m_openInputs.at(0) == 3); delete ip; QVERIFY(stub->m_openInputs.size() == 0); }
void InputPatch_Test::patch() { InputPluginStub stub; QLCInputProfile prof1; prof1.setManufacturer("Foo"); prof1.setManufacturer("Bar"); InputPatch* ip = new InputPatch(this); ip->set(&stub, 0, false, &prof1); QVERIFY(ip->m_plugin == &stub); QVERIFY(ip->m_input == 0); QVERIFY(ip->m_profile == &prof1); QVERIFY(ip->pluginName() == stub.name()); QVERIFY(ip->inputName() == stub.inputs()[0]); QVERIFY(ip->profileName() == prof1.name()); QVERIFY(stub.m_openLines.size() == 1); QVERIFY(stub.m_openLines.at(0) == 0); QVERIFY(ip->m_feedbackEnabled == false); QVERIFY(ip->feedbackEnabled() == false); QLCInputProfile prof2; prof2.setManufacturer("Xyzzy"); prof2.setManufacturer("Foobar"); ip->set(&stub, 3, true, &prof2); QVERIFY(ip->m_plugin == &stub); QVERIFY(ip->m_input == 3); QVERIFY(ip->m_profile == &prof2); QVERIFY(ip->pluginName() == stub.name()); QVERIFY(ip->inputName() == stub.inputs()[3]); QVERIFY(ip->profileName() == prof2.name()); QVERIFY(stub.m_openLines.size() == 1); QVERIFY(stub.m_openLines.at(0) == 3); QVERIFY(ip->m_feedbackEnabled == true); QVERIFY(ip->feedbackEnabled() == true); delete ip; QVERIFY(stub.m_openLines.size() == 0); }
InputOutputPatchEditor::InputOutputPatchEditor(QWidget* parent, quint32 universe, InputOutputMap *ioMap, Doc *doc) : QWidget(parent) , m_ioMap(ioMap) , m_doc(doc) , m_universe(universe) , m_currentInputPluginName(KInputNone) , m_currentInput(QLCIOPlugin::invalidLine()) , m_currentOutputPluginName(KOutputNone) , m_currentOutput(QLCIOPlugin::invalidLine()) , m_currentProfileName(KInputNone) , m_currentFeedbackPluginName(KOutputNone) , m_currentFeedback(QLCIOPlugin::invalidLine()) { Q_ASSERT(universe < m_ioMap->universes()); Q_ASSERT(ioMap != NULL); setupUi(this); m_infoBrowser->setOpenExternalLinks(true); m_infoBrowser->setFixedHeight(250); InputPatch* inputPatch = m_ioMap->inputPatch(universe); OutputPatch* outputPatch = m_ioMap->outputPatch(universe); OutputPatch* feedbackPatch = m_ioMap->feedbackPatch(universe); /* Copy these so they can be applied if the user cancels */ if (inputPatch != NULL) { m_currentInputPluginName = inputPatch->pluginName(); m_currentInput = inputPatch->input(); m_currentProfileName = inputPatch->profileName(); } if (outputPatch != NULL) { m_currentOutputPluginName = outputPatch->pluginName(); m_currentOutput = outputPatch->output(); } if (feedbackPatch != NULL) { m_currentFeedbackPluginName = feedbackPatch->pluginName(); m_currentFeedback = feedbackPatch->output(); } m_mapTree->setSortingEnabled(true); m_mapTree->sortByColumn(KMapColumnPluginName, Qt::AscendingOrder); /* Setup UI controls */ setupMappingPage(); setupProfilePage(); fillAudioTree(); /* Listen to itemChanged() signals to catch check state changes */ connect(m_audioMapTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotAudioDeviceItemChanged(QTreeWidgetItem*, int))); /* Select the top-most "None" item */ m_mapTree->setCurrentItem(m_mapTree->topLevelItem(0)); /* Listen to plugin configuration changes */ connect(m_ioMap, SIGNAL(pluginConfigurationChanged(const QString&)), this, SLOT(slotPluginConfigurationChanged(const QString&))); /* Listen to plugin configuration changes */ connect(m_ioMap, SIGNAL(pluginConfigurationChanged(const QString&)), this, SLOT(slotPluginConfigurationChanged(const QString&))); }
void InputPatch_Test::patch() { InputMap im(this); QDir dir(TESTPLUGINDIR); dir.setFilter(QDir::Files); dir.setNameFilters(QStringList() << QString("*%1").arg(KExtPlugin)); im.loadPlugins(dir); QVERIFY(im.m_plugins.size() > 0); InputPluginStub* stub = static_cast<InputPluginStub*> (im.m_plugins.at(0)); QVERIFY(stub != NULL); QLCInputProfile prof1; prof1.setManufacturer("Foo"); prof1.setManufacturer("Bar"); InputPatch* ip = new InputPatch(this); ip->set(stub, 0, false, &prof1); QVERIFY(ip->m_plugin == stub); QVERIFY(ip->m_input == 0); QVERIFY(ip->m_profile == &prof1); QVERIFY(ip->pluginName() == stub->name()); QVERIFY(ip->inputName() == stub->inputs()[0]); QVERIFY(ip->profileName() == prof1.name()); QVERIFY(stub->m_openLines.size() == 1); QVERIFY(stub->m_openLines.at(0) == 0); QVERIFY(ip->m_feedbackEnabled == false); QVERIFY(ip->feedbackEnabled() == false); QLCInputProfile prof2; prof2.setManufacturer("Xyzzy"); prof2.setManufacturer("Foobar"); ip->set(stub, 3, true, &prof2); QVERIFY(ip->m_plugin == stub); QVERIFY(ip->m_input == 3); QVERIFY(ip->m_profile == &prof2); QVERIFY(ip->pluginName() == stub->name()); QVERIFY(ip->inputName() == stub->inputs()[3]); QVERIFY(ip->profileName() == prof2.name()); QVERIFY(stub->m_openLines.size() == 1); QVERIFY(stub->m_openLines.at(0) == 3); QVERIFY(ip->m_feedbackEnabled == true); QVERIFY(ip->feedbackEnabled() == true); delete ip; QVERIFY(stub->m_openLines.size() == 0); }
void VCPropertiesEditor::updateHoldInputSource() { QLCInputProfile* profile; InputPatch* patch; QString uniName; QString chName; if (m_properties.holdInputUniverse() == KInputUniverseInvalid || m_properties.holdInputChannel() == KInputChannelInvalid) { /* Nothing selected for input universe and/or channel */ uniName = KInputNone; chName = KInputNone; /* Display the gathered information */ m_holdInputUniverseEdit->setText(uniName); m_holdInputChannelEdit->setText(chName); return; } patch = _app->inputMap()->patch(m_properties.holdInputUniverse()); if (patch == NULL || patch->plugin() == NULL) { /* There is no patch for the given universe */ uniName = KInputNone; chName = KInputNone; /* Display the gathered information */ m_holdInputUniverseEdit->setText(uniName); m_holdInputChannelEdit->setText(chName); return; } profile = patch->profile(); if (profile == NULL) { /* There is no profile. Display plugin name and channel number. Boring. */ uniName = patch->plugin()->name(); chName = tr("%1: Unknown") .arg(m_properties.holdInputChannel() + 1); } else { QString name; /* Display profile name for universe */ uniName = QString("%1: %2") .arg(m_properties.holdInputUniverse() + 1) .arg(profile->name()); /* User can input the channel number by hand, so put something rational to the channel name in those cases as well. */ name = profile->channelName(m_properties.holdInputChannel()); if (name == QString::null) name = tr("Unknown"); /* Display channel name */ chName = QString("%1: %2") .arg(m_properties.holdInputChannel() + 1).arg(name); } /* Display the gathered information */ m_holdInputUniverseEdit->setText(uniName); m_holdInputChannelEdit->setText(chName); }
void VCSliderProperties::updateInputSource() { QLCInputProfile* profile; InputPatch* patch; QString uniName; QString chName; if (m_inputUniverse == InputMap::invalidUniverse() || m_inputChannel == InputMap::invalidChannel()) { /* Nothing selected for input universe and/or channel */ uniName = KInputNone; chName = KInputNone; } else { patch = m_inputMap->patch(m_inputUniverse); if (patch == NULL || patch->plugin() == NULL) { /* There is no patch for the given universe */ uniName = KInputNone; chName = KInputNone; } else { profile = patch->profile(); if (profile == NULL) { /* There is no profile. Display plugin name and channel number. Boring. */ uniName = patch->plugin()->name(); chName = tr("%1: Unknown") .arg(m_inputChannel + 1); } else { QLCInputChannel* ich; QString name; /* Display profile name for universe */ uniName = QString("%1: %2") .arg(m_inputUniverse + 1) .arg(profile->name()); /* User can input the channel number by hand, so put something rational to the channel name in those cases as well. */ ich = profile->channel(m_inputChannel); if (ich != NULL) name = ich->name(); else name = tr("Unknown"); /* Display channel name */ chName = QString("%1: %2") .arg(m_inputChannel + 1).arg(name); } } } /* Display the gathered information */ m_inputUniverseEdit->setText(uniName); m_inputChannelEdit->setText(chName); }
mg_result WebAccess::websocketDataHandler(mg_connection *conn) { if (conn == NULL) return MG_TRUE; m_conn = conn; // store this to send VC loaded async event if (conn->content_len == 0) return MG_TRUE; QString qData = QString(conn->content); qData.truncate(conn->content_len); qDebug() << "[websocketDataHandler]" << qData; QStringList cmdList = qData.split("|"); if (cmdList.isEmpty()) return MG_TRUE; if(cmdList[0] == "QLC+CMD") { if (cmdList.count() < 2) return MG_FALSE; if(cmdList[1] == "opMode") emit toggleDocMode(); return MG_TRUE; } else if (cmdList[0] == "QLC+IO") { if (cmdList.count() < 3) return MG_FALSE; int universe = cmdList[2].toInt(); if (cmdList[1] == "INPUT") { m_doc->inputOutputMap()->setInputPatch(universe, cmdList[3], cmdList[4].toUInt()); m_doc->inputOutputMap()->saveDefaults(); } else if (cmdList[1] == "OUTPUT") { m_doc->inputOutputMap()->setOutputPatch(universe, cmdList[3], cmdList[4].toUInt(), false); m_doc->inputOutputMap()->saveDefaults(); } else if (cmdList[1] == "FB") { m_doc->inputOutputMap()->setOutputPatch(universe, cmdList[3], cmdList[4].toUInt(), true); m_doc->inputOutputMap()->saveDefaults(); } else if (cmdList[1] == "PROFILE") { InputPatch *inPatch = m_doc->inputOutputMap()->inputPatch(universe); if (inPatch != NULL) { m_doc->inputOutputMap()->setInputPatch(universe, inPatch->pluginName(), inPatch->input(), cmdList[3]); m_doc->inputOutputMap()->saveDefaults(); } } else if (cmdList[1] == "PASSTHROUGH") { quint32 uniIdx = cmdList[2].toUInt(); if (cmdList[3] == "true") m_doc->inputOutputMap()->setUniversePassthrough(uniIdx, true); else m_doc->inputOutputMap()->setUniversePassthrough(uniIdx, false); m_doc->inputOutputMap()->saveDefaults(); } else if (cmdList[1] == "AUDIOIN") { QSettings settings; if (cmdList[2] == "__qlcplusdefault__") settings.remove(SETTINGS_AUDIO_INPUT_DEVICE); else { settings.setValue(SETTINGS_AUDIO_INPUT_DEVICE, cmdList[2]); m_doc->destroyAudioCapture(); } } else if (cmdList[1] == "AUDIOOUT") { QSettings settings; if (cmdList[2] == "__qlcplusdefault__") settings.remove(SETTINGS_AUDIO_OUTPUT_DEVICE); else settings.setValue(SETTINGS_AUDIO_OUTPUT_DEVICE, cmdList[2]); } else qDebug() << "[webaccess] Command" << cmdList[1] << "not supported !"; return MG_TRUE; } #if defined(Q_WS_X11) || defined(Q_OS_LINUX) else if(cmdList[0] == "QLC+SYS") { if (cmdList.at(1) == "NETWORK") { if (m_netConfig->updateNetworkFile(cmdList) == true) { QString wsMessage = QString("ALERT|" + tr("Network configuration changed. Reboot to apply the changes.")); mg_websocket_write(m_conn, WEBSOCKET_OPCODE_TEXT, wsMessage.toUtf8().data(), wsMessage.length()); return MG_TRUE; } else qDebug() << "[webaccess] Error writing network configuration file !"; return MG_TRUE; } else if (cmdList.at(1) == "AUTOSTART") { if (cmdList.count() < 3) return MG_FALSE; QString asName = QString("%1/%2/%3").arg(getenv("HOME")).arg(USERQLCPLUSDIR).arg(AUTOSTART_PROJECT_NAME); if (cmdList.at(2) == "none") QFile::remove(asName); else emit storeAutostartProject(asName); QString wsMessage = QString("ALERT|" + tr("Autostart configuration changed")); mg_websocket_write(m_conn, WEBSOCKET_OPCODE_TEXT, wsMessage.toUtf8().data(), wsMessage.length()); return MG_TRUE; } else if (cmdList.at(1) == "REBOOT") { QProcess *rebootProcess = new QProcess(); rebootProcess->start("reboot", QStringList()); } else if (cmdList.at(1) == "HALT") { QProcess *haltProcess = new QProcess(); haltProcess->start("halt", QStringList()); } } #endif else if (cmdList[0] == "QLC+API") { if (cmdList.count() < 2) return MG_FALSE; QString apiCmd = cmdList[1]; // compose the basic API reply messages QString wsAPIMessage = QString("QLC+API|%1|").arg(apiCmd); if (apiCmd == "isProjectLoaded") { if (m_pendingProjectLoaded) { wsAPIMessage.append("true"); m_pendingProjectLoaded = false; } else wsAPIMessage.append("false"); } else if (apiCmd == "getFunctionsNumber") { wsAPIMessage.append(QString::number(m_doc->functions().count())); } else if (apiCmd == "getFunctionsList") { foreach(Function *f, m_doc->functions()) wsAPIMessage.append(QString("%1|%2|").arg(f->id()).arg(f->name())); // remove trailing separator wsAPIMessage.truncate(wsAPIMessage.length() - 1); } else if (apiCmd == "getFunctionType") { if (cmdList.count() < 3) return MG_FALSE; quint32 fID = cmdList[2].toUInt(); Function *f = m_doc->function(fID); if (f != NULL) wsAPIMessage.append(m_doc->function(fID)->typeString()); else wsAPIMessage.append(Function::typeToString(Function::Undefined)); } else if (apiCmd == "getFunctionStatus") { if (cmdList.count() < 3) return MG_FALSE; quint32 fID = cmdList[2].toUInt(); Function *f = m_doc->function(fID); if (f != NULL) { if (f->isRunning()) wsAPIMessage.append("Running"); else wsAPIMessage.append("Stopped"); } else wsAPIMessage.append(Function::typeToString(Function::Undefined)); } else if (apiCmd == "getWidgetsNumber") { VCFrame *mainFrame = m_vc->contents(); QList<VCWidget *> chList = mainFrame->findChildren<VCWidget*>(); wsAPIMessage.append(QString::number(chList.count())); } else if (apiCmd == "getWidgetsList") { VCFrame *mainFrame = m_vc->contents(); foreach(VCWidget *widget, mainFrame->findChildren<VCWidget*>()) wsAPIMessage.append(QString("%1|%2|").arg(widget->id()).arg(widget->caption())); // remove trailing separator wsAPIMessage.truncate(wsAPIMessage.length() - 1); } else if (apiCmd == "getWidgetType") { if (cmdList.count() < 3) return MG_FALSE; quint32 wID = cmdList[2].toUInt(); VCWidget *widget = m_vc->widget(wID); if (widget != NULL) wsAPIMessage.append(widget->typeToString(widget->type())); else wsAPIMessage.append(widget->typeToString(VCWidget::UnknownWidget)); } else if (apiCmd == "getWidgetStatus") { if (cmdList.count() < 3) return MG_FALSE; quint32 wID = cmdList[2].toUInt(); VCWidget *widget = m_vc->widget(wID); if (widget != NULL) { switch(widget->type()) { case VCWidget::ButtonWidget: { VCButton *button = qobject_cast<VCButton*>(widget); if (button->isOn()) wsAPIMessage.append("255"); else wsAPIMessage.append("0"); } break; case VCWidget::SliderWidget: { VCSlider *slider = qobject_cast<VCSlider*>(widget); wsAPIMessage.append(QString::number(slider->sliderValue())); } break; case VCWidget::CueListWidget: { VCCueList *cue = qobject_cast<VCCueList*>(widget); quint32 chaserID = cue->chaserID(); Function *f = m_doc->function(chaserID); if (f != NULL && f->isRunning()) wsAPIMessage.append(QString("PLAY|%2|").arg(cue->getCurrentIndex())); else wsAPIMessage.append("STOP"); } break; } } } else if (apiCmd == "getChannelsValues") { if (cmdList.count() < 4) return MG_FALSE; quint32 universe = cmdList[2].toUInt() - 1; int startAddr = cmdList[3].toInt() - 1; int count = 1; if (cmdList.count() == 5) count = cmdList[4].toInt(); wsAPIMessage.append(WebAccessSimpleDesk::getChannelsMessage(m_doc, m_sd, universe, startAddr, count)); } else if (apiCmd == "sdResetUniverse") { m_sd->resetUniverse(); wsAPIMessage = "QLC+API|getChannelsValues|"; wsAPIMessage.append(WebAccessSimpleDesk::getChannelsMessage( m_doc, m_sd, m_sd->getCurrentUniverseIndex(), 0, m_sd->getSlidersNumber())); } //qDebug() << "Simple desk channels:" << wsAPIMessage; mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, wsAPIMessage.toUtf8().data(), wsAPIMessage.length()); return MG_TRUE; } else if(cmdList[0] == "CH") { if (cmdList.count() < 3) return MG_FALSE; uint absAddress = cmdList[1].toInt() - 1; int value = cmdList[2].toInt(); m_sd->setAbsoluteChannelValue(absAddress, uchar(value)); return MG_TRUE; } else if(cmdList[0] == "POLL") return MG_TRUE; if (qData.contains("|") == false) return MG_FALSE; quint32 widgetID = cmdList[0].toUInt(); VCWidget *widget = m_vc->widget(widgetID); uchar value = 0; if (cmdList.count() > 1) value = (uchar)cmdList[1].toInt(); if (widget != NULL) { switch(widget->type()) { case VCWidget::ButtonWidget: { VCButton *button = qobject_cast<VCButton*>(widget); if ((value == 0 && button->isOn()) || (value != 0 && button->isOn() == false)) button->pressFunction(); } break; case VCWidget::SliderWidget: { VCSlider *slider = qobject_cast<VCSlider*>(widget); slider->setSliderValue(value); } break; case VCWidget::AudioTriggersWidget: { VCAudioTriggers *triggers = qobject_cast<VCAudioTriggers*>(widget); triggers->slotEnableButtonToggled(value ? true : false); } break; case VCWidget::CueListWidget: { if (cmdList.count() < 2) return MG_FALSE; VCCueList *cue = qobject_cast<VCCueList*>(widget); if (cmdList[1] == "PLAY") cue->slotPlayback(); else if (cmdList[1] == "PREV") cue->slotPreviousCue(); else if (cmdList[1] == "NEXT") cue->slotNextCue(); else if (cmdList[1] == "STEP") cue->playCueAtIndex(cmdList[2].toInt()); } break; case VCWidget::FrameWidget: case VCWidget::SoloFrameWidget: { VCFrame *frame = qobject_cast<VCFrame*>(widget); frame->blockSignals(true); if (cmdList[1] == "NEXT_PG") frame->slotNextPage(); else if (cmdList[1] == "PREV_PG") frame->slotPreviousPage(); frame->blockSignals(false); } break; default: break; } } return MG_TRUE; }