X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mainwindow.cpp;h=7235e8e9c5d1c74dbd1d0e7237d0d03ac3ba7d89;hb=e7f9c69a5fe88a3fea5a7dc3ce71e7ed337bdbd7;hp=6c1c790b41f30098b428b8e6be9af3aaa72b94a1;hpb=9e47a2f661b9d292598ef0277e507458e3dad62f;p=nageru diff --git a/mainwindow.cpp b/mainwindow.cpp index 6c1c790..7235e8e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -414,6 +414,9 @@ void MainWindow::mixer_created(Mixer *mixer) analyzer.reset(new Analyzer); + global_mixer->set_theme_menu_callback(bind(&MainWindow::setup_theme_menu, this)); + setup_theme_menu(); + struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = schedule_cut_signal; @@ -808,6 +811,27 @@ 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(); + + 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); + }); + } + ui->menuBar->insertMenu(ui->menu_Help->menuAction(), theme_menu); + } +} + void MainWindow::limiter_threshold_knob_changed(int value) { float threshold_dbfs = value * 0.1f;