void WaveformMarkSet::setup(const QString& group, const QDomNode& node, const WaveformSignalColors& signalColors) { m_defaultMark = WaveformMark(); m_marks.clear(); m_defaultMark = WaveformMark(); m_marks.clear(); #if QT_VERSION >= 0x040700 m_marks.reserve(NUM_HOT_CUES); #endif std::set<QString> controlItemSet; bool hasDefaultMark = false; QDomNode child = node.firstChild(); while (!child.isNull()) { if (child.nodeName() == "DefaultMark") { m_defaultMark.setup(group, child, signalColors); hasDefaultMark = true; } else if (child.nodeName() == "Mark") { m_marks.push_back(WaveformMark()); WaveformMark& mark = m_marks.back(); mark.setup(group, child, signalColors); if (mark.m_pointControl) { // guarantee uniqueness even if there is a misdesigned skin QString item = mark.m_pointControl->getKey().item; if (!controlItemSet.insert(item).second) { qWarning() << "WaveformRenderMark::setup - redefinition of" << item; m_marks.removeAt(m_marks.size() - 1); } } } child = child.nextSibling(); } //check if there is a default mark and compare declared //and to create all missing hot_cues if (hasDefaultMark) { for (int i = 1; i < NUM_HOT_CUES; ++i) { QString hotCueControlItem = "hotcue_" + QString::number(i) + "_position"; ControlObject* pHotcue = ControlObject::getControl( ConfigKey(group, hotCueControlItem)); if (pHotcue == NULL) { continue; } if (controlItemSet.insert(hotCueControlItem).second) { //qDebug() << "WaveformRenderMark::setup - Automatic mark" << hotCueControlItem; m_marks.push_back(m_defaultMark); WaveformMark& mark = m_marks.back(); mark.m_pointControl = new ControlObjectThreadMain(pHotcue->getKey()); mark.m_text = mark.m_text.arg(i); } } } }
void LADSPAPresetInstance::addControl(int i, LADSPAPresetKnob * knob, EngineLADSPA * engine) { ConfigKey * key = new ConfigKey("[LADSPA]", knob->getLabel()); ControlObject * potmeter = new ControlPotmeter(*key, knob->getMin(), knob->getMax()); ControlObjectThreadMain * potmeterThreadMain = new ControlObjectThreadMain(potmeter->getKey()); LADSPAControl * control = new LADSPAControl; control->setValue(knob->getDefault()); potmeterThreadMain->slotSet(knob->getDefault()); m_Keys[i] = key; LADSPAPortConnectionVector * portConnections = knob->getConnections(); for (LADSPAPortConnectionVector::iterator connection = portConnections->begin(); connection != portConnections->end(); connection++) { m_Instances[(*connection).plugin]->connect((*connection).port, control->getBuffer()); } m_Connections[i] = engine->addControl(potmeter, control); }
bool ControllerLearningEventFilter::eventFilter(QObject* pObject, QEvent* pEvent) { //qDebug() << "ControllerLearningEventFilter::eventFilter" << pObject << pEvent; WWidget* pWidget = dynamic_cast<WWidget*>(pObject); if (!pWidget || !m_bListening) { return false; } WKnob* pKnob = dynamic_cast<WKnob*>(pObject); WSliderComposed* pSlider = dynamic_cast<WSliderComposed*>(pObject); bool has_right_click_reset = pKnob || pSlider; if (pEvent->type() == QEvent::KeyPress) { // TODO(XXX): handle keypresses? } else if (pEvent->type() == QEvent::MouseButtonPress) { QMouseEvent* mouseEvent = reinterpret_cast<QMouseEvent*>(pEvent); qDebug() << "MouseButtonPress" << pWidget; const ControlInfo& info = m_widgetControlInfo[pWidget]; if (mouseEvent->button() & Qt::LeftButton) { if (info.leftClickControl) { ConfigKey key = info.leftClickControl->getKey(); qDebug() << "Left-click maps MIDI to:" << key.group << key.item; emit(controlClicked(info.leftClickControl)); } else if (info.clickControl) { ConfigKey key = info.clickControl->getKey(); emit(controlClicked(info.clickControl)); qDebug() << "Default-click maps MIDI to:" << key.group << key.item; } else { qDebug() << "No control bound to left-click for" << pWidget; } } if (mouseEvent->button() & Qt::RightButton) { if (info.rightClickControl) { ConfigKey key = info.rightClickControl->getKey(); qDebug() << "Right-click maps MIDI to:" << key.group << key.item; emit(controlClicked(info.rightClickControl)); } else if (has_right_click_reset && (info.leftClickControl || info.clickControl)) { // WKnob and WSliderComposed emits a reset signal on // right-click. For controls that are derived from // ControlPotmeter, we can hack this by appending "_set_default" // to the ConfigKey item. ControlObject* pControl = info.leftClickControl; if (!pControl) { pControl = info.clickControl; } ConfigKey key = pControl->getKey(); key.item = key.item + "_set_default"; ControlObject* pResetControl = ControlObject::getControl(key); if (pResetControl) { qDebug() << "Right-click reset maps MIDI to:" << key.group << key.item; emit(controlClicked(pResetControl)); } } else if (info.clickControl) { ConfigKey key = info.clickControl->getKey(); qDebug() << "Default-click maps MIDI to:" << key.group << key.item; emit(controlClicked(info.clickControl)); } else { qDebug() << "No control bound to right-click for" << pWidget; } } } else if (pEvent->type() == QEvent::MouseButtonRelease) { qDebug() << "MouseButtonRelease" << pWidget; } else if (pEvent->type() == QEvent::MouseMove) { qDebug() << "MouseMoveEvent" << pWidget; } return false; }