Replace "Reload After Saving" with option to remove queued tracks

The "Reload After Saving" setting was added in
g3347 (4f83e66) to solve FS#13287, by allowing
you to bookmark a modified playlist after saving,
without having to manually reload it first.

Since the rewrite of playlist_save in g5192
(90e3571), a modified playlist doesn't have to be
reloaded anymore in order to be bookmarked after
it's been saved, unless it contains queued tracks.

To cover the remaining use cases of the previously
available option, Rockbox will now offer to remove
any queued tracks from a playlist when saving it.

Change-Id: I2d6f12bcce14d8ff41a4d921ce84d628774103ac
This commit is contained in:
Christian Soffke 2023-11-11 01:53:36 +01:00
parent e5c65a0039
commit ea5ce8034b
15 changed files with 69 additions and 90 deletions

View file

@ -38,7 +38,6 @@
#include "talk.h"
#include "playlist_catalog.h"
#include "splash.h"
#include "filetree.h"
#include "general.h"
/* load a screen to save the playlist passed in (or current playlist if NULL is passed) */
@ -46,11 +45,6 @@ int save_playlist_screen(struct playlist_info* playlist)
{
char directoryonly[MAX_PATH+3];
char *filename;
int resume_index;
uint32_t resume_elapsed;
uint32_t resume_offset;
char temp[MAX_PATH+1], *p;
int len;
@ -86,55 +80,8 @@ int save_playlist_screen(struct playlist_info* playlist)
/* reload in case playlist was saved to cwd */
reload_directory();
/* only reload newly saved playlist if:
* playlist is null AND setting is turned on
*
* if playlist is null, we should be dealing with the current playlist,
* and thus we got here from the wps screen. That means we want to reload
* the current playlist so the user can make bookmarks. */
if ((global_settings.playlist_reload_after_save == true) &&
(playlist == NULL))
{
/* at least one slash exists in temp */
if (strrchr(temp, '/') != NULL)
{
filename = strrchr(temp, '/') + 1;
if (temp[0] == '/') /* most common situation - first char is a slash */
{
strcpy(directoryonly, temp);
directoryonly[filename - temp] = '\0';
} else /* there is a slash, but not at the beginning of temp - prepend one */
{
directoryonly[0] = '/';
strcpy(directoryonly+1, temp);
directoryonly[filename - temp + 1] = '\0';
}
} else /* temp doesn't contain any slashes, uncommon? */
{
directoryonly[0] = '/';
directoryonly[1] = '\0';
filename = temp;
}
/* can't trust index from id3 (don't know why), get it from playlist */
resume_index = playlist_get_display_index() - 1;
struct mp3entry* id3 = audio_current_track();
/* record elapsed and offset so they don't change when we load new playlist */
resume_elapsed = id3->elapsed;
resume_offset = id3->offset;
ft_play_playlist(temp, directoryonly, filename, true);
playlist_start(resume_index, resume_elapsed, resume_offset);
}
/* cancelled out of name selection */
} else {
return 1;
return 1; /* cancelled out of name selection */
}
return 0;
@ -179,14 +126,12 @@ MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL)
MENUITEM_SETTING(keep_current_track_on_replace, &global_settings.keep_current_track_on_replace_playlist, NULL);
MENUITEM_SETTING(show_shuffled_adding_options, &global_settings.show_shuffled_adding_options, NULL);
MENUITEM_SETTING(show_queue_options, &global_settings.show_queue_options, NULL);
MENUITEM_SETTING(playlist_reload_after_save, &global_settings.playlist_reload_after_save, NULL);
MAKE_MENU(currentplaylist_settings_menu, ID2P(LANG_CURRENT_PLAYLIST),
NULL, Icon_Playlist,
&warn_on_erase,
&keep_current_track_on_replace,
&show_shuffled_adding_options,
&show_queue_options,
&playlist_reload_after_save);
&show_queue_options);
MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL,
Icon_Playlist,