]> git.sesse.net Git - nageru/commitdiff
Make it possible to hide displays (and re-show them again). Not persistent for now.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 17 Feb 2019 19:38:11 +0000 (20:38 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 17 Feb 2019 19:38:11 +0000 (20:38 +0100)
futatabi/mainwindow.cpp
futatabi/mainwindow.h
futatabi/mainwindow.ui

index 6c52109c07701efc0d9a5d5dcbddaba94c4f401b..fa93a7b458fe4982f3efd6f0f258ee7d78ebf036 100644 (file)
@@ -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) {
index 6e8f0c7b3dbe0b8c5ab7c6da0bd87d18f9c51ce5..7328a5e4bca0128cabc7dbaada2e70bc5eda4d30 100644 (file)
@@ -119,6 +119,7 @@ private:
                QFrame *frame;
                JPEGFrameView *display;
                QPushButton *preview_btn;
+               bool hidden = false;
        };
        std::vector<FrameAndDisplay> 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();
index 286c7e8e57dbcf3b6bba7d2356b7033c9354071d..e2653c7424ba274b8f943cd40089cbb03dd8ca1e 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1038</width>
+    <width>1061</width>
     <height>600</height>
    </rect>
   </property>
              <string>Next (N)</string>
             </property>
             <property name="icon">
-             <iconset theme="media-skip-forward"/>
+             <iconset theme="media-skip-forward">
+              <normaloff>.</normaloff>.</iconset>
             </property>
            </widget>
           </item>
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>1038</width>
+     <width>1061</width>
      <height>22</height>
     </rect>
    </property>
     <addaction name="undo_action"/>
     <addaction name="redo_action"/>
    </widget>
+   <widget class="QMenu" name="view_menu">
+    <property name="title">
+     <string>V&amp;iew</string>
+    </property>
+    <widget class="QMenu" name="hide_camera_menu">
+     <property name="title">
+      <string>&amp;Hide camera</string>
+     </property>
+    </widget>
+    <addaction name="hide_camera_menu"/>
+   </widget>
    <addaction name="menuFile"/>
+   <addaction name="view_menu"/>
    <addaction name="menu_Edit"/>
    <addaction name="menu_Help"/>
   </widget>