|
8 | 8 |
|
9 | 9 | #include "config.h" |
10 | 10 | #include "control/controlproxy.h" |
| 11 | +#include "controllers/controller.h" |
11 | 12 | #include "defs_urls.h" |
12 | 13 | #include "moc_wmainmenubar.cpp" |
13 | 14 | #include "util/cmdlineargs.h" |
@@ -470,6 +471,17 @@ void WMainMenuBar::initialize() { |
470 | 471 | pOptionsMenu->addSeparator(); |
471 | 472 | #endif |
472 | 473 |
|
| 474 | + // Controller Learning submenu |
| 475 | + m_pControllerLearningMenu = new QMenu(tr("&Controller Learning Wizard"), this); |
| 476 | + QString controllerLearningText = tr( |
| 477 | + "Open the MIDI learning wizard for an enabled controller"); |
| 478 | + m_pControllerLearningMenu->setStatusTip(controllerLearningText); |
| 479 | + m_pControllerLearningMenu->setWhatsThis(buildWhatsThis( |
| 480 | + tr("Controller Learning Wizard"), controllerLearningText)); |
| 481 | + // Menu will be populated dynamically with enabled controllers |
| 482 | + pOptionsMenu->addMenu(m_pControllerLearningMenu); |
| 483 | + pOptionsMenu->addSeparator(); |
| 484 | + |
473 | 485 | QString recordTitle = tr("&Record Mix"); |
474 | 486 | QString recordText = tr("Record your mix to a file"); |
475 | 487 | auto* pOptionsRecord = new QAction(recordTitle, this); |
@@ -998,3 +1010,35 @@ void VisibilityControlConnection::slotActionToggled(bool toggle) { |
998 | 1010 | m_pControl->set(toggle ? 1.0 : 0.0); |
999 | 1011 | } |
1000 | 1012 | } |
| 1013 | + |
| 1014 | +void WMainMenuBar::onControllersChanged(const QList<Controller*>& controllers) { |
| 1015 | + // Clear existing actions |
| 1016 | + for (QAction* pAction : std::as_const(m_controllerLearningActions)) { |
| 1017 | + m_pControllerLearningMenu->removeAction(pAction); |
| 1018 | + delete pAction; |
| 1019 | + } |
| 1020 | + m_controllerLearningActions.clear(); |
| 1021 | + |
| 1022 | + // Add menu item for each controller |
| 1023 | + for (Controller* pController : controllers) { |
| 1024 | + if (!pController) { |
| 1025 | + continue; |
| 1026 | + } |
| 1027 | + QString controllerName = pController->getName(); |
| 1028 | + auto* pAction = new QAction(controllerName, this); |
| 1029 | + pAction->setStatusTip(tr("Open learning wizard for %1").arg(controllerName)); |
| 1030 | + connect(pAction, &QAction::triggered, this, [this, pController]() { |
| 1031 | + emit openControllerLearningWizard(pController); |
| 1032 | + }); |
| 1033 | + m_pControllerLearningMenu->addAction(pAction); |
| 1034 | + m_controllerLearningActions.append(pAction); |
| 1035 | + } |
| 1036 | + |
| 1037 | + // Show "No controllers enabled" if list is empty |
| 1038 | + if (m_controllerLearningActions.isEmpty()) { |
| 1039 | + auto* pNoControllersAction = new QAction(tr("No controllers enabled"), this); |
| 1040 | + pNoControllersAction->setEnabled(false); |
| 1041 | + m_pControllerLearningMenu->addAction(pNoControllersAction); |
| 1042 | + m_controllerLearningActions.append(pNoControllersAction); |
| 1043 | + } |
| 1044 | +} |
0 commit comments