From 8a22660770d3c0c713247ab8f2b7c08777affd9f Mon Sep 17 00:00:00 2001 From: JJ Style Date: Thu, 24 Aug 2023 23:25:27 +0100 Subject: [PATCH] Fix #13369: shuffle setting not working from shortcut. Setting in shortcut was not being handled as it had no callback. In the settings menu it looks like the event is handled separately. Added a shuffle callback to the setting so it is called when changed from the shortcut. Edit: move callback to within settings_list so playlist interface is unchanged. Change-Id: I3691acac1c73a80bf67c0b8b334009ef1655fdb0 --- apps/settings_list.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/settings_list.c b/apps/settings_list.c index 96cc933ac3..134b93cf48 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -63,6 +63,7 @@ #include "onplay.h" #include "misc.h" /* current activity */ #endif +#include "playlist.h" #include "voice_thread.h" @@ -618,6 +619,19 @@ static void eq_set_default(void* setting, void* defaultval) memcpy(setting, defaultval, sizeof(struct eq_band_setting)); } +/* perform shuffle/unshuffle of the current playlist based on the boolean provided */ +static void shuffle_playlist_callback(bool shuffle) +{ + if (shuffle) + { + playlist_randomise(NULL, current_tick, true); + } + else + { + playlist_sort(NULL, true); + } +} + #ifdef HAVE_QUICKSCREEN static void qs_load_from_cfg(void *var, char *value) { @@ -898,7 +912,7 @@ const struct settings_list settings[] = { #endif /* playback */ - OFFON_SETTING(0, playlist_shuffle, LANG_SHUFFLE, false, "shuffle", NULL), + OFFON_SETTING(0, playlist_shuffle, LANG_SHUFFLE, false, "shuffle", shuffle_playlist_callback), SYSTEM_SETTING(NVRAM(4), resume_index, -1), SYSTEM_SETTING(NVRAM(4), resume_crc32, -1), SYSTEM_SETTING(NVRAM(4), resume_elapsed, -1),