Shortcuts.c -- Update

Fix returns from shortcuts -- should now run plugins
Fix formatting of file names to remove path from browser shortcuts

Change-Id: I46e337110d04b84bedcb0c2945d5dd29a1860847
This commit is contained in:
William Wilgus 2021-03-07 10:07:49 -05:00
parent 0dce973729
commit 9712d375ce
7 changed files with 51 additions and 22 deletions

View file

@ -398,7 +398,7 @@ static const struct settings_list *get_setting(int gs_value,
return defaultval; return defaultval;
} }
bool quick_screen_quick(int button_enter) int 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;
@ -439,7 +439,7 @@ bool quick_screen_quick(int button_enter)
playlist_sort(NULL, true); playlist_sort(NULL, true);
} }
} }
return usb; return (usb ? 1:0);
} }
/* stuff to make the quickscreen configurable */ /* stuff to make the quickscreen configurable */

View file

@ -43,7 +43,7 @@ struct gui_quickscreen
item is changed */ item is changed */
}; };
extern bool quick_screen_quick(int button_enter); extern int quick_screen_quick(int button_enter);
int quickscreen_set_option(void *data); int quickscreen_set_option(void *data);
bool is_setting_quickscreenable(const struct settings_list *setting); bool is_setting_quickscreenable(const struct settings_list *setting);
void set_as_qs_item(const struct settings_list *setting, void set_as_qs_item(const struct settings_list *setting,

View file

@ -836,7 +836,12 @@ long gui_wps_show(void)
case ACTION_WPS_QUICKSCREEN: case ACTION_WPS_QUICKSCREEN:
{ {
gwps_leave_wps(); gwps_leave_wps();
if (quick_screen_quick(button)) if (global_settings.shortcuts_replaces_qs)
{
global_status.last_screen = GO_TO_SHORTCUTMENU;
return quick_screen_quick(button);
}
else if (quick_screen_quick(button) > 0)
return GO_TO_ROOT; return GO_TO_ROOT;
restore = true; restore = true;
} }

View file

@ -427,7 +427,13 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
#ifdef HAVE_QUICKSCREEN #ifdef HAVE_QUICKSCREEN
else if (action == ACTION_STD_QUICKSCREEN) else if (action == ACTION_STD_QUICKSCREEN)
{ {
quick_screen_quick(action); if (global_settings.shortcuts_replaces_qs)
{
global_status.last_screen = GO_TO_SHORTCUTMENU;
ret = quick_screen_quick(action);
}
else
quick_screen_quick(action);
redraw_lists = true; redraw_lists = true;
} }
#endif #endif

View file

@ -822,21 +822,27 @@ void root_menu(void)
case GO_TO_PLUGIN: case GO_TO_PLUGIN:
{ {
char *key; char *key;
switch (last_screen) if (global_status.last_screen == GO_TO_SHORTCUTMENU)
{ {
case GO_TO_ROOT: global_status.last_screen = last_screen;
key = ID2P(LANG_START_SCREEN); key = ID2P(LANG_SHORTCUTS);
break;
case GO_TO_WPS:
key = ID2P(LANG_OPEN_PLUGIN_SET_WPS_CONTEXT_PLUGIN);
break;
case GO_TO_SHORTCUTMENU:
key = ID2P(LANG_SHORTCUTS);
break;
default:
key = ID2P(LANG_OPEN_PLUGIN);
break;
} }
else
switch (last_screen)
{
case GO_TO_ROOT:
key = ID2P(LANG_START_SCREEN);
break;
case GO_TO_WPS:
key = ID2P(LANG_OPEN_PLUGIN_SET_WPS_CONTEXT_PLUGIN);
break;
case GO_TO_SHORTCUTMENU:
key = ID2P(LANG_SHORTCUTS);
break;
default:
key = ID2P(LANG_OPEN_PLUGIN);
break;
}
open_plugin_get_entry(key, &open_plugin_entry); open_plugin_get_entry(key, &open_plugin_entry);
char *path = open_plugin_entry.path; char *path = open_plugin_entry.path;

View file

@ -395,8 +395,6 @@ static const char * shortcut_menu_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len) char * buffer, size_t buffer_len)
{ {
(void)data; (void)data;
(void)buffer;
(void)buffer_len;
struct shortcut *sc = get_shortcut(selected_item); struct shortcut *sc = get_shortcut(selected_item);
if (!sc) if (!sc)
return ""; return "";
@ -409,6 +407,16 @@ static const char * shortcut_menu_get_name(int selected_item, void * data,
/* No translation support as only soft_shutdown has LANG_SHUTDOWN defined */ /* No translation support as only soft_shutdown has LANG_SHUTDOWN defined */
return type_strings[SHORTCUT_SHUTDOWN]; return type_strings[SHORTCUT_SHUTDOWN];
} }
else if (sc->type == SHORTCUT_BROWSER && (sc->u.path)[0] != '\0')
{
char* pos;
if (path_basename(sc->u.path, (const char **)&pos) > 0)
{
if (snprintf(buffer, buffer_len, "%s (%s)", pos, sc->u.path) < (int)buffer_len)
return buffer;
}
}
return sc->name[0] ? sc->name : sc->u.path; return sc->name[0] ? sc->name : sc->u.path;
} }
@ -609,7 +617,6 @@ int do_shortcut_menu(void *ignored)
/* else fall through */ /* else fall through */
case SHORTCUT_BROWSER: case SHORTCUT_BROWSER:
{ {
if(open_plugin_add_path(ID2P(LANG_SHORTCUTS), sc->u.path, NULL) != 0) if(open_plugin_add_path(ID2P(LANG_SHORTCUTS), sc->u.path, NULL) != 0)
{ {
done = GO_TO_PLUGIN; done = GO_TO_PLUGIN;

View file

@ -738,7 +738,12 @@ static int dirbrowse(void)
/* don't enter f2 from plugin browser */ /* don't enter f2 from plugin browser */
if (*tc.dirfilter < NUM_FILTER_MODES) if (*tc.dirfilter < NUM_FILTER_MODES)
{ {
if (quick_screen_quick(button)) if (global_settings.shortcuts_replaces_qs)
{
global_status.last_screen = GO_TO_SHORTCUTMENU;
return quick_screen_quick(button);
}
else if (quick_screen_quick(button))
reload_dir = true; reload_dir = true;
restore = true; restore = true;
} }