Skip to content

Commit

Permalink
Control picker menu: group samplers >16 into submenus
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jan 31, 2024
1 parent d684c65 commit 186f166
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1479,14 +1479,23 @@ void ControlPickerMenu::addPlayerControl(const QString& control,
}

if (samplerControls) {
QMenu* samplerControlMenu = new QMenu(tr("Samplers"), controlMenu);
controlMenu->addMenu(samplerControlMenu);
QMenu* samplerControlMainMenu = addSubmenu(tr("Samplers"), controlMenu);
QMenu* samplerControlMenu = samplerControlMainMenu;
QMenu* samplerResetControlMainMenu = nullptr;
QMenu* samplerResetControlMenu = nullptr;
if (resetControlMenu) {
samplerResetControlMenu = new QMenu(tr("Samplers"), resetControlMenu);
resetControlMenu->addMenu(samplerResetControlMenu);
samplerResetControlMainMenu = addSubmenu(tr("Samplers"), resetControlMenu);
samplerResetControlMenu = samplerResetControlMainMenu;
}
const int maxSamplersPerMenu = 16;
int counter = 1;
QString submenuLabel;
for (int i = 1; i <= iNumSamplers; ++i) {
if (counter > maxSamplersPerMenu) {
int limit = iNumSamplers > i + 16 ? i + 16 : iNumSamplers;
submenuLabel = m_samplerStr.arg(i) + QStringLiteral("- %1").arg(limit);
samplerControlMenu = addSubmenu(submenuLabel, samplerControlMainMenu);
}
// PlayerManager::groupForSampler is 0-indexed.
QString prefix = m_samplerStr.arg(i);
QString group = PlayerManager::groupForSampler(i - 1);
Expand All @@ -1499,6 +1508,9 @@ void ControlPickerMenu::addPlayerControl(const QString& control,
prefix);

if (resetControlMenu) {
if (counter > maxSamplersPerMenu) {
samplerResetControlMenu = addSubmenu(submenuLabel, samplerResetControlMainMenu);
}
QString resetTitle = QString("%1 (%2)").arg(controlTitle, m_resetStr);
QString resetDescription = QString("%1 (%2)").arg(controlDescription, m_resetStr);
addSingleControl(group,
Expand All @@ -1509,6 +1521,10 @@ void ControlPickerMenu::addPlayerControl(const QString& control,
prefix,
prefix);
}
if (counter > maxSamplersPerMenu) {
counter = 1;
}
counter++;
}
}
}
Expand Down

0 comments on commit 186f166

Please sign in to comment.