add tag type list switcher to media library

This commit is contained in:
unK
2008-10-04 20:20:21 +02:00
parent d5bdec41f7
commit 109f49430e
5 changed files with 56 additions and 21 deletions

View File

@@ -130,5 +130,7 @@
# #
#key_go_to_parent_dir = 263 127 #key_go_to_parent_dir = 263 127
# #
#key_switch_tag_type_list = '`'
#
#key_quit = 'q' 'Q' #key_quit = 'q' 'Q'
# #

View File

@@ -179,8 +179,8 @@ string GetKeybindings()
result += DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n"; result += DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n";
result += DisplayKeys(&Key.VolumeUp[0], 1) + "Next column\n"; result += DisplayKeys(&Key.VolumeUp[0], 1) + "Next column\n";
result += DisplayKeys(Key.Enter) + "Add to playlist and play song/album/artist's songs\n"; result += DisplayKeys(Key.Enter) + "Add to playlist and play song/album/artist's songs\n";
result += DisplayKeys(Key.Space) + "Add to playlist song/album/artist's songs\n\n\n"; result += DisplayKeys(Key.Space) + "Add to playlist song/album/artist's songs\n";
result += DisplayKeys(Key.SwitchTagTypeList) + "Tag type list switcher (left column)\n\n\n";
result += " [.b]Keys - Playlist Editor\n -----------------------------------------[/b]\n"; result += " [.b]Keys - Playlist Editor\n -----------------------------------------[/b]\n";
result += DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n"; result += DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n";

View File

@@ -3051,6 +3051,33 @@ int main(int argc, char *argv[])
Config.ncmpc_like_songs_adding = !Config.ncmpc_like_songs_adding; Config.ncmpc_like_songs_adding = !Config.ncmpc_like_songs_adding;
ShowMessage("Add mode: " + string(Config.ncmpc_like_songs_adding ? "Add item to playlist, remove if already added" : "Always add item to playlist")); ShowMessage("Add mode: " + string(Config.ncmpc_like_songs_adding ? "Add item to playlist, remove if already added" : "Always add item to playlist"));
} }
else if (Keypressed(input, Key.SwitchTagTypeList) && wCurrent == mLibArtists)
{
LockStatusbar();
wFooter->WriteXY(0, Config.statusbar_visibility, "Tag type ? [[.b]a[/b]rtist/[.b]y[/b]ear/[.b]g[/b]enre/[.b]c[/b]omposer/[.b]p[/b]erformer] ", 1);
int item;
curs_set(1);
do
{
TraceMpdStatus();
wFooter->ReadKey(item);
}
while (item != 'a' && item != 'y' && item != 'g' && item != 'c' && item != 'p');
curs_set(0);
UnlockStatusbar();
mpd_TagItems new_tagitem = IntoTagItem(item);
if (new_tagitem != Config.media_lib_primary_tag)
{
Config.media_lib_primary_tag = new_tagitem;
string item_type = IntoStr(Config.media_lib_primary_tag);
mLibArtists->SetTitle(item_type + "s");
mLibArtists->Reset();
mLibArtists->Clear(0);
mLibArtists->Display();
ToLower(item_type);
ShowMessage("Switched to list of " + item_type + " tag");
}
}
else if (Keypressed(input, Key.SongInfo)) else if (Keypressed(input, Key.SongInfo))
{ {
if (wCurrent == sInfo) if (wCurrent == sInfo)

View File

@@ -92,6 +92,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
keys.ToggleAutoCenter[0] = 'U'; keys.ToggleAutoCenter[0] = 'U';
keys.TogglePlaylistDisplayMode[0] = 'p'; keys.TogglePlaylistDisplayMode[0] = 'p';
keys.GoToParentDir[0] = 263; keys.GoToParentDir[0] = 263;
keys.SwitchTagTypeList[0] = '`';
keys.Quit[0] = 'q'; keys.Quit[0] = 'q';
keys.Up[1] = 'k'; keys.Up[1] = 'k';
@@ -153,6 +154,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
keys.ToggleAutoCenter[1] = null_key; keys.ToggleAutoCenter[1] = null_key;
keys.TogglePlaylistDisplayMode[1] = null_key; keys.TogglePlaylistDisplayMode[1] = null_key;
keys.GoToParentDir[1] = 127; keys.GoToParentDir[1] = 127;
keys.SwitchTagTypeList[1] = null_key;
keys.Quit[1] = 'Q'; keys.Quit[1] = 'Q';
} }
@@ -252,6 +254,25 @@ string IntoStr(Color color)
return result; return result;
} }
mpd_TagItems IntoTagItem(char c)
{
switch (c)
{
case 'a':
return MPD_TAG_ITEM_ARTIST;
case 'y':
return MPD_TAG_ITEM_DATE;
case 'g':
return MPD_TAG_ITEM_GENRE;
case 'c':
return MPD_TAG_ITEM_COMPOSER;
case 'p':
return MPD_TAG_ITEM_PERFORMER;
default:
return MPD_TAG_ITEM_ARTIST;
}
}
namespace namespace
{ {
void GetKeys(string line, int *key) void GetKeys(string line, int *key)
@@ -277,25 +298,6 @@ namespace
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str())); key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
} }
mpd_TagItems IntoTagItem(char c)
{
switch (c)
{
case 'a':
return MPD_TAG_ITEM_ARTIST;
case 'y':
return MPD_TAG_ITEM_DATE;
case 'g':
return MPD_TAG_ITEM_GENRE;
case 'c':
return MPD_TAG_ITEM_COMPOSER;
case 'p':
return MPD_TAG_ITEM_PERFORMER;
default:
return MPD_TAG_ITEM_ARTIST;
}
}
Color IntoColor(const string &color) Color IntoColor(const string &color)
{ {
Color result = clDefault; Color result = clDefault;
@@ -461,6 +463,8 @@ void ReadKeys(ncmpcpp_keys &keys)
GetKeys(*it, keys.StartSearching); GetKeys(*it, keys.StartSearching);
else if (it->find("key_go_to_parent_dir ") != string::npos) else if (it->find("key_go_to_parent_dir ") != string::npos)
GetKeys(*it, keys.GoToParentDir); GetKeys(*it, keys.GoToParentDir);
else if (it->find("key_switch_tag_type_list ") != string::npos)
GetKeys(*it, keys.SwitchTagTypeList);
else if (it->find("key_quit ") != string::npos) else if (it->find("key_quit ") != string::npos)
GetKeys(*it, keys.Quit); GetKeys(*it, keys.Quit);
} }

View File

@@ -90,6 +90,7 @@ struct ncmpcpp_keys
int ToggleAutoCenter[2]; int ToggleAutoCenter[2];
int TogglePlaylistDisplayMode[2]; int TogglePlaylistDisplayMode[2];
int GoToParentDir[2]; int GoToParentDir[2];
int SwitchTagTypeList[2];
int Quit[2]; int Quit[2];
}; };
@@ -158,6 +159,7 @@ void ReadKeys(ncmpcpp_keys &);
void ReadConfiguration(ncmpcpp_config &); void ReadConfiguration(ncmpcpp_config &);
string IntoStr(Color); string IntoStr(Color);
mpd_TagItems IntoTagItem(char);
string GetLineValue(const string &, char = '"', char = '"'); string GetLineValue(const string &, char = '"', char = '"');
#endif #endif