From 230198fe4a567677efae55d8b9872a669b136bf8 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 25 May 2020 11:32:17 +0100 Subject: [PATCH] (Ozone) Add option to sort playlists after name truncation --- config.def.h | 1 + configuration.c | 1 + configuration.h | 1 + intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 6 ++++++ menu/drivers/ozone/ozone_sidebar.c | 9 ++++++--- menu/menu_displaylist.c | 2 ++ menu/menu_setting.c | 15 +++++++++++++++ msg_hash.h | 1 + 10 files changed, 45 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index a3d0e0ca0f..bb76792b95 100644 --- a/config.def.h +++ b/config.def.h @@ -413,6 +413,7 @@ #define DEFAULT_OZONE_COLOR_THEME 1 #define DEFAULT_OZONE_COLLAPSE_SIDEBAR false #define DEFAULT_OZONE_TRUNCATE_PLAYLIST_NAME true +#define DEFAULT_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME true #define DEFAULT_OZONE_SCROLL_CONTENT_METADATA false #endif diff --git a/configuration.c b/configuration.c index 7299146e05..6610cc4aaa 100644 --- a/configuration.c +++ b/configuration.c @@ -1667,6 +1667,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, #ifdef HAVE_OZONE SETTING_BOOL("ozone_collapse_sidebar", &settings->bools.ozone_collapse_sidebar, true, DEFAULT_OZONE_COLLAPSE_SIDEBAR, false); SETTING_BOOL("ozone_truncate_playlist_name", &settings->bools.ozone_truncate_playlist_name, true, DEFAULT_OZONE_TRUNCATE_PLAYLIST_NAME, false); + SETTING_BOOL("ozone_sort_after_truncate_playlist_name", &settings->bools.ozone_sort_after_truncate_playlist_name, true, DEFAULT_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, false); SETTING_BOOL("ozone_scroll_content_metadata",&settings->bools.ozone_scroll_content_metadata, true, DEFAULT_OZONE_SCROLL_CONTENT_METADATA, false); #endif SETTING_BOOL("log_to_file", &settings->bools.log_to_file, true, DEFAULT_LOG_TO_FILE, false); diff --git a/configuration.h b/configuration.h index fb24ef8c40..02844d4e46 100644 --- a/configuration.h +++ b/configuration.h @@ -394,6 +394,7 @@ typedef struct settings bool enable_device_vibration; bool ozone_collapse_sidebar; bool ozone_truncate_playlist_name; + bool ozone_sort_after_truncate_playlist_name; bool ozone_scroll_content_metadata; bool log_to_file; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index ce3db58484..4152c4cd4f 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1538,6 +1538,10 @@ MSG_HASH( MENU_ENUM_LABEL_OZONE_TRUNCATE_PLAYLIST_NAME, "ozone_truncate_playlist_name" ) +MSG_HASH( + MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, + "ozone_sort_after_truncate_playlist_name" + ) MSG_HASH( MENU_ENUM_LABEL_OZONE_SCROLL_CONTENT_METADATA, "ozone_scroll_content_metadata" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index c4d394aa38..dc81b2f6c8 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7757,6 +7757,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME, "When enabled, will remove the system names from the playlists. For example, display 'PlayStation' instead of 'Sony - PlayStation'. Changes require a restart to take effect." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, + "Sort Playlists After Name Truncation" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, + "When enabled, playlists will be re-sorted in alphabetical order after removing the 'system' component of their names. Changes require a restart to take effect." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_OZONE_MENU_COLOR_THEME, "Menu Color Theme" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index fb8706a54a..9eda3891bc 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -449,6 +449,7 @@ default_sublabel_macro(action_bind_sublabel_left_thumbnails_ozone, MENU_ default_sublabel_macro(action_bind_sublabel_ozone_menu_color_theme, MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME) default_sublabel_macro(action_bind_sublabel_ozone_collapse_sidebar, MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR) default_sublabel_macro(action_bind_sublabel_ozone_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME) +default_sublabel_macro(action_bind_sublabel_ozone_sort_after_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME) default_sublabel_macro(action_bind_sublabel_ozone_scroll_content_metadata, MENU_ENUM_SUBLABEL_OZONE_SCROLL_CONTENT_METADATA) #endif default_sublabel_macro(action_bind_sublabel_menu_thumbnail_upscale_threshold, MENU_ENUM_SUBLABEL_MENU_THUMBNAIL_UPSCALE_THRESHOLD) @@ -1854,6 +1855,11 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_OZONE_TRUNCATE_PLAYLIST_NAME: #ifdef HAVE_OZONE BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_truncate_playlist_name); +#endif + break; + case MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME: +#ifdef HAVE_OZONE + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_sort_after_truncate_playlist_name); #endif break; case MENU_ENUM_LABEL_OZONE_SCROLL_CONTENT_METADATA: diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index f2c1c37d8f..55c48fb4c1 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -722,6 +722,7 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone) const char *dir_playlist = settings->paths.directory_playlist; bool menu_content_show_playlists = settings->bools.menu_content_show_playlists; bool ozone_truncate_playlist_name = settings->bools.ozone_truncate_playlist_name; + bool ozone_sort_after_truncate = settings->bools.ozone_sort_after_truncate_playlist_name; menu_displaylist_info_init(&info); @@ -800,9 +801,11 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone) file_list_set_alt_at_offset(ozone->horizontal_list, i, console_name); } - /* If playlist names were truncated, re-sort list - * by console name */ - if (ozone_truncate_playlist_name && (list_size > 0)) + /* If playlist names were truncated and option is + * enabled, re-sort list by console name */ + if (ozone_truncate_playlist_name && + ozone_sort_after_truncate && + (list_size > 0)) file_list_sort_on_alt(ozone->horizontal_list); } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index f46c7feb4a..389fe59eaa 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4277,6 +4277,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_PLAYLIST_FUZZY_ARCHIVE_MATCH, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_SCAN_WITHOUT_CORE_MATCH, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_OZONE_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_CONTENT_RUNTIME_LOG, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_CONTENT_RUNTIME_LOG_AGGREGATE, PARSE_ONLY_BOOL, true}, }; @@ -7464,6 +7465,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_XMB_MENU_COLOR_THEME, PARSE_ONLY_UINT, true}, {MENU_ENUM_LABEL_OZONE_COLLAPSE_SIDEBAR, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_OZONE_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_MATERIALUI_ICONS_ENABLE, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION, PARSE_ONLY_UINT, true}, {MENU_ENUM_LABEL_MATERIALUI_SHOW_NAV_BAR, PARSE_ONLY_BOOL, true}, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 21d50a55cf..d5bf46aef0 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -15806,6 +15806,21 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_NONE); + + CONFIG_BOOL( + list, list_info, + &settings->bools.ozone_sort_after_truncate_playlist_name, + MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, + MENU_ENUM_LABEL_VALUE_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, + DEFAULT_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); } #endif diff --git a/msg_hash.h b/msg_hash.h index c96b1dee48..ab01c81030 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1049,6 +1049,7 @@ enum msg_hash_enums MENU_LABEL(OZONE_MENU_COLOR_THEME), MENU_LABEL(OZONE_COLLAPSE_SIDEBAR), MENU_LABEL(OZONE_TRUNCATE_PLAYLIST_NAME), + MENU_LABEL(OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME), MENU_LABEL(OZONE_SCROLL_CONTENT_METADATA), MENU_LABEL(MATERIALUI_MENU_COLOR_THEME), MENU_LABEL(QUICK_MENU_OVERRIDE_OPTIONS),