mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-07-10 13:29:52 -04:00
Hotkey Tree share code with WPS Context / Hotkey Wps
Change-Id: I0d81601bdb8279e845a874486ac4c1516b9d7dfc
This commit is contained in:
parent
ff3155be9a
commit
21e9d3f449
4 changed files with 50 additions and 45 deletions
|
|
@ -193,7 +193,9 @@ MENUITEM_SETTING(show_filename_ext, &global_settings.show_filename_ext, NULL);
|
|||
MENUITEM_SETTING(browse_current, &global_settings.browse_current, NULL);
|
||||
MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL);
|
||||
#ifdef HAVE_HOTKEY
|
||||
MENUITEM_SETTING(hotkey_tree_item, &global_settings.hotkey_tree, NULL);
|
||||
MENUITEM_FUNCTION_W_PARAM(hotkey_tree_item, 0, ID2P(LANG_HOTKEY_FILE_BROWSER),
|
||||
tree_context_menu_do_setting, (void*)0,
|
||||
NULL, Icon_Menu_setting);
|
||||
#endif
|
||||
static int clear_start_directory(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1616,6 +1616,10 @@ int hotkey_run_menu(intptr_t flag, bool execute, int current_action)
|
|||
|
||||
struct hk_menu_data data = {hk_menu, execute ? 1 : 0};
|
||||
|
||||
char *title = str(LANG_ONPLAY_MENU_TITLE);
|
||||
if (flag & HOTKEY_FLAG_TREE)
|
||||
title = str(LANG_HOTKEY_FILE_BROWSER);
|
||||
|
||||
struct simplelist_info info;
|
||||
int selected = 0;
|
||||
int count = 0;
|
||||
|
|
@ -1634,7 +1638,7 @@ int hotkey_run_menu(intptr_t flag, bool execute, int current_action)
|
|||
}
|
||||
|
||||
/* count -1 don't display HOTKEY_OFF item */
|
||||
simplelist_info_init(&info, str(LANG_ONPLAY_MENU_TITLE), count - data.hide_off, (void*)&data);
|
||||
simplelist_info_init(&info, title, count - data.hide_off, (void*)&data);
|
||||
info.get_name = hotkey_get_name;
|
||||
info.get_icon = hotkey_get_icon;
|
||||
info.get_talk = hotkey_get_talk;
|
||||
|
|
@ -1699,7 +1703,9 @@ int onplay(char* file, int attr, int from_context, bool hotkey, int customaction
|
|||
return onplay_result;
|
||||
}
|
||||
else
|
||||
return execute_hotkey(global_settings.hotkey_tree);
|
||||
{
|
||||
return execute_hotkey(global_settings.hotkey_tree & HK_CTX_MASK);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)hotkey;
|
||||
|
|
@ -1742,13 +1748,14 @@ int get_onplay_context(void)
|
|||
return selected_file.context;
|
||||
}
|
||||
|
||||
int wps_context_menu_do_setting(void *param)
|
||||
static int hotkey_menu_do_setting(void *param, int *setting, int flag)
|
||||
{
|
||||
int context_wps = global_settings.context_wps;
|
||||
|
||||
int current = *setting;
|
||||
int item = (intptr_t)param;
|
||||
|
||||
int temp = HK_CTX_GET(item, context_wps);
|
||||
int sel = hotkey_run_menu(HOTKEY_FLAG_WPS, false, temp);
|
||||
int temp = HK_CTX_GET(item, current);
|
||||
int sel = hotkey_run_menu(flag, false, temp);
|
||||
if (sel >=0)
|
||||
{
|
||||
if (sel == HOTKEY_PLUGIN)
|
||||
|
|
@ -1764,8 +1771,8 @@ int wps_context_menu_do_setting(void *param)
|
|||
}
|
||||
}
|
||||
|
||||
context_wps &= ~HK_CTX_SET(item, HK_CTX_MASK);/*clear*/
|
||||
context_wps |= HK_CTX_SET(item, sel);
|
||||
current &= ~HK_CTX_SET(item, HK_CTX_MASK);/*clear*/
|
||||
current |= HK_CTX_SET(item, sel);
|
||||
|
||||
/* check for duplicates */
|
||||
#ifdef HAVE_HOTKEY
|
||||
|
|
@ -1777,17 +1784,27 @@ int wps_context_menu_do_setting(void *param)
|
|||
{
|
||||
if (i != item)
|
||||
{
|
||||
if (HK_CTX_GET(i, global_settings.context_wps) == sel)
|
||||
if (HK_CTX_GET(i, *setting) == sel)
|
||||
{
|
||||
context_wps &= ~HK_CTX_SET(i, HK_CTX_MASK);/*clear*/
|
||||
current &= ~HK_CTX_SET(i, HK_CTX_MASK);/*clear*/
|
||||
}
|
||||
}
|
||||
}
|
||||
global_settings.context_wps = context_wps;
|
||||
*setting = current;
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
||||
int wps_context_menu_do_setting(void *param)
|
||||
{
|
||||
return hotkey_menu_do_setting(param, &global_settings.context_wps, HOTKEY_FLAG_WPS);
|
||||
}
|
||||
|
||||
int tree_context_menu_do_setting(void *param)
|
||||
{
|
||||
return hotkey_menu_do_setting(param, &global_settings.hotkey_tree, HOTKEY_FLAG_TREE);
|
||||
}
|
||||
|
||||
void wps_context_menu_load_from_cfg(void* setting, char *value)
|
||||
{
|
||||
int item = 0;
|
||||
|
|
@ -1803,7 +1820,8 @@ void wps_context_menu_load_from_cfg(void* setting, char *value)
|
|||
|
||||
for (size_t i = ARRAYLEN(hotkey_items) - 1; i < ARRAYLEN(hotkey_items); i--)
|
||||
{
|
||||
if (strncasecmp(st, str(hotkey_items[i].lang_id), end-st) == 0)
|
||||
if (end-st > 1
|
||||
&& strncasecmp(st, str(hotkey_items[i].lang_id), end-st) == 0)
|
||||
{
|
||||
var |= HK_CTX_SET(item, hotkey_items[i].action);
|
||||
}
|
||||
|
|
@ -1818,9 +1836,13 @@ void wps_context_menu_load_from_cfg(void* setting, char *value)
|
|||
char* wps_context_menu_write_to_cfg(void* setting, char*buf, int buf_len)
|
||||
{
|
||||
int var = *(int*)setting;
|
||||
unsigned i, written;
|
||||
int items = HK_CTX_ITEMS;
|
||||
if (setting == &global_settings.hotkey_tree)
|
||||
items = 1;
|
||||
|
||||
unsigned int written;
|
||||
char *buffer = buf;
|
||||
for (i = 0; i < HK_CTX_ITEMS && buf_len > 0; i++)
|
||||
for (int i = 0; i < items && buf_len > 0; i++)
|
||||
{
|
||||
written = snprintf(buffer, buf_len, "%s, ",
|
||||
str(get_hotkey(HK_CTX_GET(i, var))->lang_id));
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ void onplay_show_playlist_cat_menu(const char* track_name, int attr,
|
|||
void onplay_show_playlist_menu(const char* path, int attr, void (*playlist_insert_cb));
|
||||
|
||||
int wps_context_menu_do_setting(void *param);
|
||||
int tree_context_menu_do_setting(void *param);
|
||||
void wps_context_menu_set_default(void* setting, void* defaultval);
|
||||
char* wps_context_menu_write_to_cfg(void* setting, char*buf, int buf_len);
|
||||
void wps_context_menu_load_from_cfg(void* setting, char *value);
|
||||
|
|
|
|||
|
|
@ -701,6 +701,10 @@ static const int wps_context_menu_default =
|
|||
#endif
|
||||
| HK_CTX_SET(4, HOTKEY_ALBUMART);
|
||||
|
||||
#ifdef HAVE_HOTKEY
|
||||
static const int tree_hotkey_default = HOTKEY_OFF;
|
||||
#endif
|
||||
|
||||
#ifndef __PCTOOL__
|
||||
static void eq_load_from_cfg(void *setting, char *value)
|
||||
{
|
||||
|
|
@ -895,21 +899,6 @@ static void tsc_set_default(void* setting, void* defaultval)
|
|||
memcpy(setting, defaultval, sizeof(struct touchscreen_parameter));
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_HOTKEY
|
||||
static const char* hotkey_formatter(char* buffer, size_t buffer_size, int value,
|
||||
const char* unit)
|
||||
{
|
||||
(void)buffer;
|
||||
(void)buffer_size;
|
||||
(void)unit;
|
||||
return str(get_hotkey(value)->lang_id);
|
||||
}
|
||||
static int32_t hotkey_getlang(int value, int unit)
|
||||
{
|
||||
(void)unit;
|
||||
return get_hotkey(value)->lang_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void start_in_callback(int var)
|
||||
{
|
||||
|
|
@ -2348,21 +2337,12 @@ const struct settings_list settings[] = {
|
|||
wps_context_menu_is_changed, wps_context_menu_set_default),
|
||||
|
||||
#ifdef HAVE_HOTKEY
|
||||
/* TREE HOTKEY */
|
||||
TABLE_SETTING(0, hotkey_tree,
|
||||
LANG_HOTKEY_FILE_BROWSER, HOTKEY_OFF, "hotkey tree",
|
||||
#ifdef HAVE_TAGCACHE
|
||||
"off,properties,pictureflow,open with,delete,insert,insert shuffled,context menu",
|
||||
UNIT_INT, hotkey_formatter, hotkey_getlang, NULL, 8,
|
||||
#else
|
||||
"off,properties,open with,delete,insert,insert shuffled,context menu",
|
||||
UNIT_INT, hotkey_formatter, hotkey_getlang, NULL, 7,
|
||||
#endif
|
||||
HOTKEY_OFF,HOTKEY_PROPERTIES,
|
||||
#ifdef HAVE_TAGCACHE
|
||||
HOTKEY_PICTUREFLOW,
|
||||
#endif
|
||||
HOTKEY_OPEN_WITH, HOTKEY_DELETE, HOTKEY_INSERT, HOTKEY_INSERT_SHUFFLED, HOTKEY_CONTEXT_MENU),
|
||||
CUSTOM_SETTING(0, hotkey_tree,
|
||||
LANG_HOTKEY_FILE_BROWSER, /* lang string here is never actually used */
|
||||
&tree_hotkey_default, "hotkey tree",
|
||||
wps_context_menu_load_from_cfg, wps_context_menu_write_to_cfg,
|
||||
wps_context_menu_is_changed, wps_context_menu_set_default),
|
||||
|
||||
#endif /* HAVE_HOTKEY */
|
||||
|
||||
INT_SETTING(F_TIME_SETTING, resume_rewind, LANG_RESUME_REWIND, 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue