From a8951813f5a69f17d044f8f723fc23702c0f7bc1 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 9 Feb 2023 13:21:51 +0000 Subject: [PATCH] Provisional support for knobs --- controllersetup.cpp | 98 ++++++++++++++++++---- controllersetup.h | 13 ++- usbcontroller.cpp | 61 ++++++++++++-- usbcontroller.h | 54 ++++++++---- wfmain.cpp | 196 +++++++++++++++++++++++++++++++------------- wfmain.h | 5 +- wfviewtypes.h | 1 + 7 files changed, 323 insertions(+), 105 deletions(-) diff --git a/controllersetup.cpp b/controllersetup.cpp index ffc72b0..4d161ba 100644 --- a/controllersetup.cpp +++ b/controllersetup.cpp @@ -16,6 +16,7 @@ controllerSetup::controllerSetup(QWidget* parent) : connect(&onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int))); connect(&offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int))); + connect(&knobEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(knobEventIndexChanged(int))); } controllerSetup::~controllerSetup() @@ -50,48 +51,80 @@ void controllerSetup::mousePressed(QPoint p) } onEvent.blockSignals(true); onEvent.move(p); - onEvent.setCurrentIndex(currentButton->onCommand->index); + onEvent.setCurrentIndex(onEvent.findData(currentButton->onCommand->index)); onEvent.show(); onEvent.blockSignals(false); p.setY(p.y() + 40); offEvent.blockSignals(true); offEvent.move(p); - offEvent.setCurrentIndex(currentButton->offCommand->index); + offEvent.setCurrentIndex(offEvent.findData(currentButton->offCommand->index)); offEvent.show(); offEvent.blockSignals(false); - + knobEvent.hide(); + break; + } + } + if (!found) { + for (KNOB& k : *knobs) + { + if (k.dev == currentDevice && k.pos.contains(p)) + { + found = true; + currentKnob = &k; + qDebug() << "Knob" << currentKnob->num << "Event" << currentKnob->command->text; + if (knobEventProxy == Q_NULLPTR) { + knobEventProxy = scene->addWidget(&knobEvent); + } + knobEvent.blockSignals(true); + knobEvent.move(p); + knobEvent.setCurrentIndex(knobEvent.findData(currentKnob->command->index)); + knobEvent.show(); + knobEvent.blockSignals(false); + onEvent.hide(); + offEvent.hide(); + break; + } } } if (!found) { onEvent.hide(); offEvent.hide(); + knobEvent.hide(); } - } void controllerSetup::onEventIndexChanged(int index) { - qDebug() << "On Event for button" << currentButton->num << "Event" << index; - if (currentButton != Q_NULLPTR && index < commands->size()) { - currentButton->onCommand = &commands->at(index); + Q_UNUSED(index); + if (currentButton != Q_NULLPTR && onEvent.currentData().toInt() < commands->size()) { + currentButton->onCommand = &commands->at(onEvent.currentData().toInt()); currentButton->onText->setPlainText(currentButton->onCommand->text); } } void controllerSetup::offEventIndexChanged(int index) { - qDebug() << "Off Event for button" << currentButton->num << "Event" << index; - if (currentButton != Q_NULLPTR && index < commands->size()) { - currentButton->offCommand = &commands->at(index); + Q_UNUSED(index); + if (currentButton != Q_NULLPTR && offEvent.currentData().toInt() < commands->size()) { + currentButton->offCommand = &commands->at(offEvent.currentData().toInt()); currentButton->offText->setPlainText(currentButton->offCommand->text); } } +void controllerSetup::knobEventIndexChanged(int index) { + Q_UNUSED(index); + if (currentKnob != Q_NULLPTR && knobEvent.currentData().toInt() < commands->size()) { + currentKnob->command = &commands->at(knobEvent.currentData().toInt()); + currentKnob->text->setPlainText(currentKnob->command->text); + } +} -void controllerSetup::newDevice(unsigned char devType, QVector