tagcache: Add menu entry for customizing the DB path

Allow the database path to be set from the file browser's
"Set As" context menu, so it can be changed without editing
the .cfg file by hand.

Change-Id: Ie1a84bcb2084ee3b1a0a18cc51f564238515f164
This commit is contained in:
Aidan MacDonald 2022-06-01 02:00:30 +01:00
parent ac1f92d9e8
commit f026cc4e17
5 changed files with 47 additions and 0 deletions

View file

@ -1871,6 +1871,7 @@ static int database_callback(int btn, struct gui_synclist *lists)
stat->initialized ? "Yes" : "No"); stat->initialized ? "Yes" : "No");
simplelist_addline("DB Ready: %s", simplelist_addline("DB Ready: %s",
stat->ready ? "Yes" : "No"); stat->ready ? "Yes" : "No");
simplelist_addline("DB Path: %s", stat->db_path);
simplelist_addline("RAM Cache: %s", simplelist_addline("RAM Cache: %s",
stat->ramcache ? "Yes" : "No"); stat->ramcache ? "Yes" : "No");
simplelist_addline("RAM: %d/%d B", simplelist_addline("RAM: %d/%d B",

View file

@ -16641,3 +16641,17 @@
*: "Go to Last Album" *: "Go to Last Album"
</voice> </voice>
</phrase> </phrase>
<phrase>
id: LANG_DATABASE_DIR
desc: in database settings menu
user: core
<source>
*: "Database Directory"
</source>
<dest>
*: "Database Directory"
</dest>
<voice>
*: "Database Directory"
</voice>
</phrase>

View file

@ -1390,9 +1390,27 @@ static bool set_catalogdir(void)
MENUITEM_FUNCTION(set_catalogdir_item, 0, ID2P(LANG_PLAYLIST_DIR), MENUITEM_FUNCTION(set_catalogdir_item, 0, ID2P(LANG_PLAYLIST_DIR),
set_catalogdir, clipboard_callback, Icon_Playlist); set_catalogdir, clipboard_callback, Icon_Playlist);
static bool set_databasedir(void)
{
path_append(global_settings.tagcache_db_path, selected_file,
PA_SEP_SOFT, sizeof(global_settings.tagcache_db_path));
struct tagcache_stat *tc_stat = tagcache_get_stat();
if (strcasecmp(global_settings.tagcache_db_path, tc_stat->db_path))
{
splashf(HZ, ID2P(LANG_PLEASE_REBOOT));
}
settings_save();
return false;
}
MENUITEM_FUNCTION(set_databasedir_item, 0, ID2P(LANG_DATABASE_DIR),
set_databasedir, clipboard_callback, Icon_Audio);
MAKE_ONPLAYMENU(set_as_dir_menu, ID2P(LANG_SET_AS), MAKE_ONPLAYMENU(set_as_dir_menu, ID2P(LANG_SET_AS),
clipboard_callback, Icon_NOICON, clipboard_callback, Icon_NOICON,
&set_catalogdir_item, &set_catalogdir_item,
&set_databasedir_item,
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
&set_recdir_item, &set_recdir_item,
#endif #endif
@ -1454,6 +1472,7 @@ static int clipboard_callback(int action,
if (this_item == &delete_dir_item || if (this_item == &delete_dir_item ||
this_item == &set_startdir_item || this_item == &set_startdir_item ||
this_item == &set_catalogdir_item || this_item == &set_catalogdir_item ||
this_item == &set_databasedir_item ||
this_item == &set_as_dir_menu this_item == &set_as_dir_menu
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
|| this_item == &set_recdir_item || this_item == &set_recdir_item

View file

@ -142,6 +142,12 @@
(struct filename_setting[]){ \ (struct filename_setting[]){ \
{prefix,suffix,sizeof(global_settings.var)}}} } {prefix,suffix,sizeof(global_settings.var)}}} }
#define DIRECTORY_SETTING(flags,var,lang_id,name,default) \
{flags|F_DIRNAME|F_T_UCHARPTR, &global_settings.var, lang_id, \
CHARPTR(default), name, NULL, \
{.filename_setting=(struct filename_setting[]){ \
{NULL, NULL, sizeof(global_settings.var)}}}}
/* Used for settings which use the set_option() setting screen. /* Used for settings which use the set_option() setting screen.
The ... arg is a list of pointers to strings to display in the setting The ... arg is a list of pointers to strings to display in the setting
screen. These can either be literal strings, or ID2P(LANG_*) */ screen. These can either be literal strings, or ID2P(LANG_*) */

View file

@ -179,6 +179,13 @@ each option pertains both to files and directories):
\begin{description} \begin{description}
\item [Playlist Directory.] \item [Playlist Directory.]
Set as default directory for the Playlist Catalogue. Set as default directory for the Playlist Catalogue.
\opt{tagcache}{
\item [Database Directory.]
Rockbox usually stores database files in the \fname{/.rockbox} folder.
You can choose another location for the database using this setting.
This is mainly useful for multiboot targets, so the same database can
be shared among several builds without needing to rebuild it each time.
}
\opt{recording}{ \opt{recording}{
\item [Recording Directory.] \item [Recording Directory.]
Save recordings in the selected directory. Save recordings in the selected directory.