X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mainwindow.cpp;h=537f8810acad38c26d4fdba0e3d3a2e60a08358a;hb=bc8e214a1e9f6d27055914901b660b6c9269d636;hp=37b3af11659c700a1d3cf674d20999024157e1c1;hpb=bb7eef2994e16fece998bc2c5cf42579d485d67b;p=nageru diff --git a/mainwindow.cpp b/mainwindow.cpp index 37b3af1..537f881 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,9 @@ #include "aboutdialog.h" #include "alsa_pool.h" +#include "analyzer.h" #include "clickable_label.h" +#include "context_menus.h" #include "correlation_meter.h" #include "disk_space_estimator.h" #include "ellipsis_label.h" @@ -196,18 +199,30 @@ MainWindow::MainWindow() // The menus. connect(ui->cut_action, &QAction::triggered, this, &MainWindow::cut_triggered); connect(ui->exit_action, &QAction::triggered, this, &MainWindow::exit_triggered); + connect(ui->manual_action, &QAction::triggered, this, &MainWindow::manual_triggered); connect(ui->about_action, &QAction::triggered, this, &MainWindow::about_triggered); + connect(ui->open_analyzer_action, &QAction::triggered, this, &MainWindow::open_analyzer_triggered); connect(ui->simple_audio_mode, &QAction::triggered, this, &MainWindow::simple_audio_mode_triggered); connect(ui->multichannel_audio_mode, &QAction::triggered, this, &MainWindow::multichannel_audio_mode_triggered); connect(ui->input_mapping_action, &QAction::triggered, this, &MainWindow::input_mapping_triggered); connect(ui->midi_mapping_action, &QAction::triggered, this, &MainWindow::midi_mapping_triggered); + connect(ui->timecode_stream_action, &QAction::triggered, this, &MainWindow::timecode_stream_triggered); + connect(ui->timecode_stdout_action, &QAction::triggered, this, &MainWindow::timecode_stdout_triggered); - if (global_flags.x264_video_to_http) { + ui->timecode_stream_action->setChecked(global_flags.display_timecode_in_stream); + ui->timecode_stdout_action->setChecked(global_flags.display_timecode_on_stdout); + + if (global_flags.x264_video_to_http && isinf(global_flags.x264_crf)) { connect(ui->x264_bitrate_action, &QAction::triggered, this, &MainWindow::x264_bitrate_triggered); } else { ui->x264_bitrate_action->setEnabled(false); } + connect(ui->video_menu, &QMenu::aboutToShow, [this]{ + fill_hdmi_sdi_output_device_menu(ui->hdmi_sdi_output_device_menu); + fill_hdmi_sdi_output_resolution_menu(ui->hdmi_sdi_output_resolution_menu); + }); + // Hook up the transition buttons. (Keyboard shortcuts are set in set_transition_names().) // TODO: Make them dynamic. connect(ui->transition_btn1, &QPushButton::clicked, bind(&MainWindow::transition_clicked, this, 0)); @@ -367,6 +382,8 @@ void MainWindow::mixer_created(Mixer *mixer) midi_mapper.refresh_lights(); midi_mapper.start_thread(); + analyzer.reset(new Analyzer); + struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = schedule_cut_signal; @@ -536,11 +553,14 @@ void MainWindow::setup_audio_expanded_view() void MainWindow::mixer_shutting_down() { - ui->me_live->clean_context(); - ui->me_preview->clean_context(); + ui->me_live->shutdown(); + ui->me_preview->shutdown(); + for (Ui::Display *display : previews) { - display->display->clean_context(); + display->display->shutdown(); } + + analyzer->mixer_shutting_down(); } void MainWindow::cut_triggered() @@ -563,11 +583,25 @@ void MainWindow::exit_triggered() close(); } +void MainWindow::manual_triggered() +{ + if (!QDesktopServices::openUrl(QUrl("https://nageru.sesse.net/doc/"))) { + QMessageBox msgbox; + msgbox.setText("Could not launch manual in web browser.\nPlease see https://nageru.sesse.net/doc/ manually."); + msgbox.exec(); + } +} + void MainWindow::about_triggered() { AboutDialog().exec(); } +void MainWindow::open_analyzer_triggered() +{ + analyzer->show(); +} + void MainWindow::simple_audio_mode_triggered() { if (global_audio_mixer->get_mapping_mode() == AudioMixer::MappingMode::SIMPLE) { @@ -620,6 +654,16 @@ void MainWindow::midi_mapping_triggered() MIDIMappingDialog(&midi_mapper).exec(); } +void MainWindow::timecode_stream_triggered() +{ + global_mixer->set_display_timecode_in_stream(ui->timecode_stream_action->isChecked()); +} + +void MainWindow::timecode_stdout_triggered() +{ + global_mixer->set_display_timecode_on_stdout(ui->timecode_stdout_action->isChecked()); +} + void MainWindow::gain_staging_knob_changed(unsigned bus_index, int value) { if (bus_index == 0) { @@ -855,9 +899,9 @@ void MainWindow::relayout() double remaining_height = height; // Allocate the height; the most important part is to keep the main displays - // at 16:9 if at all possible. + // at the right aspect if at all possible. double me_width = ui->me_preview->width(); - double me_height = me_width * 9.0 / 16.0 + ui->label_preview->height() + ui->preview_vertical_layout->spacing(); + double me_height = me_width * double(global_flags.height) / double(global_flags.width) + ui->label_preview->height() + ui->preview_vertical_layout->spacing(); // TODO: Scale the widths when we need to do this. if (me_height / double(height) > 0.8) { @@ -877,7 +921,7 @@ void MainWindow::relayout() double preview_label_height = previews[0]->title_bar->geometry().height() + previews[0]->main_vertical_layout->spacing(); int preview_total_width = ui->preview_displays->geometry().width() - (previews.size() - 1) * ui->preview_displays->spacing(); - double preview_height = min(remaining_height - preview_label_height, (preview_total_width / double(previews.size())) * 9.0 / 16.0); + double preview_height = min(remaining_height - preview_label_height, (preview_total_width / double(previews.size())) * double(global_flags.height) / double(global_flags.width)); remaining_height -= preview_height + preview_label_height + ui->vertical_layout->spacing(); ui->vertical_layout->setStretch(0, lrintf(me_height)); @@ -891,7 +935,7 @@ void MainWindow::relayout() ui->compact_audio_layout->setStretch(2, lrintf(preview_height + preview_label_height)); // Set the widths for the previews. - double preview_width = preview_height * 16.0 / 9.0; + double preview_width = preview_height * double(global_flags.width) / double(global_flags.height); for (unsigned i = 0; i < previews.size(); ++i) { ui->preview_displays->setStretch(i, lrintf(preview_width)); } @@ -1210,6 +1254,8 @@ void MainWindow::update_channel_name(Mixer::Output output, const string &name) unsigned channel = output - Mixer::OUTPUT_INPUT0; previews[channel]->label->setText(name.c_str()); } + + analyzer->update_channel_name(output, name); } void MainWindow::update_channel_color(Mixer::Output output, const string &color) @@ -1259,6 +1305,12 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) return false; } +void MainWindow::closeEvent(QCloseEvent *event) +{ + analyzer->hide(); + event->accept(); +} + namespace { double srgb_to_linear(double x)