+
+void GLWidget::show_context_menu(int signal_num, const QPoint &pos)
+{
+ QPoint global_pos = mapToGlobal(pos);
+
+ QMenu menu;
+ QActionGroup group(&menu);
+
+ unsigned num_cards = global_mixer->get_num_cards();
+ unsigned current_card = global_mixer->map_signal(signal_num);
+ for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
+ QString description(QString::fromStdString(global_mixer->get_card_description(card_index)));
+ QAction *action = new QAction(description, &group);
+ action->setCheckable(true);
+ if (current_card == card_index) {
+ action->setChecked(true);
+ }
+ action->setData(card_index);
+ menu.addAction(action);
+ }
+ QAction *selected_item = menu.exec(global_pos);
+ if (selected_item) {
+ unsigned card_index = selected_item->data().toInt(nullptr);
+ global_mixer->set_signal_mapping(signal_num, card_index);
+ }
+}