]> git.sesse.net Git - nageru/commitdiff
Only enable the preview button if we can actually preview something.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 9 Jan 2019 21:34:09 +0000 (22:34 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 9 Jan 2019 21:36:10 +0000 (22:36 +0100)
futatabi/mainwindow.cpp
futatabi/mainwindow.h

index a7f6f82e87fc77b1ad88ca8c75572e301fb575d9..4a4c0d658f2a54f478d84847295020ec37888163 100644 (file)
@@ -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 + ")"));
index 8d286117e6a95d8f2998109ae656cd2df1d5bcca..d7e037c37ee7205a6c177d22509ce25f85fa990b 100644 (file)
@@ -138,6 +138,7 @@ private:
        void padding_toggled(double seconds, bool checked);
 
        void highlight_camera_input(int stream_idx);
+       void enable_or_disable_preview_button();
 
        template<class Model>
        void replace_model(QTableView *view, Model **model, Model *new_model);