From: Steinar H. Gunderson Date: Sun, 17 Feb 2019 19:38:11 +0000 (+0100) Subject: Make it possible to hide displays (and re-show them again). Not persistent for now. X-Git-Tag: 1.8.3~34 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=b3fa9338f37e8c7e2bb9ca07d3417a909fcc6d6e Make it possible to hide displays (and re-show them again). Not persistent for now. --- diff --git a/futatabi/mainwindow.cpp b/futatabi/mainwindow.cpp index 6c52109..fa93a7b 100644 --- a/futatabi/mainwindow.cpp +++ b/futatabi/mainwindow.cpp @@ -301,9 +301,17 @@ void MainWindow::change_num_cameras() { assert(num_cameras >= displays.size()); // We only add, never remove. + // Make new entries to hide the displays. + for (unsigned i = displays.size(); i < num_cameras; ++i) { + char title[256]; + snprintf(title, sizeof(title), "Camera %u", i + 1); + QAction *hide_action = ui->hide_camera_menu->addAction(title); + hide_action->setCheckable(true); + hide_action->setChecked(false); + connect(hide_action, &QAction::toggled, bind(&MainWindow::hide_camera_toggled, this, i, _1)); + } + // Make new display rows. - unsigned display_rows = (num_cameras + 1) / 2; - ui->video_displays->setStretch(1, display_rows); for (unsigned i = displays.size(); i < num_cameras; ++i) { QFrame *frame = new QFrame(this); frame->setAutoFillBackground(true); @@ -316,7 +324,6 @@ void MainWindow::change_num_cameras() display->setAutoFillBackground(true); layout->addWidget(display); - ui->input_displays->addWidget(frame, i / 2, i % 2); display->set_overlay(to_string(i + 1)); QPushButton *preview_btn = new QPushButton(this); @@ -324,7 +331,7 @@ void MainWindow::change_num_cameras() preview_btn->setText(QString::fromStdString(to_string(i + 1))); ui->preview_layout->addWidget(preview_btn); - displays.emplace_back(FrameAndDisplay{ frame, display, preview_btn }); + displays.emplace_back(FrameAndDisplay{ frame, display, preview_btn, /*hidden=*/false }); connect(display, &JPEGFrameView::clicked, preview_btn, &QPushButton::click); QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this); @@ -332,6 +339,7 @@ void MainWindow::change_num_cameras() connect(preview_btn, &QPushButton::clicked, [this, i] { preview_angle_clicked(i); }); } + relayout_displays(); cliplist_clips->change_num_cameras(num_cameras); playlist_clips->change_num_cameras(num_cameras); @@ -339,6 +347,28 @@ void MainWindow::change_num_cameras() QMetaObject::invokeMethod(this, "relayout", Qt::QueuedConnection); } +void MainWindow::relayout_displays() +{ + while (ui->input_displays->count() > 0) { + QLayoutItem *item = ui->input_displays->takeAt(0); + ui->input_displays->removeWidget(item->widget()); + } + + unsigned cell_idx = 0; + for (unsigned i = 0; i < displays.size(); ++i) { + if (displays[i].hidden) { + displays[i].frame->setVisible(false); + } else { + displays[i].frame->setVisible(true); + ui->input_displays->addWidget(displays[i].frame, cell_idx / 2, cell_idx % 2); + ++cell_idx; + } + } + ui->video_displays->setStretch(1, (cell_idx + 1) / 2); + + QMetaObject::invokeMethod(this, "relayout", Qt::QueuedConnection); +} + MainWindow::~MainWindow() { // We don't have a context to release Player's OpenGL resources in here, @@ -1197,6 +1227,12 @@ void MainWindow::out_padding_toggled(double seconds, bool checked) save_settings(); } +void MainWindow::hide_camera_toggled(unsigned camera_idx, bool checked) +{ + displays[camera_idx].hidden = checked; + relayout_displays(); +} + void MainWindow::highlight_camera_input(int stream_idx) { for (unsigned i = 0; i < num_cameras; ++i) { diff --git a/futatabi/mainwindow.h b/futatabi/mainwindow.h index 6e8f0c7..7328a5e 100644 --- a/futatabi/mainwindow.h +++ b/futatabi/mainwindow.h @@ -119,6 +119,7 @@ private: QFrame *frame; JPEGFrameView *display; QPushButton *preview_btn; + bool hidden = false; }; std::vector displays; @@ -129,6 +130,7 @@ private: MIDIMapper midi_mapper; void change_num_cameras(); + void relayout_displays(); void cue_in_clicked(); void cue_out_clicked(); void queue_clicked(); @@ -181,6 +183,7 @@ private: void quality_toggled(int quality, bool checked); void in_padding_toggled(double seconds, bool checked); void out_padding_toggled(double seconds, bool checked); + void hide_camera_toggled(unsigned camera_idx, bool checked); void highlight_camera_input(int stream_idx); void enable_or_disable_preview_button(); diff --git a/futatabi/mainwindow.ui b/futatabi/mainwindow.ui index 286c7e8..e2653c7 100644 --- a/futatabi/mainwindow.ui +++ b/futatabi/mainwindow.ui @@ -6,7 +6,7 @@ 0 0 - 1038 + 1061 600 @@ -217,7 +217,8 @@ Next (N) - + + .. @@ -364,7 +365,7 @@ 0 0 - 1038 + 1061 22 @@ -429,7 +430,19 @@ + + + V&iew + + + + &Hide camera + + + + +