mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
Settings menu: add main menu customization
Lets you launch the main_menu_config plugin from Settings, so that it remains accessible, even after all other menu items have been hidden. Includes minor changes to the main menu config plugin, so that it better fits in with the rest of the settings menus: * Keep theme enabled * Autosave * Add "On" or "Off" suffix to each item, to prevent confusion when Icon_Config is blank, as is the case with certain iconsets * Update current selection after swapping items * Prefix spoken selection with row number for enhanced clarity when swapping items * Change title to LANG_MAIN_MENU * ACTION_STD_OK to toggle an item's visibility * ACTION_STD_CONTEXT to access options for reordering menu items, or for reverting to the default menu * Ask for confirmation before reverting Change-Id: I74240b94243224c76e23ef8f3a0559bd8ba28df0
This commit is contained in:
parent
dbeefebcad
commit
5efb6d7fac
7 changed files with 99 additions and 65 deletions
|
@ -14152,16 +14152,16 @@
|
|||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_TOGGLE_ITEM
|
||||
desc: in main_menu_config
|
||||
desc: deprecated
|
||||
user: core
|
||||
<source>
|
||||
*: "Toggle Item"
|
||||
*: ""
|
||||
</source>
|
||||
<dest>
|
||||
*: "Toggle Item"
|
||||
*: ""
|
||||
</dest>
|
||||
<voice>
|
||||
*: "Toggle Item"
|
||||
*: ""
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
|
@ -14222,13 +14222,13 @@
|
|||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_MAIN_MENU_ORDER
|
||||
desc: main_menu_config plugin title
|
||||
desc: deprecated
|
||||
user: core
|
||||
<source>
|
||||
*: "Rockbox Main Menu Order"
|
||||
*: ""
|
||||
</source>
|
||||
<dest>
|
||||
*: "Rockbox Main Menu Order"
|
||||
*: ""
|
||||
</dest>
|
||||
<voice>
|
||||
*: ""
|
||||
|
|
|
@ -495,6 +495,15 @@ MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_System_menu,
|
|||
/* INFO MENU */
|
||||
/***********************************/
|
||||
|
||||
static int main_menu_config(void)
|
||||
{
|
||||
plugin_load(PLUGIN_APPS_DIR "/main_menu_config.rock", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MENUITEM_FUNCTION(main_menu_config_item, 0, ID2P(LANG_MAIN_MENU),
|
||||
main_menu_config, NULL, Icon_Rockbox);
|
||||
|
||||
/***********************************/
|
||||
/* MAIN MENU */
|
||||
|
||||
|
@ -509,6 +518,7 @@ MAKE_MENU(main_menu_, ID2P(LANG_SETTINGS), NULL,
|
|||
#if CONFIG_RTC
|
||||
&timedate_item,
|
||||
#endif
|
||||
&main_menu_config_item,
|
||||
&manage_settings,
|
||||
);
|
||||
/* MAIN MENU */
|
||||
|
|
|
@ -860,7 +860,8 @@ int plugin_load(const char* plugin, const void* parameter)
|
|||
|
||||
/* for some plugins, the SBS can be left enabled */
|
||||
const char *sepch = strrchr(plugin, PATH_SEPCH);
|
||||
bool theme_enabled = sepch && !strcmp("properties.rock", sepch + 1);
|
||||
bool theme_enabled = sepch && (!strcmp("properties.rock", sepch + 1) ||
|
||||
!strcmp("main_menu_config.rock", sepch + 1));
|
||||
|
||||
if (current_plugin_handle)
|
||||
{
|
||||
|
|
|
@ -40,11 +40,14 @@ static const char * menu_get_name(int selected_item, void * data,
|
|||
char * buffer, size_t buffer_len)
|
||||
{
|
||||
(void)data;
|
||||
(void)buffer;
|
||||
(void)buffer_len;
|
||||
unsigned char *p = menu_items[selected_item].name;
|
||||
int id = P2ID(p);
|
||||
return (id != -1) ? rb->str(id) : p;
|
||||
|
||||
rb->snprintf(buffer, buffer_len, "%s: %s", (id != -1) ? rb->str(id) : p,
|
||||
menu_items[selected_item].enabled ?
|
||||
rb->str(LANG_ON) : rb->str(LANG_OFF));
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static enum themable_icons menu_get_icon(int selected_item, void * data)
|
||||
|
@ -157,7 +160,8 @@ static int menu_speak_item(int selected_item, void *data)
|
|||
|
||||
if (id != -1)
|
||||
{
|
||||
rb->talk_id(id, false);
|
||||
rb->talk_number(selected_item + 1, false);
|
||||
rb->talk_id(id, true);
|
||||
rb->talk_id(menu_items[selected_item].enabled ? LANG_ON : LANG_OFF, true);
|
||||
}
|
||||
|
||||
|
@ -172,6 +176,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
rb->global_settings->show_icons = true;
|
||||
struct gui_synclist list;
|
||||
bool done = false;
|
||||
bool changed = false;
|
||||
int action, cur_sel;
|
||||
|
||||
menu_table = rb->root_menu_get_options(&menu_item_count);
|
||||
|
@ -182,59 +187,72 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
rb->gui_synclist_set_voice_callback(&list, menu_speak_item);
|
||||
rb->gui_synclist_set_icon_callback(&list, menu_get_icon);
|
||||
rb->gui_synclist_set_nb_items(&list, menu_item_count);
|
||||
rb->gui_synclist_set_title(&list, rb->str(LANG_MAIN_MENU_ORDER), Icon_Rockbox);
|
||||
rb->gui_synclist_draw(&list);
|
||||
rb->gui_synclist_set_title(&list, rb->str(LANG_MAIN_MENU), Icon_Rockbox);
|
||||
rb->gui_synclist_speak_item(&list);
|
||||
|
||||
while (!done)
|
||||
{
|
||||
rb->gui_synclist_draw(&list);
|
||||
cur_sel = rb->gui_synclist_get_sel_pos(&list);
|
||||
action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
|
||||
action = rb->get_action(CONTEXT_LIST, HZ/10);
|
||||
if (rb->gui_synclist_do_button(&list, &action))
|
||||
continue;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_STD_OK:
|
||||
menu_items[cur_sel].enabled = !menu_items[cur_sel].enabled;
|
||||
rb->gui_synclist_speak_item(&list);
|
||||
changed = true;
|
||||
break;
|
||||
case ACTION_STD_CONTEXT:
|
||||
{
|
||||
MENUITEM_STRINGLIST(menu, "Main Menu Editor", NULL,
|
||||
ID2P(LANG_TOGGLE_ITEM),
|
||||
MENUITEM_STRINGLIST(menu, ID2P(LANG_MAIN_MENU), NULL,
|
||||
ID2P(LANG_MOVE_ITEM_UP),
|
||||
ID2P(LANG_MOVE_ITEM_DOWN),
|
||||
"----------",
|
||||
ID2P(LANG_LOAD_DEFAULT_CONFIGURATION),
|
||||
ID2P(LANG_SAVE_EXIT));
|
||||
ID2P(LANG_LOAD_DEFAULT_CONFIGURATION));
|
||||
switch (rb->do_menu(&menu, NULL, NULL, false))
|
||||
{
|
||||
case 0:
|
||||
menu_items[cur_sel].enabled = !menu_items[cur_sel].enabled;
|
||||
if (cur_sel == 0)
|
||||
{
|
||||
rb->splash(HZ, ID2P(LANG_FAILED));
|
||||
break;
|
||||
}
|
||||
swap_items(cur_sel, cur_sel - 1);
|
||||
rb->gui_synclist_select_item(&list, cur_sel - 1); /* speaks */
|
||||
changed = true;
|
||||
break;
|
||||
case 1:
|
||||
if (cur_sel == 0)
|
||||
break;
|
||||
swap_items(cur_sel, cur_sel - 1);
|
||||
break;
|
||||
case 2:
|
||||
if (cur_sel + 1 == menu_item_count)
|
||||
{
|
||||
rb->splash(HZ, ID2P(LANG_FAILED));
|
||||
break;
|
||||
}
|
||||
swap_items(cur_sel, cur_sel + 1);
|
||||
rb->gui_synclist_select_item(&list, cur_sel + 1); /* speaks */
|
||||
changed = true;
|
||||
break;
|
||||
case 4:
|
||||
rb->root_menu_set_default(&rb->global_settings->root_menu_customized, NULL);
|
||||
load_from_cfg();
|
||||
break;
|
||||
case 5:
|
||||
done = true;
|
||||
save_to_cfg();
|
||||
rb->global_settings->root_menu_customized = true;
|
||||
rb->settings_save();
|
||||
break;
|
||||
}
|
||||
if (!done)
|
||||
{
|
||||
rb->gui_synclist_draw(&list);
|
||||
rb->gui_synclist_speak_item(&list);
|
||||
case 2:;
|
||||
static const char *lines[] =
|
||||
{ID2P(LANG_RESET_ASK), ID2P(LANG_LOAD_DEFAULT_CONFIGURATION)};
|
||||
static const struct text_message message={lines, 2};
|
||||
|
||||
switch(rb->gui_syncyesno_run(&message, NULL, NULL))
|
||||
{
|
||||
case YESNO_YES:
|
||||
rb->root_menu_set_default(&rb->global_settings->root_menu_customized, NULL);
|
||||
load_from_cfg();
|
||||
break;
|
||||
default:
|
||||
rb->splash(HZ, ID2P(LANG_CANCEL));
|
||||
break;
|
||||
}
|
||||
/* fall-through */
|
||||
default:
|
||||
rb->gui_synclist_speak_item(&list);
|
||||
}
|
||||
rb->gui_synclist_set_title(&list, rb->str(LANG_MAIN_MENU), Icon_Rockbox);
|
||||
break;
|
||||
}
|
||||
case ACTION_STD_CANCEL:
|
||||
|
@ -243,6 +261,13 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
save_to_cfg();
|
||||
rb->global_settings->root_menu_customized = true;
|
||||
rb->settings_save();
|
||||
}
|
||||
rb->global_settings->show_icons = show_icons;
|
||||
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
|
||||
\subsection{\label{ref:CustomisingTheMainMenu}Customising The Main Menu}
|
||||
|
||||
It is possible to customise the main menu, i.e. to reorder or to hide some
|
||||
of its items (only the main menu can be customised, submenus can not).
|
||||
To accomplish this, load a \fname{.cfg} file (as described in
|
||||
\reference{ref:manage_settings}) containing the following line:
|
||||
The easiest way to reorder or to hide menu items is via the settings menu
|
||||
(see \reference{ref:main_menu_config}).
|
||||
|
||||
To accomplish this using a text editor instead, load a \fname{.cfg} file
|
||||
(as described in \reference{ref:manage_settings}) containing the following line:
|
||||
\config{root~menu~order:items}, where ``items'' is a comma separated list
|
||||
(no spaces around the commas!) of the following
|
||||
words: \config{bookmarks}, \config{files}, \opt{tagcache}{\config{database}, }%
|
||||
|
@ -32,10 +33,6 @@ for changing the settings (the latter will be added automatically).
|
|||
To reset the menu items to the default, use \config{root~menu~order:-} (i.e.
|
||||
use a hyphen instead of ``items'').
|
||||
|
||||
This configuration entry can only be created and edited with a text editor or
|
||||
the Main Menu Config Plugin (see \reference{ref:main_menu_config}).
|
||||
It is not possible to change this setting via the settings menu.
|
||||
|
||||
\subsection{\label{ref:CustomisingThePlayername}Customising The Playername}
|
||||
|
||||
Some themes show a customizable playername in the Whats Playing Screen.
|
||||
|
|
|
@ -141,6 +141,22 @@ to recording. The details of this menu are covered in detail in
|
|||
\reference{ref:Recordingsettings}.
|
||||
}
|
||||
|
||||
\subsection{Main Menu}
|
||||
{\label{ref:main_menu_config}}
|
||||
Allows you to hide or reorder items from the main menu.
|
||||
|
||||
Press \ActionStdOk{} to toggle an item's visibility.
|
||||
|
||||
Press \ActionStdContext{} to access the following options:
|
||||
\begin{description}
|
||||
\item[Move Item Up] Swap selected menu item with the previous one
|
||||
\item[Move Item down] Swap selected menu item with the next one
|
||||
\item[Load Default Configuration] Discard all customization
|
||||
\end{description}
|
||||
|
||||
For an advanced description of the associated configuration entry,
|
||||
see \reference{ref:CustomisingTheMainMenu}.
|
||||
|
||||
\subsection{Manage Settings}
|
||||
The \setting{Manage Settings} option allows the saving and re-loading of user
|
||||
configuration settings, browsing the hard drive for alternate firmwares, and finally
|
||||
|
|
|
@ -1,17 +1,2 @@
|
|||
\subsection{Main Menu Configuration}
|
||||
{\label{ref:main_menu_config}}
|
||||
|
||||
This plugin helps you customizing the main menu (i.e. reorder or hide menu
|
||||
items). It changes the appropriate configuration file as described in
|
||||
\reference{ref:CustomisingTheMainMenu}.
|
||||
|
||||
When you start the plugin, the available main menu items will be displayed.
|
||||
By pressing \ActionStdOk{} you open a menu with the following options:
|
||||
\begin{description}
|
||||
\item[Toggle Item] Hide the selected menu item or make it visible again
|
||||
\item[Move Item Up] Swap the selected menu item with the previous one
|
||||
\item[Move Item down] Swap the selected menu item with the next one
|
||||
\item[Load Default Configuration] Discards all customization
|
||||
\item[Exit] Save your changes to the configuration file and exit the plugin
|
||||
\end{description}
|
||||
You can leave the plugin without saving by pressing \ActionStdCancel{}.
|
||||
see \reference{ref:main_menu_config}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue