X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmainwindow.cpp;fp=nageru%2Fmainwindow.cpp;h=f33c57d6b2d24f6343c9bab2b04464e6ed489e8f;hb=f8da8feaff269b75480625e1384951c20c3a529d;hp=91234ceb23ff301b6194d9bda9b1f81fd0f7e34b;hpb=7a845519ce53c4efd5c5db9eb8fc815fdd69fe2f;p=nageru diff --git a/nageru/mainwindow.cpp b/nageru/mainwindow.cpp index 91234ce..f33c57d 100644 --- a/nageru/mainwindow.cpp +++ b/nageru/mainwindow.cpp @@ -881,22 +881,38 @@ void MainWindow::update_eq_label(unsigned bus_index, EQBand band, float gain_db) void MainWindow::setup_theme_menu() { - std::vector theme_menu_entries = global_mixer->get_theme_menu(); + Theme::MenuEntry *root_menu = global_mixer->get_theme_menu(); + // Remove the old menu, if any. if (theme_menu != nullptr) { ui->menuBar->removeAction(theme_menu->menuAction()); theme_menu = nullptr; } - if (!theme_menu_entries.empty()) { - theme_menu = new QMenu("&Theme"); - for (const Theme::MenuEntry &entry : theme_menu_entries) { - QAction *action = theme_menu->addAction(QString::fromStdString(entry.text)); - connect(action, &QAction::triggered, [entry] { - global_mixer->theme_menu_entry_clicked(entry.lua_ref); - }); + if (root_menu != nullptr) { + assert(root_menu->is_submenu); + if (!root_menu->submenu.empty()) { + theme_menu = new QMenu("&Theme"); + fill_menu_from_theme_menu(root_menu->submenu, theme_menu); + ui->menuBar->insertMenu(ui->menu_Help->menuAction(), theme_menu); + } + } +} + +void MainWindow::fill_menu_from_theme_menu(const vector> &entries, QMenu *menu) +{ + for (const unique_ptr &entry : entries) { + if (entry->is_submenu) { + QMenu *submenu = new QMenu(QString::fromStdString(entry->text)); + fill_menu_from_theme_menu(entry->submenu, submenu); + menu->addMenu(submenu); + continue; } - ui->menuBar->insertMenu(ui->menu_Help->menuAction(), theme_menu); + + QAction *action = menu->addAction(QString::fromStdString(entry->text)); + connect(action, &QAction::triggered, [lua_ref = entry->entry.lua_ref] { + global_mixer->theme_menu_entry_clicked(lua_ref); + }); } }