X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fmainwindow.cpp;h=b39d8d4a3e55290501216a499e4fddec38571ce7;hb=4f86bed02e83063d4f852a1003f0e5d44790bf92;hp=4a4c0d658f2a54f478d84847295020ec37888163;hpb=f22a41cb05c5cc1bbe8ce391fa918707138afad3;p=nageru diff --git a/futatabi/mainwindow.cpp b/futatabi/mainwindow.cpp index 4a4c0d6..b39d8d4 100644 --- a/futatabi/mainwindow.cpp +++ b/futatabi/mainwindow.cpp @@ -203,6 +203,7 @@ MainWindow::MainWindow() connect(ui->clip_list->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::clip_list_selection_changed); + enable_or_disable_queue_button(); // Find out how many cameras we have in the existing frames; // if none, we start with two cameras. @@ -285,6 +286,7 @@ void MainWindow::cue_in_clicked() QModelIndex index = cliplist_clips->index(cliplist_clips->size() - 1, int(ClipList::Column::IN)); ui->clip_list->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); ui->clip_list->scrollToBottom(); + enable_or_disable_queue_button(); } void MainWindow::cue_out_clicked() @@ -300,10 +302,13 @@ void MainWindow::cue_out_clicked() QModelIndex index = cliplist_clips->index(cliplist_clips->size() - 1, int(ClipList::Column::OUT)); ui->clip_list->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); ui->clip_list->scrollToBottom(); + enable_or_disable_queue_button(); } void MainWindow::queue_clicked() { + // See also enable_or_disable_queue_button(). + if (cliplist_clips->empty()) { return; } @@ -846,6 +851,7 @@ void MainWindow::clip_list_selection_changed(const QModelIndex ¤t, const Q camera_selected = current.column() - int(ClipList::Column::CAMERA_1); } highlight_camera_input(camera_selected); + enable_or_disable_queue_button(); } void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_left) @@ -1057,6 +1063,30 @@ void MainWindow::enable_or_disable_preview_button() ui->preview_btn->setEnabled(!cliplist_clips->empty()); } +void MainWindow::enable_or_disable_queue_button() +{ + // Follows the logic in queue_clicked(). + // TODO: Perhaps only enable this if something is actually selected. + + bool enabled; + + if (cliplist_clips->empty()) { + enabled = false; + } else { + QItemSelectionModel *selected = ui->clip_list->selectionModel(); + if (!selected->hasSelection()) { + Clip clip = *cliplist_clips->back(); + enabled = clip.pts_out != -1; + } else { + QModelIndex index = selected->currentIndex(); + Clip clip = *cliplist_clips->clip(index.row()); + enabled = clip.pts_out != -1; + } + } + + ui->queue_btn->setEnabled(enabled); +} + void MainWindow::set_output_status(const string &status) { ui->live_label->setText(QString::fromStdString("Current output (" + status + ")"));