forked from len0rd/rockbox
Hotkey: better settings handling, fewer saved variables, localizable hotkey info list
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25529 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3b5eff719a
commit
accc046cbd
6 changed files with 84 additions and 33 deletions
|
@ -13479,3 +13479,35 @@
|
|||
hotkey: "View Hotkey Settings"
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_WPS
|
||||
desc: hotkey info menu
|
||||
user: core
|
||||
<source>
|
||||
*: none
|
||||
hotkey: "WPS: %s"
|
||||
</source>
|
||||
<dest>
|
||||
*: none
|
||||
hotkey: "WPS: %s"
|
||||
</dest>
|
||||
<voice>
|
||||
*: none
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_FILE_BROWSER
|
||||
desc: hotkey info menu
|
||||
user: core
|
||||
<source>
|
||||
*: none
|
||||
hotkey: "File Browser: %s"
|
||||
</source>
|
||||
<dest>
|
||||
*: none
|
||||
hotkey: "File Browser: %s"
|
||||
</dest>
|
||||
<voice>
|
||||
*: none
|
||||
</voice>
|
||||
</phrase>
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#ifdef HAVE_HOTKEY
|
||||
#include "list.h"
|
||||
#include "settings_list.h"
|
||||
#include "onplay.h"
|
||||
#endif
|
||||
|
||||
/***********************************/
|
||||
|
@ -413,32 +414,26 @@ static void view_hotkey_info(void)
|
|||
info.hide_selection = true;
|
||||
info.scroll_all = true;
|
||||
simplelist_set_line_count(2);
|
||||
simplelist_addline(0, "WPS: %s",
|
||||
str(global_settings.hotkey_wps_desc_id));
|
||||
simplelist_addline(1, "Tree: %s",
|
||||
str(global_settings.hotkey_tree_desc_id));
|
||||
simplelist_addline(0, str(LANG_WPS),
|
||||
str(get_hotkey_desc_id(global_settings.hotkey_wps)));
|
||||
simplelist_addline(1, str(LANG_FILE_BROWSER),
|
||||
str(get_hotkey_desc_id(global_settings.hotkey_tree)));
|
||||
simplelist_show_list(&info);
|
||||
}
|
||||
|
||||
/* reset hotkey settings to their defaults */
|
||||
static void reset_hotkey_settings(void)
|
||||
{
|
||||
void *vars[] = {
|
||||
&global_settings.hotkey_tree,
|
||||
&global_settings.hotkey_tree_desc_id,
|
||||
&global_settings.hotkey_wps,
|
||||
&global_settings.hotkey_wps_desc_id,
|
||||
};
|
||||
const int num_settings = sizeof(vars) / sizeof(vars[0]);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_settings; i++)
|
||||
{
|
||||
const struct settings_list *setting =
|
||||
find_setting(vars[i], NULL);
|
||||
find_setting(&global_settings.hotkey_wps, NULL);
|
||||
reset_setting(setting, setting->setting);
|
||||
}
|
||||
{
|
||||
const struct settings_list *setting =
|
||||
find_setting(&global_settings.hotkey_tree, NULL);
|
||||
reset_setting(setting, setting->setting);
|
||||
}
|
||||
|
||||
settings_save();
|
||||
splash(HZ, str(LANG_RESET_DONE_CLEAR));
|
||||
}
|
||||
|
|
|
@ -1208,6 +1208,7 @@ struct hotkey_assignment {
|
|||
struct menu_func func;
|
||||
int return_code;
|
||||
const struct menu_item_ex *menu_addr;
|
||||
int lang_id;
|
||||
};
|
||||
|
||||
#define HOTKEY_FUNC(func, param) {{(void *)func}, param}
|
||||
|
@ -1227,31 +1228,51 @@ enum hotkey_settings {
|
|||
static struct hotkey_assignment hotkey_items[] = {
|
||||
{ HOTKEY_VIEW_PLAYLIST | HOT_WPS,
|
||||
HOTKEY_FUNC(NULL, NULL),
|
||||
ONPLAY_PLAYLIST, &view_cur_playlist },
|
||||
ONPLAY_PLAYLIST, &view_cur_playlist,
|
||||
LANG_VIEW_DYNAMIC_PLAYLIST },
|
||||
{ HOTKEY_SHOW_TRACK_INFO| HOT_WPS,
|
||||
HOTKEY_FUNC(browse_id3, NULL),
|
||||
ONPLAY_RELOAD_DIR, &browse_id3_item },
|
||||
ONPLAY_RELOAD_DIR, &browse_id3_item,
|
||||
LANG_MENU_SHOW_ID3_INFO },
|
||||
#ifdef HAVE_PITCHSCREEN
|
||||
{ HOTKEY_PITCHSCREEN | HOT_WPS,
|
||||
HOTKEY_FUNC(gui_syncpitchscreen_run, NULL),
|
||||
ONPLAY_RELOAD_DIR, &pitch_screen_item },
|
||||
ONPLAY_RELOAD_DIR, &pitch_screen_item,
|
||||
LANG_PITCH },
|
||||
#endif
|
||||
{ HOTKEY_OPEN_WITH | HOT_WPS | HOT_TREE,
|
||||
HOTKEY_FUNC(open_with, NULL),
|
||||
ONPLAY_RELOAD_DIR, &list_viewers_item },
|
||||
ONPLAY_RELOAD_DIR, &list_viewers_item,
|
||||
LANG_ONPLAY_OPEN_WITH },
|
||||
{ HOTKEY_DELETE | HOT_WPS | HOT_TREE,
|
||||
HOTKEY_FUNC(delete_item, NULL),
|
||||
ONPLAY_RELOAD_DIR, &delete_file_item },
|
||||
ONPLAY_RELOAD_DIR, &delete_file_item,
|
||||
LANG_DELETE },
|
||||
{ HOTKEY_DELETE | HOT_TREE,
|
||||
HOTKEY_FUNC(delete_item, NULL),
|
||||
ONPLAY_RELOAD_DIR, &delete_dir_item },
|
||||
ONPLAY_RELOAD_DIR, &delete_dir_item,
|
||||
LANG_DELETE },
|
||||
{ HOTKEY_INSERT | HOT_TREE,
|
||||
HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT),
|
||||
ONPLAY_START_PLAY, &i_pl_item },
|
||||
ONPLAY_START_PLAY, &i_pl_item,
|
||||
LANG_INSERT },
|
||||
};
|
||||
|
||||
static const int num_hotkey_items = sizeof(hotkey_items) / sizeof(hotkey_items[0]);
|
||||
|
||||
/* Return the language ID for the input function */
|
||||
int get_hotkey_desc_id(int hk_func)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_hotkey_items; i++)
|
||||
{
|
||||
if ((hotkey_items[i].item & HOT_MASK) == hk_func)
|
||||
return hotkey_items[i].lang_id;
|
||||
}
|
||||
|
||||
return LANG_HOTKEY_NOT_SET;
|
||||
}
|
||||
|
||||
/* Execute the hotkey function, if listed for this screen */
|
||||
static int execute_hotkey(bool is_wps)
|
||||
{
|
||||
|
@ -1294,9 +1315,7 @@ static void set_hotkey(bool is_wps)
|
|||
struct hotkey_assignment *this_item;
|
||||
const int context = is_wps ? HOT_WPS : HOT_TREE;
|
||||
int *hk_func = is_wps ? &global_settings.hotkey_wps :
|
||||
&global_settings.hotkey_tree,
|
||||
*hk_desc = is_wps ? &global_settings.hotkey_wps_desc_id :
|
||||
&global_settings.hotkey_tree_desc_id;
|
||||
&global_settings.hotkey_tree;
|
||||
int this_hk,
|
||||
this_id;
|
||||
bool match_found = false;
|
||||
|
@ -1336,7 +1355,6 @@ static void set_hotkey(bool is_wps)
|
|||
{
|
||||
/* store the hotkey settings */
|
||||
*hk_func = this_hk;
|
||||
*hk_desc = this_id;
|
||||
|
||||
settings_save();
|
||||
}
|
||||
|
|
|
@ -31,4 +31,8 @@ enum {
|
|||
ONPLAY_PLAYLIST,
|
||||
};
|
||||
|
||||
#ifdef HAVE_HOTKEY
|
||||
int get_hotkey_desc_id(int hk_func);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -817,10 +817,10 @@ struct user_settings
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_HOTKEY
|
||||
/* hotkey assignments - acceptable values are in
|
||||
hotkey_settings enum in onplay.c */
|
||||
int hotkey_wps;
|
||||
int hotkey_wps_desc_id;
|
||||
int hotkey_tree;
|
||||
int hotkey_tree_desc_id;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
|
|
@ -1662,10 +1662,12 @@ const struct settings_list settings[] = {
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_HOTKEY
|
||||
CHOICE_SETTING(0, hotkey_wps, 0, 1, "hotkey wps", 0, NULL, 0),
|
||||
CHOICE_SETTING(0, hotkey_wps_desc_id, 0, LANG_VIEW_DYNAMIC_PLAYLIST, "hotkey wps desc id", 0, NULL, 0),
|
||||
CHOICE_SETTING(0, hotkey_tree, 0, 0, "hotkey tree", 0, NULL, 0),
|
||||
CHOICE_SETTING(0, hotkey_tree_desc_id, 0, LANG_OFF, "hotkey tree desc id", 0, NULL, 0),
|
||||
CHOICE_SETTING(0, hotkey_wps, -1, 1, "hotkey wps",
|
||||
"off,view playlist,show track info,pitchscreen,open with,delete,insert",
|
||||
NULL, 7, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
CHOICE_SETTING(0, hotkey_tree, -1, 0, "hotkey tree",
|
||||
"off,view playlist,show track info,pitchscreen,open with,delete,insert",
|
||||
NULL, 7, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue