]> git.sesse.net Git - nageru/blobdiff - futatabi/mainwindow.cpp
Fix a dangling reference (found by GCC 14).
[nageru] / futatabi / mainwindow.cpp
index a479a7389b41bc800fd6fc9696053ecdd66f74ad..29eeb756655f5ea85d0099b2b068ee116861c8eb 100644 (file)
@@ -7,6 +7,7 @@
 #include "player.h"
 #include "futatabi_midi_mapping.pb.h"
 #include "midi_mapping_dialog.h"
+#include "pbo_pool.h"
 #include "shared/aboutdialog.h"
 #include "shared/disk_space_estimator.h"
 #include "shared/post_to_main_thread.h"
@@ -324,7 +325,11 @@ void MainWindow::change_num_cameras()
                display->setAutoFillBackground(true);
                layout->addWidget(display);
 
-               display->set_overlay(to_string(i + 1));
+               if (global_flags.source_labels.count(i + 1)) {
+                       display->set_overlay(global_flags.source_labels[i + 1]);
+               } else {
+                       display->set_overlay(to_string(i + 1));
+               }
 
                QPushButton *preview_btn = new QPushButton(this);
                preview_btn->setMaximumSize(20, 17);
@@ -388,6 +393,10 @@ void MainWindow::cue_in_clicked()
                playlist_selection_changed();
        }
 
+       // Show the clip in the preview.
+       unsigned stream_idx = ui->preview_display->get_stream_idx();
+       preview_single_frame(cliplist_clips->mutable_back()->pts_in, stream_idx, FIRST_AT_OR_AFTER);
+
        // Select the item so that we can jog it.
        ui->clip_list->setFocus();
        QModelIndex index = cliplist_clips->index(cliplist_clips->size() - 1, int(ClipList::Column::IN));
@@ -404,6 +413,10 @@ void MainWindow::cue_out_clicked()
 
        cliplist_clips->mutable_back()->pts_out = current_pts + lrint(global_flags.cue_out_point_padding_seconds * TIMEBASE);
 
+       // Show the clip in the preview. (TODO: This won't take padding into account.)
+       unsigned stream_idx = ui->preview_display->get_stream_idx();
+       preview_single_frame(cliplist_clips->mutable_back()->pts_out, stream_idx, LAST_BEFORE);
+
        // Select the item so that we can jog it.
        ui->clip_list->setFocus();
        QModelIndex index = cliplist_clips->index(cliplist_clips->size() - 1, int(ClipList::Column::OUT));
@@ -437,9 +450,6 @@ void MainWindow::queue_clicked()
        } else {
                clip.stream_idx = ui->preview_display->get_stream_idx();
        }
-       if (clip.pts_out == -1) {
-               clip.pts_out = clip.pts_in + int64_t(TIMEBASE) * 86400 * 7;  // One week; effectively infinite, but without overflow issues.
-       }
 
        playlist_clips->add_clip(clip);
        playlist_selection_changed();
@@ -624,10 +634,7 @@ void MainWindow::defer_timer_expired()
 void MainWindow::content_changed()
 {
        // If we are playing, update the part of the playlist that's not playing yet.
-       vector<ClipWithID> clips;
-       for (unsigned row = 0; row < playlist_clips->size(); ++row) {
-               clips.emplace_back(*playlist_clips->clip_with_id(row));
-       }
+       vector<ClipWithID> clips = get_playlist(0, playlist_clips->size());
        live_player->splice_play(clips);
 
        // Serialize the state.
@@ -688,14 +695,7 @@ void MainWindow::play_clicked()
        }
        unsigned start_row = selected->selectedRows(0)[0].row();
 
-       vector<ClipWithID> clips;
-       for (unsigned row = start_row; row < playlist_clips->size(); ++row) {
-               ClipWithID clip = *playlist_clips->clip_with_id(row);
-               if (clip.clip.pts_out == -1) {
-                       clip.clip.pts_out = clip.clip.pts_in + int64_t(TIMEBASE) * 86400 * 7;  // One week; effectively infinite, but without overflow issues.
-               }
-               clips.emplace_back(clip);
-       }
+       vector<ClipWithID> clips = get_playlist(start_row, playlist_clips->size());
        live_player->play(clips);
        playlist_clips->set_progress({ { start_row, 0.0f } });
        ui->playlist->selectionModel()->clear();
@@ -928,7 +928,7 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
                } else if (watched == ui->playlist->viewport()) {
                        destination = ui->playlist;
                        jog_destination = JOG_PLAYLIST;
-                       if (destination->columnAt(wheel->x()) != int(PlayList::Column::CAMERA)) {
+                       if (destination->columnAt(wheel->position().x()) != int(PlayList::Column::CAMERA)) {
                                last_mousewheel_camera_row = -1;
                        }
                } else {
@@ -936,8 +936,8 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
                        return false;
                }
 
-               int column = destination->columnAt(wheel->x());
-               int row = destination->rowAt(wheel->y());
+               int column = destination->columnAt(wheel->position().x());
+               int row = destination->rowAt(wheel->position().y());
                if (column == -1 || row == -1)
                        return false;
 
@@ -1049,6 +1049,19 @@ void MainWindow::clip_list_selection_changed(const QModelIndex &current, const Q
        enable_or_disable_queue_button();
 }
 
+vector<ClipWithID> MainWindow::get_playlist(size_t start_row, size_t end_row)
+{
+       vector<ClipWithID> clips;
+       for (unsigned row = start_row; row < end_row; ++row) {
+               ClipWithID clip = *playlist_clips->clip_with_id(row);
+               if (clip.clip.pts_out == -1) {
+                       clip.clip.pts_out = clip.clip.pts_in + int64_t(TIMEBASE) * 86400 * 7;  // One week; effectively infinite, but without overflow issues.
+               }
+               clips.emplace_back(clip);
+       }
+       return clips;
+}
+
 void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_left)
 {
        char time_str[256];