X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=glwidget.cpp;fp=glwidget.cpp;h=5a1325803a283fad20cf8be86478d94945b66ca5;hb=1202ad9167357a461366dab9cbbaa6c578423253;hp=9215fcad2219360a047e5878d61b0b77b0335c62;hpb=52e243fee63f15d7cc57ec24b72bcef5a3f0adcd;p=nageru diff --git a/glwidget.cpp b/glwidget.cpp index 9215fca..5a13258 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -144,6 +144,7 @@ void GLWidget::show_context_menu(unsigned signal_num, const QPoint &pos) QActionGroup mode_group(&mode_submenu); std::map video_modes = global_mixer->get_available_video_modes(current_card); uint32_t current_video_mode = global_mixer->get_current_video_mode(current_card); + bool has_auto_mode = false; for (const auto &mode : video_modes) { QString description(QString::fromStdString(mode.second.name)); QAction *action = new QAction(description, &mode_group); @@ -153,6 +154,19 @@ void GLWidget::show_context_menu(unsigned signal_num, const QPoint &pos) } action->setData(QList{"video_mode", mode.first}); mode_submenu.addAction(action); + + // TODO: Relying on the 0 value here (from bmusb.h) is ugly, it should be a named constant. + if (mode.first == 0) { + has_auto_mode = true; + } + } + + // Add a “scan” menu if there's no “auto” mode. + if (!has_auto_mode) { + QAction *action = new QAction("Scan", &mode_group); + action->setData(QList{"video_mode", 0}); + mode_submenu.addSeparator(); + mode_submenu.addAction(action); } mode_submenu.setTitle("Input mode"); @@ -175,7 +189,11 @@ void GLWidget::show_context_menu(unsigned signal_num, const QPoint &pos) QList selected = selected_item->data().toList(); if (selected[0].toString() == "video_mode") { uint32_t mode = selected[1].toUInt(nullptr); - global_mixer->set_video_mode(current_card, mode); + if (mode == 0 && !has_auto_mode) { + global_mixer->start_mode_scanning(current_card); + } else { + global_mixer->set_video_mode(current_card, mode); + } } else if (selected[0].toString() == "card") { unsigned card_index = selected[1].toUInt(nullptr); global_mixer->set_signal_mapping(signal_num, card_index);