FS#9515 - customisable quickscreen. Allows you to choose which setting you want displayed on the quickscreen.
Allows almost every available setting. (change the options in settings > general settings > quickscreen items) Not every setting will work perfectly, some might need aditional handling if the change doesnt take effect straight away (let us know which are problematic so they can be fixed) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18984 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5395957549
commit
edcacaa787
7 changed files with 309 additions and 10 deletions
|
@ -37,6 +37,8 @@
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "quickscreen.h"
|
#include "quickscreen.h"
|
||||||
#include "talk.h"
|
#include "talk.h"
|
||||||
|
#include "list.h"
|
||||||
|
#include "splash.h"
|
||||||
|
|
||||||
static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT];
|
static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT];
|
||||||
static struct viewport vp_icons[NB_SCREENS];
|
static struct viewport vp_icons[NB_SCREENS];
|
||||||
|
@ -113,7 +115,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
|
||||||
vps[screen][QUICKSCREEN_RIGHT].width = width;
|
vps[screen][QUICKSCREEN_RIGHT].width = width;
|
||||||
|
|
||||||
/* shrink the icons vp by a few pixels if there is room so the arrows
|
/* shrink the icons vp by a few pixels if there is room so the arrows
|
||||||
arnt' drawn right next to the text */
|
aren't drawn right next to the text */
|
||||||
if (vp_icons[screen].width > CENTER_ICONAREA_WIDTH+8)
|
if (vp_icons[screen].width > CENTER_ICONAREA_WIDTH+8)
|
||||||
{
|
{
|
||||||
vp_icons[screen].width -= 8;
|
vp_icons[screen].width -= 8;
|
||||||
|
@ -320,18 +322,31 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter)
|
||||||
cond_talk_ids_fq(VOICE_OK);
|
cond_talk_ids_fq(VOICE_OK);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
static bool is_setting_quickscreenable(const struct settings_list *setting);
|
||||||
|
static inline const struct settings_list *get_setting(int gs_value,
|
||||||
|
const struct settings_list *defaultval)
|
||||||
|
{
|
||||||
|
if (gs_value != -1 && gs_value < nb_settings &&
|
||||||
|
is_setting_quickscreenable(&settings[gs_value]))
|
||||||
|
return &settings[gs_value];
|
||||||
|
return defaultval;
|
||||||
|
}
|
||||||
bool quick_screen_quick(int button_enter)
|
bool quick_screen_quick(int button_enter)
|
||||||
{
|
{
|
||||||
struct gui_quickscreen qs;
|
struct gui_quickscreen qs;
|
||||||
bool oldshuffle = global_settings.playlist_shuffle;
|
bool oldshuffle = global_settings.playlist_shuffle;
|
||||||
int oldrepeat = global_settings.repeat_mode;
|
int oldrepeat = global_settings.repeat_mode;
|
||||||
qs.items[QUICKSCREEN_LEFT] =
|
|
||||||
find_setting(&global_settings.playlist_shuffle, NULL);
|
qs.items[QUICKSCREEN_LEFT] =
|
||||||
qs.items[QUICKSCREEN_RIGHT] =
|
get_setting(global_settings.qs_item_left,
|
||||||
find_setting(&global_settings.repeat_mode, NULL);
|
find_setting(&global_settings.playlist_shuffle, NULL));
|
||||||
qs.items[QUICKSCREEN_BOTTOM] =
|
qs.items[QUICKSCREEN_RIGHT] =
|
||||||
find_setting(&global_settings.dirfilter, NULL);
|
get_setting(global_settings.qs_item_right,
|
||||||
|
find_setting(&global_settings.repeat_mode, NULL));
|
||||||
|
qs.items[QUICKSCREEN_BOTTOM] =
|
||||||
|
get_setting(global_settings.qs_item_bottom,
|
||||||
|
find_setting(&global_settings.dirfilter, NULL));
|
||||||
|
|
||||||
qs.callback = NULL;
|
qs.callback = NULL;
|
||||||
if (gui_syncquickscreen_run(&qs, button_enter))
|
if (gui_syncquickscreen_run(&qs, button_enter))
|
||||||
{
|
{
|
||||||
|
@ -378,3 +393,136 @@ bool quick_screen_f3(int button_enter)
|
||||||
}
|
}
|
||||||
#endif /* BUTTON_F3 */
|
#endif /* BUTTON_F3 */
|
||||||
|
|
||||||
|
/* stuff to make the quickscreen configurable */
|
||||||
|
static bool is_setting_quickscreenable(const struct settings_list *setting)
|
||||||
|
{
|
||||||
|
/* to keep things simple, only settings which have a lang_id set are ok */
|
||||||
|
if (setting->lang_id < 0 || (setting->flags&F_BANFROMQS))
|
||||||
|
return false;
|
||||||
|
switch (setting->flags&F_T_MASK)
|
||||||
|
{
|
||||||
|
case F_T_BOOL:
|
||||||
|
return true;
|
||||||
|
case F_T_INT:
|
||||||
|
case F_T_UINT:
|
||||||
|
return (setting->RESERVED != NULL);
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct settings_list *find_setting_from_index(int index)
|
||||||
|
{
|
||||||
|
int count = -1, i;
|
||||||
|
const struct settings_list *setting = &settings[0];
|
||||||
|
for(i=0;i<nb_settings;i++)
|
||||||
|
{
|
||||||
|
setting = &settings[i];
|
||||||
|
if (is_setting_quickscreenable(setting))
|
||||||
|
count++;
|
||||||
|
if (count == index)
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
static char* quickscreen_setter_getname(int selected_item, void *data,
|
||||||
|
char *buffer, size_t buffer_len)
|
||||||
|
{
|
||||||
|
(void)data;
|
||||||
|
const struct settings_list *setting = find_setting_from_index(selected_item);
|
||||||
|
snprintf(buffer, buffer_len, "%s (%s)",
|
||||||
|
str(setting->lang_id), setting->cfg_name);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
static int quickscreen_setter_speak_item(int selected_item, void * data)
|
||||||
|
{
|
||||||
|
(void)data;
|
||||||
|
talk_id(find_setting_from_index(selected_item)->lang_id, true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int quickscreen_setter_action_callback(int action,
|
||||||
|
struct gui_synclist *lists)
|
||||||
|
{
|
||||||
|
const struct settings_list *temp = lists->data;
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case ACTION_STD_OK:
|
||||||
|
/* ok, quit */
|
||||||
|
return ACTION_STD_CANCEL;
|
||||||
|
case ACTION_STD_CONTEXT: /* real settings use this to reset to default */
|
||||||
|
{
|
||||||
|
int i=0, count=0;
|
||||||
|
reset_setting(temp, temp->setting);
|
||||||
|
for(i=0;i<nb_settings;i++)
|
||||||
|
{
|
||||||
|
if (is_setting_quickscreenable(&settings[i]))
|
||||||
|
count++;
|
||||||
|
if (*(int*)temp->setting == i)
|
||||||
|
{
|
||||||
|
gui_synclist_select_item(lists, count-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ACTION_REDRAW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
int quickscreen_set_option(void *data)
|
||||||
|
{
|
||||||
|
int valid_settings_count = 0;
|
||||||
|
int i, newval = 0, oldval, *setting = NULL;
|
||||||
|
struct simplelist_info info;
|
||||||
|
switch ((intptr_t)data)
|
||||||
|
{
|
||||||
|
case QUICKSCREEN_LEFT:
|
||||||
|
setting = &global_settings.qs_item_left;
|
||||||
|
break;
|
||||||
|
case QUICKSCREEN_RIGHT:
|
||||||
|
setting = &global_settings.qs_item_right;
|
||||||
|
break;
|
||||||
|
case QUICKSCREEN_BOTTOM:
|
||||||
|
setting = &global_settings.qs_item_bottom;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
oldval = *setting;
|
||||||
|
for(i=0;i<nb_settings;i++)
|
||||||
|
{
|
||||||
|
if (is_setting_quickscreenable(&settings[i]))
|
||||||
|
valid_settings_count++;
|
||||||
|
if (oldval == i)
|
||||||
|
newval = valid_settings_count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
simplelist_info_init(&info, str(LANG_QS_ITEMS),
|
||||||
|
valid_settings_count,
|
||||||
|
(void*)find_setting(setting, NULL)); /* find the qs item being changed */
|
||||||
|
info.get_name = quickscreen_setter_getname;
|
||||||
|
if(global_settings.talk_menu)
|
||||||
|
info.get_talk = quickscreen_setter_speak_item;
|
||||||
|
info.action_callback = quickscreen_setter_action_callback;
|
||||||
|
info.selection = newval;
|
||||||
|
simplelist_show_list(&info);
|
||||||
|
if (info.selection != oldval)
|
||||||
|
{
|
||||||
|
if (info.selection != -1)
|
||||||
|
{
|
||||||
|
const struct settings_list *temp = find_setting_from_index(info.selection);
|
||||||
|
int i = 0;
|
||||||
|
for(i=0;i<nb_settings;i++)
|
||||||
|
{
|
||||||
|
if (&settings[i] == temp)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*setting = i;
|
||||||
|
settings_save();
|
||||||
|
}
|
||||||
|
/* probably should splash LANG_CANCEL here but right now
|
||||||
|
we cant find out the selection when the cancel button was
|
||||||
|
pressed, (without hacks)so we cant know if the
|
||||||
|
selection was changed, or just viewed */
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter);
|
||||||
extern bool quick_screen_f3(int button_enter);
|
extern bool quick_screen_f3(int button_enter);
|
||||||
#endif
|
#endif
|
||||||
extern bool quick_screen_quick(int button_enter);
|
extern bool quick_screen_quick(int button_enter);
|
||||||
|
int quickscreen_set_option(void *data);
|
||||||
|
|
||||||
#endif /*_GUI_QUICK_SCREEN_H_*/
|
#endif /*_GUI_QUICK_SCREEN_H_*/
|
||||||
#endif /* HAVE_QUICKSCREEN */
|
#endif /* HAVE_QUICKSCREEN */
|
||||||
|
|
|
@ -12109,3 +12109,71 @@
|
||||||
*: "Search Results"
|
*: "Search Results"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_QS_ITEMS
|
||||||
|
desc: used for the submenu name for the quickscreen items
|
||||||
|
user:
|
||||||
|
<source>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Quickscreen Items"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Quickscreen Items"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Quickscreen Items"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_LEFT
|
||||||
|
desc: used for the submenu name for the quickscreen items
|
||||||
|
user:
|
||||||
|
<source>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Left"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Left"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Left"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_RIGHT
|
||||||
|
desc: used for the submenu name for the quickscreen items
|
||||||
|
user:
|
||||||
|
<source>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Right"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Right"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Right"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_BOTTOM
|
||||||
|
desc: used for the submenu name for the quickscreen items
|
||||||
|
user:
|
||||||
|
<source>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Bottom"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Bottom"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: none
|
||||||
|
quickscreen: "Bottom"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "quickscreen.h"
|
||||||
|
|
||||||
/***********************************/
|
/***********************************/
|
||||||
/* TAGCACHE MENU */
|
/* TAGCACHE MENU */
|
||||||
|
@ -486,7 +487,25 @@ MAKE_MENU(voice_settings_menu, ID2P(LANG_VOICE), 0, Icon_Voice,
|
||||||
/* VOICE MENU */
|
/* VOICE MENU */
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_QUICKSCREEN
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
/* CUSTOMISABLE QUICKSCREEN CODE */
|
||||||
|
|
||||||
|
MENUITEM_FUNCTION(qs_left_item, MENU_FUNC_USEPARAM, ID2P(LANG_LEFT),
|
||||||
|
(menu_function)quickscreen_set_option, (intptr_t*)QUICKSCREEN_LEFT, NULL,
|
||||||
|
Icon_Menu_setting);
|
||||||
|
MENUITEM_FUNCTION(qs_right_item, MENU_FUNC_USEPARAM, ID2P(LANG_RIGHT),
|
||||||
|
(menu_function)quickscreen_set_option, (intptr_t*)QUICKSCREEN_RIGHT, NULL,
|
||||||
|
Icon_Menu_setting);
|
||||||
|
MENUITEM_FUNCTION(qs_bottom_item, MENU_FUNC_USEPARAM, ID2P(LANG_BOTTOM),
|
||||||
|
(menu_function)quickscreen_set_option, (intptr_t*)QUICKSCREEN_BOTTOM, NULL,
|
||||||
|
Icon_Menu_setting);
|
||||||
|
|
||||||
|
MAKE_MENU(quickscreen_settings, ID2P(LANG_QS_ITEMS), NULL, Icon_Config,
|
||||||
|
&qs_left_item, &qs_right_item, &qs_bottom_item);
|
||||||
|
/* CUSTOMISABLE QUICKSCREEN CODE */
|
||||||
|
/***********************************/
|
||||||
|
#endif
|
||||||
|
|
||||||
/***********************************/
|
/***********************************/
|
||||||
/* SETTINGS MENU */
|
/* SETTINGS MENU */
|
||||||
|
@ -500,6 +519,9 @@ MENUITEM_FUNCTION(browse_langs, 0, ID2P(LANG_LANGUAGE), language_browse,
|
||||||
MAKE_MENU(settings_menu_item, ID2P(LANG_GENERAL_SETTINGS), 0,
|
MAKE_MENU(settings_menu_item, ID2P(LANG_GENERAL_SETTINGS), 0,
|
||||||
Icon_General_settings_menu,
|
Icon_General_settings_menu,
|
||||||
&playlist_settings, &file_menu,
|
&playlist_settings, &file_menu,
|
||||||
|
#ifdef HAVE_QUICKSCREEN
|
||||||
|
&quickscreen_settings,
|
||||||
|
#endif
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
&tagcache_menu,
|
&tagcache_menu,
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -751,6 +751,12 @@ struct user_settings
|
||||||
#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
|
#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
|
||||||
int touchpad_sensitivity;
|
int touchpad_sensitivity;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_QUICKSCREEN
|
||||||
|
/* these are split because settings_list cant handle arrays */
|
||||||
|
int qs_item_left;
|
||||||
|
int qs_item_right;
|
||||||
|
int qs_item_bottom;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** global variables **/
|
/** global variables **/
|
||||||
|
|
|
@ -409,6 +409,45 @@ static int32_t jumpscroll_getlang(int value, int unit)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LCD_CHARCELLS */
|
#endif /* HAVE_LCD_CHARCELLS */
|
||||||
|
|
||||||
|
#ifdef HAVE_QUICKSCREEN
|
||||||
|
int find_setting_by_name(char*name)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
const struct settings_list *setting;
|
||||||
|
while (i<nb_settings)
|
||||||
|
{
|
||||||
|
setting = &settings[i];
|
||||||
|
if (setting->cfg_name && !strcmp(setting->cfg_name, name))
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
void qs_load_from_cfg(void* var, char*value)
|
||||||
|
{
|
||||||
|
*(int*)var = find_setting_by_name(value);
|
||||||
|
}
|
||||||
|
char* qs_write_to_cfg(void* setting, char*buf, int buf_len)
|
||||||
|
{
|
||||||
|
const struct settings_list *var = &settings[*(int*)setting];
|
||||||
|
strncpy(buf, var->cfg_name, buf_len);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
bool qs_is_changed(void* setting, void* defaultval)
|
||||||
|
{
|
||||||
|
int i = *(int*)setting;
|
||||||
|
if (i < 0 || i >= nb_settings)
|
||||||
|
return false;
|
||||||
|
const struct settings_list *var = &settings[i];
|
||||||
|
return var != find_setting(defaultval, NULL);
|
||||||
|
}
|
||||||
|
void qs_set_default(void* setting, void* defaultval)
|
||||||
|
{
|
||||||
|
find_setting(defaultval, (int*)setting);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
const struct settings_list settings[] = {
|
const struct settings_list settings[] = {
|
||||||
/* sound settings */
|
/* sound settings */
|
||||||
SOUND_SETTING(F_NO_WRAP,volume, LANG_VOLUME, "volume", SOUND_VOLUME),
|
SOUND_SETTING(F_NO_WRAP,volume, LANG_VOLUME, "volume", SOUND_VOLUME),
|
||||||
|
@ -1372,6 +1411,20 @@ const struct settings_list settings[] = {
|
||||||
"touchpad sensitivity", "normal,high", touchpad_set_sensitivity, 2,
|
"touchpad sensitivity", "normal,high", touchpad_set_sensitivity, 2,
|
||||||
ID2P(LANG_NORMAL), ID2P(LANG_HIGH)),
|
ID2P(LANG_NORMAL), ID2P(LANG_HIGH)),
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_QUICKSCREEN
|
||||||
|
CUSTOM_SETTING(0, qs_item_left, LANG_LEFT,
|
||||||
|
&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,
|
||||||
|
&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,
|
||||||
|
&global_settings.dirfilter, "qs bottom",
|
||||||
|
qs_load_from_cfg, qs_write_to_cfg,
|
||||||
|
qs_is_changed, qs_set_default),
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
const int nb_settings = sizeof(settings)/sizeof(*settings);
|
const int nb_settings = sizeof(settings)/sizeof(*settings);
|
||||||
|
|
|
@ -152,8 +152,10 @@ struct custom_setting {
|
||||||
#define F_PADTITLE 0x800 /* pad the title with spaces to force it to scroll */
|
#define F_PADTITLE 0x800 /* pad the title with spaces to force it to scroll */
|
||||||
#define F_NO_WRAP 0x1000 /* used if the list should not wrap */
|
#define F_NO_WRAP 0x1000 /* used if the list should not wrap */
|
||||||
|
|
||||||
|
#define F_BANFROMQS 0x80000000 /* ban the setting from the quickscreen items */
|
||||||
|
|
||||||
struct settings_list {
|
struct settings_list {
|
||||||
uint32_t flags; /* ____ _SER TFFF NNN_ _ATW PTVC IFRB STTT */
|
uint32_t flags; /* B___ _SER TFFF NNN_ _ATW PTVC IFRB STTT */
|
||||||
void *setting;
|
void *setting;
|
||||||
int lang_id; /* -1 for none */
|
int lang_id; /* -1 for none */
|
||||||
union storage_type default_val;
|
union storage_type default_val;
|
||||||
|
|
Loading…
Reference in a new issue