From 4f86bed02e83063d4f852a1003f0e5d44790bf92 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 9 Jan 2019 22:40:54 +0100 Subject: [PATCH] Only enable the queue button if we can actually queue something. --- futatabi/mainwindow.cpp | 30 ++++++++++++++++++++++++++++++ futatabi/mainwindow.h | 1 + 2 files changed, 31 insertions(+) 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 + ")")); diff --git a/futatabi/mainwindow.h b/futatabi/mainwindow.h index d7e037c..3628bf4 100644 --- a/futatabi/mainwindow.h +++ b/futatabi/mainwindow.h @@ -139,6 +139,7 @@ private: void highlight_camera_input(int stream_idx); void enable_or_disable_preview_button(); + void enable_or_disable_queue_button(); template void replace_model(QTableView *view, Model **model, Model *new_model); -- 2.39.2