support for switching between supported lyrics databases at runtime
This commit is contained in:
@@ -151,6 +151,7 @@ void GetKeybindings(Scrollpad &help)
|
||||
help << DisplayKeys(Key.SongInfo) << "Show song's info\n";
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
help << DisplayKeys(Key.ArtistInfo) << "Show artist's info\n";
|
||||
help << DisplayKeys(Key.ToggleLyricsDB) << "Toggle lyrics database\n";
|
||||
# endif // HAVE_CURL_CURL_H
|
||||
help << DisplayKeys(Key.Lyrics) << "Show/hide song's lyrics\n\n";
|
||||
|
||||
|
||||
@@ -285,13 +285,20 @@ namespace
|
||||
lyricsplugin_not_found
|
||||
};
|
||||
|
||||
const char *lyricsplugins_list[] =
|
||||
{
|
||||
"lyricwiki.org",
|
||||
"lyricsplugin.com",
|
||||
0
|
||||
};
|
||||
|
||||
const LyricsPlugin *ChooseLyricsPlugin(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
return &lyricwiki;
|
||||
case 2:
|
||||
case 1:
|
||||
return &lyricsplugin;
|
||||
default:
|
||||
return &lyricwiki;
|
||||
@@ -299,6 +306,11 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetLyricsPluginName(int offset)
|
||||
{
|
||||
return lyricsplugins_list[offset];
|
||||
}
|
||||
|
||||
#endif // HAVE_CURL_CURL_H
|
||||
|
||||
void *GetLyrics(void *song)
|
||||
|
||||
@@ -36,6 +36,8 @@ struct LyricsPlugin
|
||||
bool (*not_found)(const string &);
|
||||
};
|
||||
|
||||
const char *GetLyricsPluginName(int);
|
||||
|
||||
#endif
|
||||
|
||||
void * GetLyrics(void *);
|
||||
|
||||
@@ -2562,6 +2562,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
// redraw_screen = 1;
|
||||
}
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
else if (Keypressed(input, Key.ToggleLyricsDB))
|
||||
{
|
||||
const char *current_lyrics_plugin = GetLyricsPluginName(++Config.lyrics_db);
|
||||
if (!current_lyrics_plugin)
|
||||
{
|
||||
current_lyrics_plugin = GetLyricsPluginName(Config.lyrics_db = 0);
|
||||
}
|
||||
ShowMessage("Using lyrics database: %s", current_lyrics_plugin);
|
||||
}
|
||||
# endif // HAVE_CURL_CURL_H
|
||||
else if (Keypressed(input, Key.ToggleAutoCenter))
|
||||
{
|
||||
Config.autocenter_mode = !Config.autocenter_mode;
|
||||
|
||||
@@ -160,6 +160,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.StartSearching[0] = 'y';
|
||||
keys.ToggleAutoCenter[0] = 'U';
|
||||
keys.ToggleDisplayMode[0] = 'p';
|
||||
keys.ToggleLyricsDB[0] = 'L';
|
||||
keys.GoToParentDir[0] = 263;
|
||||
keys.SwitchTagTypeList[0] = '`';
|
||||
keys.Quit[0] = 'q';
|
||||
@@ -223,6 +224,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.StartSearching[1] = null_key;
|
||||
keys.ToggleAutoCenter[1] = null_key;
|
||||
keys.ToggleDisplayMode[1] = null_key;
|
||||
keys.ToggleLyricsDB[1] = null_key;
|
||||
keys.GoToParentDir[1] = 127;
|
||||
keys.SwitchTagTypeList[1] = null_key;
|
||||
keys.Quit[1] = 'Q';
|
||||
@@ -284,7 +286,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.seek_time = 1;
|
||||
conf.playlist_disable_highlight_delay = 5;
|
||||
conf.message_delay_time = 4;
|
||||
conf.lyrics_db = 1;
|
||||
conf.lyrics_db = 0;
|
||||
}
|
||||
|
||||
string GetLineValue(string &line, char a, char b, bool once)
|
||||
@@ -481,6 +483,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
||||
GetKeys(key, keys.ToggleAutoCenter);
|
||||
else if (key.find("key_toggle_display_mode ") != string::npos)
|
||||
GetKeys(key, keys.ToggleDisplayMode);
|
||||
else if (key.find("key_toggle_lyrics_db ") != string::npos)
|
||||
GetKeys(key, keys.ToggleLyricsDB);
|
||||
else if (key.find("key_go_to_containing_directory ") != string::npos)
|
||||
GetKeys(key, keys.GoToContainingDir);
|
||||
else if (key.find("key_start_searching ") != string::npos)
|
||||
@@ -703,7 +707,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
else if (cl.find("lyrics_database") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.lyrics_db = StrToInt(v);
|
||||
conf.lyrics_db = StrToInt(v)-1;
|
||||
}
|
||||
else if (cl.find("song_window_title_format") != string::npos)
|
||||
{
|
||||
|
||||
@@ -88,6 +88,7 @@ struct ncmpcpp_keys
|
||||
int StartSearching[2];
|
||||
int ToggleAutoCenter[2];
|
||||
int ToggleDisplayMode[2];
|
||||
int ToggleLyricsDB[2];
|
||||
int GoToParentDir[2];
|
||||
int SwitchTagTypeList[2];
|
||||
int Quit[2];
|
||||
|
||||
Reference in New Issue
Block a user