X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fmainwindow.cpp;h=4a4c0d658f2a54f478d84847295020ec37888163;hb=f22a41cb05c5cc1bbe8ce391fa918707138afad3;hp=a7f6f82e87fc77b1ad88ca8c75572e301fb575d9;hpb=09b27ab32073dba2c565cdda43fcf2c37ea04a7b;p=nageru diff --git a/futatabi/mainwindow.cpp b/futatabi/mainwindow.cpp index a7f6f82..4a4c0d6 100644 --- a/futatabi/mainwindow.cpp +++ b/futatabi/mainwindow.cpp @@ -342,6 +342,8 @@ void MainWindow::queue_clicked() void MainWindow::preview_clicked() { + // See also enable_or_disable_preview_button(). + if (ui->playlist->hasFocus()) { // Allow the playlist as preview iff it has focus and something is selected. QItemSelectionModel *selected = ui->playlist->selectionModel(); @@ -575,6 +577,10 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) int scrub_sensitivity = 100; // pts units per pixel. int wheel_sensitivity = 100; // pts units per degree. + if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) { + enable_or_disable_preview_button(); + } + unsigned stream_idx = ui->preview_display->get_stream_idx(); if (watched == ui->clip_list) { @@ -809,6 +815,8 @@ void MainWindow::preview_single_frame(int64_t pts, unsigned stream_idx, MainWind void MainWindow::playlist_selection_changed() { + enable_or_disable_preview_button(); + QItemSelectionModel *selected = ui->playlist->selectionModel(); bool any_selected = selected->hasSelection(); ui->playlist_duplicate_btn->setEnabled(any_selected); @@ -1031,6 +1039,24 @@ void MainWindow::highlight_camera_input(int stream_idx) } } +void MainWindow::enable_or_disable_preview_button() +{ + // Follows the logic in preview_clicked(). + + if (ui->playlist->hasFocus()) { + // Allow the playlist as preview iff it has focus and something is selected. + // TODO: Is this part really relevant? + QItemSelectionModel *selected = ui->playlist->selectionModel(); + if (selected->hasSelection()) { + ui->preview_btn->setEnabled(true); + return; + } + } + + // TODO: Perhaps only enable this if something is actually selected. + ui->preview_btn->setEnabled(!cliplist_clips->empty()); +} + void MainWindow::set_output_status(const string &status) { ui->live_label->setText(QString::fromStdString("Current output (" + status + ")"));