X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fmainwindow.cpp;h=6c52109c07701efc0d9a5d5dcbddaba94c4f401b;hb=5d52ea28eea891d2cd5b9485a1348ec7302df157;hp=a5592930e2a3217df0b980db3d65165a362c4781;hpb=82073bde10e2751e9e1376373e91c55ce38d1d9d;p=nageru diff --git a/futatabi/mainwindow.cpp b/futatabi/mainwindow.cpp index a559293..6c52109 100644 --- a/futatabi/mainwindow.cpp +++ b/futatabi/mainwindow.cpp @@ -205,6 +205,10 @@ MainWindow::MainWindow() connect(play, &QShortcut::activated, ui->play_btn, &QPushButton::click); connect(ui->play_btn, &QPushButton::clicked, this, &MainWindow::play_clicked); + QShortcut *next = new QShortcut(QKeySequence(Qt::Key_N), this); + connect(next, &QShortcut::activated, ui->next_btn, &QPushButton::click); + connect(ui->next_btn, &QPushButton::clicked, this, &MainWindow::next_clicked); + connect(ui->stop_btn, &QPushButton::clicked, this, &MainWindow::stop_clicked); ui->stop_btn->setEnabled(false); @@ -663,6 +667,11 @@ void MainWindow::play_clicked() playlist_selection_changed(); } +void MainWindow::next_clicked() +{ + live_player->skip_to_next(); +} + void MainWindow::stop_clicked() { Clip fake_clip; @@ -733,6 +742,7 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) { enable_or_disable_preview_button(); + playlist_selection_changed(); hidden_jog_column = -1; } @@ -932,7 +942,7 @@ void MainWindow::playlist_selection_changed() enable_or_disable_preview_button(); QItemSelectionModel *selected = ui->playlist->selectionModel(); - bool any_selected = selected->hasSelection(); + bool any_selected = ui->playlist->hasFocus() && selected->hasSelection(); ui->playlist_duplicate_btn->setEnabled(any_selected); ui->playlist_remove_btn->setEnabled(any_selected); ui->playlist_move_up_btn->setEnabled( @@ -941,6 +951,19 @@ void MainWindow::playlist_selection_changed() any_selected && selected->selectedRows().back().row() < int(playlist_clips->size()) - 1); ui->play_btn->setEnabled(any_selected); + ui->next_btn->setEnabled(ui->stop_btn->isEnabled()); // TODO: Perhaps not if we're on the last clip? + midi_mapper.set_next_ready(ui->next_btn->isEnabled() ? MIDIMapper::On : MIDIMapper::Off); + + // NOTE: The hidden button is still reachable by keyboard or MIDI. + if (any_selected) { + ui->play_btn->setVisible(true); + } else if (ui->stop_btn->isEnabled()) { // Playing. + ui->play_btn->setVisible(false); + } else { + ui->play_btn->setVisible(true); + } + ui->next_btn->setVisible(!ui->play_btn->isVisible()); + if (ui->stop_btn->isEnabled()) { // Playing. midi_mapper.set_play_enabled(MIDIMapper::On); } else if (any_selected) { @@ -1288,6 +1311,13 @@ void MainWindow::play() }); } +void MainWindow::next() +{ + post_to_main_thread([this] { + next_clicked(); + }); +} + void MainWindow::toggle_lock() { post_to_main_thread([this] {