From ff197a4706ffaf836e84ef761b82c22513b95a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Wallm=C3=A9nius?= Date: Wed, 28 Oct 2009 20:41:34 +0000 Subject: [PATCH] Use array for quickscreen item settings to simplify some logic git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23380 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/quickscreen.c | 27 ++++++--------------------- apps/settings.h | 7 ++----- apps/settings_list.c | 8 ++++---- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 1abe2d5992..c7774baef4 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -367,16 +367,16 @@ bool quick_screen_quick(int button_enter) int oldrepeat = global_settings.repeat_mode; qs.items[QUICKSCREEN_TOP] = - get_setting(global_settings.qs_item_top, + get_setting(global_settings.qs_items[QUICKSCREEN_TOP], find_setting(&global_settings.party_mode, NULL)); qs.items[QUICKSCREEN_LEFT] = - get_setting(global_settings.qs_item_left, + get_setting(global_settings.qs_items[QUICKSCREEN_LEFT], find_setting(&global_settings.playlist_shuffle, NULL)); qs.items[QUICKSCREEN_RIGHT] = - get_setting(global_settings.qs_item_right, + get_setting(global_settings.qs_items[QUICKSCREEN_RIGHT], find_setting(&global_settings.repeat_mode, NULL)); qs.items[QUICKSCREEN_BOTTOM] = - get_setting(global_settings.qs_item_bottom, + get_setting(global_settings.qs_items[QUICKSCREEN_BOTTOM], find_setting(&global_settings.dirfilter, NULL)); qs.callback = NULL; @@ -452,22 +452,7 @@ void set_as_qs_item(const struct settings_list *setting, if (&settings[i] == setting) break; } - switch (item) - { - case QUICKSCREEN_TOP: - global_settings.qs_item_top = i; - break; - case QUICKSCREEN_LEFT: - global_settings.qs_item_left = i; - break; - case QUICKSCREEN_RIGHT: - global_settings.qs_item_right = i; - break; - case QUICKSCREEN_BOTTOM: - global_settings.qs_item_bottom = i; - break; - default: /* shut the compiler up */ - break; - } + + global_settings.qs_items[item] = i; } diff --git a/apps/settings.h b/apps/settings.h index c9ff3f9dd3..07f6f22efb 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -27,6 +27,7 @@ #include "inttypes.h" #include "config.h" #include "statusbar.h" /* for the statusbar values */ +#include "quickscreen.h" #include "button.h" #if CONFIG_CODEC == SWCODEC #include "audio.h" @@ -507,11 +508,7 @@ struct user_settings #endif #ifdef HAVE_QUICKSCREEN - /* these are split because settings_list cant handle arrays */ - int qs_item_top; - int qs_item_left; - int qs_item_right; - int qs_item_bottom; + int qs_items[QUICKSCREEN_ITEM_COUNT]; #endif #if CONFIG_RTC diff --git a/apps/settings_list.c b/apps/settings_list.c index 5a0e05d7d2..d9ca889458 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1582,19 +1582,19 @@ const struct settings_list settings[] = { ID2P(LANG_NORMAL), ID2P(LANG_HIGH)), #endif #ifdef HAVE_QUICKSCREEN - CUSTOM_SETTING(0, qs_item_top, LANG_TOP_QS_ITEM, + CUSTOM_SETTING(0, qs_items[QUICKSCREEN_TOP], LANG_TOP_QS_ITEM, &global_settings.dirfilter, "qs top", qs_load_from_cfg, qs_write_to_cfg, qs_is_changed, qs_set_default), - CUSTOM_SETTING(0, qs_item_left, LANG_LEFT_QS_ITEM, + CUSTOM_SETTING(0, qs_items[QUICKSCREEN_LEFT], LANG_LEFT_QS_ITEM, &global_settings.playlist_shuffle, "qs left", qs_load_from_cfg, qs_write_to_cfg, qs_is_changed, qs_set_default), - CUSTOM_SETTING(0, qs_item_right, LANG_RIGHT_QS_ITEM, + CUSTOM_SETTING(0, qs_items[QUICKSCREEN_RIGHT], LANG_RIGHT_QS_ITEM, &global_settings.repeat_mode, "qs right", qs_load_from_cfg, qs_write_to_cfg, qs_is_changed, qs_set_default), - CUSTOM_SETTING(0, qs_item_bottom, LANG_BOTTOM_QS_ITEM, + CUSTOM_SETTING(0, qs_items[QUICKSCREEN_BOTTOM], LANG_BOTTOM_QS_ITEM, &global_settings.dirfilter, "qs bottom", qs_load_from_cfg, qs_write_to_cfg, qs_is_changed, qs_set_default),