Implement playlist switch undo/redo

This commit is contained in:
Robin Gareus 2023-06-09 17:22:55 +02:00
parent 3a60de5d54
commit 6ac0aae35f
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 52 additions and 14 deletions

View file

@ -397,9 +397,11 @@ PlaylistSelector::selection_changed ()
return;
}
XMLNode* before = &_rui->track ()->playlist_state ();
switch (_mode) {
/* @Robin: I dont see a way to undo these playlist actions
* @Ben: me neither :)
* @Robin: Now I do.
*/
case plCopy:
{
@ -426,6 +428,15 @@ PlaylistSelector::selection_changed ()
}
break;
}
XMLNode* after = &_rui->track ()->playlist_state ();
if (*before != *after) {
_session->begin_reversible_command (string_compose (_("Switch Playlist for track %1"), _rui->track ()->name ()));
_session->commit_reversible_command (new MementoCommand<Track>(*_rui->track (), before, after));
} else {
delete before;
delete after;
}
}
}