diff --git a/doc/keys b/doc/keys index e4b8b0e0..07ebcf25 100644 --- a/doc/keys +++ b/doc/keys @@ -130,5 +130,7 @@ # #key_go_to_parent_dir = 263 127 # +#key_switch_tag_type_list = '`' +# #key_quit = 'q' 'Q' # diff --git a/src/help.cpp b/src/help.cpp index 940a1016..6a8dbad1 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -179,8 +179,8 @@ string GetKeybindings() result += DisplayKeys(&Key.VolumeDown[0], 1) + "Previous 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.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 += DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n"; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index fdbf7225..343d87cf 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -3051,6 +3051,33 @@ int main(int argc, char *argv[]) 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")); } + 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)) { if (wCurrent == sInfo) diff --git a/src/settings.cpp b/src/settings.cpp index 630cf579..23223241 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -92,6 +92,7 @@ void DefaultKeys(ncmpcpp_keys &keys) keys.ToggleAutoCenter[0] = 'U'; keys.TogglePlaylistDisplayMode[0] = 'p'; keys.GoToParentDir[0] = 263; + keys.SwitchTagTypeList[0] = '`'; keys.Quit[0] = 'q'; keys.Up[1] = 'k'; @@ -153,6 +154,7 @@ void DefaultKeys(ncmpcpp_keys &keys) keys.ToggleAutoCenter[1] = null_key; keys.TogglePlaylistDisplayMode[1] = null_key; keys.GoToParentDir[1] = 127; + keys.SwitchTagTypeList[1] = null_key; keys.Quit[1] = 'Q'; } @@ -252,6 +254,25 @@ string IntoStr(Color color) 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 { 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())); } - 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 result = clDefault; @@ -461,6 +463,8 @@ void ReadKeys(ncmpcpp_keys &keys) GetKeys(*it, keys.StartSearching); else if (it->find("key_go_to_parent_dir ") != string::npos) 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) GetKeys(*it, keys.Quit); } diff --git a/src/settings.h b/src/settings.h index 4da960b6..c36cd684 100644 --- a/src/settings.h +++ b/src/settings.h @@ -90,6 +90,7 @@ struct ncmpcpp_keys int ToggleAutoCenter[2]; int TogglePlaylistDisplayMode[2]; int GoToParentDir[2]; + int SwitchTagTypeList[2]; int Quit[2]; }; @@ -158,6 +159,7 @@ void ReadKeys(ncmpcpp_keys &); void ReadConfiguration(ncmpcpp_config &); string IntoStr(Color); +mpd_TagItems IntoTagItem(char); string GetLineValue(const string &, char = '"', char = '"'); #endif