Skip to content

Commit

Permalink
fix: Only resume playing the composition after canceling the *OpenCom…
Browse files Browse the repository at this point in the history
…position* dialog if the composition was playing before
  • Loading branch information
SebiAi committed Jan 25, 2024
1 parent c00897b commit 07f1741
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ void MainWindow::button_onClicked(bool checked)

void MainWindow::openFileAction_onTriggered(bool checked)
{
// Save the playing state
this->playerWasPlayingBefore = this->glyphWidget->compositionManager->player->isPlaying();

// Pause the player
this->glyphWidget->compositionManager->player->pause();

Expand Down Expand Up @@ -336,8 +339,9 @@ void MainWindow::openCompositionDialog_onFinished(int result)
processOpenCompositionDialogAccepted(this->openCompositionDialog->openModeResult, this->openCompositionDialog->row0Result, this->openCompositionDialog->row1Result);
break;
case QDialog::DialogCode::Rejected: // == 1
// Resume playing the composition
this->glyphWidget->compositionManager->player->play();
// Resume playing the composition if it was playing before
if (this->playerWasPlayingBefore)
this->glyphWidget->compositionManager->player->play();
break;
default:
// This should never happen
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class MainWindow : public QMainWindow
QAction *checkForUpdateAction;

OpenCompositionDialog *openCompositionDialog;
bool playerWasPlayingBefore = false;

QShortcut *playPauseShortcut;
QToolButton *playPauseButton;
Expand Down

0 comments on commit 07f1741

Please sign in to comment.