support for user defined tag type in left column of media library
This commit is contained in:
@@ -65,6 +65,8 @@
|
|||||||
#
|
#
|
||||||
#song_library_format = "{%n - }{%t}|{%f}"
|
#song_library_format = "{%n - }{%t}|{%f}"
|
||||||
#
|
#
|
||||||
|
#media_library_album_format = "{(%y) }%b"
|
||||||
|
#
|
||||||
#tag_editor_album_format = "{(%y) }%b"
|
#tag_editor_album_format = "{(%y) }%b"
|
||||||
#
|
#
|
||||||
#browser_playlist_prefix = "[.red]playlist[/red] "
|
#browser_playlist_prefix = "[.red]playlist[/red] "
|
||||||
@@ -104,6 +106,8 @@
|
|||||||
#
|
#
|
||||||
#repeat_one_mode = "no"
|
#repeat_one_mode = "no"
|
||||||
#
|
#
|
||||||
|
#media_library_left_column = "a" (possible values: a,y,g,c,p, legend above)
|
||||||
|
#
|
||||||
#default_find_mode = "wrapped" (wrapped/normal)
|
#default_find_mode = "wrapped" (wrapped/normal)
|
||||||
#
|
#
|
||||||
#default_space_mode = "add" (add/select)
|
#default_space_mode = "add" (add/select)
|
||||||
|
|||||||
112
src/ncmpcpp.cpp
112
src/ncmpcpp.cpp
@@ -35,7 +35,9 @@
|
|||||||
mvvline(main_start_y, middle_col_startx-1, 0, main_height); \
|
mvvline(main_start_y, middle_col_startx-1, 0, main_height); \
|
||||||
mLibAlbums->Display(redraw_screen); \
|
mLibAlbums->Display(redraw_screen); \
|
||||||
mvvline(main_start_y, right_col_startx-1, 0, main_height); \
|
mvvline(main_start_y, right_col_startx-1, 0, main_height); \
|
||||||
mLibSongs->Display(redraw_screen)
|
mLibSongs->Display(redraw_screen); \
|
||||||
|
if (mLibAlbums->Empty()) \
|
||||||
|
mLibAlbums->WriteXY(0, 0, "No albums found.")
|
||||||
|
|
||||||
#define REFRESH_PLAYLIST_EDITOR_SCREEN \
|
#define REFRESH_PLAYLIST_EDITOR_SCREEN \
|
||||||
mPlaylistList->Display(redraw_screen); \
|
mPlaylistList->Display(redraw_screen); \
|
||||||
@@ -213,7 +215,7 @@ int main(int argc, char *argv[])
|
|||||||
int right_col_width = COLS-COLS/3*2-1;
|
int right_col_width = COLS-COLS/3*2-1;
|
||||||
int right_col_startx = left_col_width+middle_col_width+2;
|
int right_col_startx = left_col_width+middle_col_width+2;
|
||||||
|
|
||||||
mLibArtists = new Menu<string>(0, main_start_y, left_col_width, main_height, "Artists", Config.main_color, brNone);
|
mLibArtists = new Menu<string>(0, main_start_y, left_col_width, main_height, IntoStr(Config.media_lib_primary_tag) + "s", Config.main_color, brNone);
|
||||||
mLibArtists->HighlightColor(Config.main_highlight_color);
|
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||||
mLibArtists->SetTimeout(ncmpcpp_window_timeout);
|
mLibArtists->SetTimeout(ncmpcpp_window_timeout);
|
||||||
|
|
||||||
@@ -432,55 +434,65 @@ int main(int argc, char *argv[])
|
|||||||
TagList list;
|
TagList list;
|
||||||
mLibAlbums->Clear(0);
|
mLibAlbums->Clear(0);
|
||||||
mLibSongs->Clear(0);
|
mLibSongs->Clear(0);
|
||||||
Mpd->GetArtists(list);
|
if (Config.media_lib_primary_tag == MPD_TAG_ITEM_ARTIST)
|
||||||
|
Mpd->GetArtists(list);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Mpd->StartSearch(0);
|
||||||
|
Mpd->AddSearch(Config.media_lib_primary_tag, "");
|
||||||
|
Mpd->StartFieldSearch(Config.media_lib_primary_tag);
|
||||||
|
Mpd->CommitSearch(list);
|
||||||
|
sort(list.begin(), list.end());
|
||||||
|
}
|
||||||
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
||||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
mLibArtists->AddOption(*it);
|
{
|
||||||
|
if (mLibArtists->Empty() || mLibArtists->Back() != *it)
|
||||||
|
mLibArtists->AddOption(*it);
|
||||||
|
}
|
||||||
mLibArtists->Window::Clear();
|
mLibArtists->Window::Clear();
|
||||||
mLibArtists->Refresh();
|
mLibArtists->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLibAlbums->Empty() && mLibSongs->Empty())
|
if (!mLibArtists->Empty() && mLibAlbums->Empty() && mLibSongs->Empty())
|
||||||
{
|
{
|
||||||
mLibAlbums->Reset();
|
mLibAlbums->Reset();
|
||||||
TagList list;
|
TagList list;
|
||||||
std::map<string, string, CaseInsensitiveSorting> maplist;
|
std::map<string, string, CaseInsensitiveSorting> maplist;
|
||||||
Mpd->GetAlbums(mLibArtists->GetOption(), list);
|
if (Config.media_lib_primary_tag == MPD_TAG_ITEM_ARTIST)
|
||||||
|
Mpd->GetAlbums(mLibArtists->GetOption(), list);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Mpd->StartSearch(1);
|
||||||
|
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->GetOption());
|
||||||
|
Mpd->StartFieldSearch(MPD_TAG_ITEM_ALBUM);
|
||||||
|
Mpd->CommitSearch(list);
|
||||||
|
//sort(list.begin(), list.end());
|
||||||
|
}
|
||||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
bool written = 0;
|
|
||||||
SongList l;
|
SongList l;
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetOption());
|
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->GetOption());
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
||||||
Mpd->CommitSearch(l);
|
Mpd->CommitSearch(l);
|
||||||
for (SongList::const_iterator j = l.begin(); j != l.end(); j++)
|
maplist[DisplaySong(*l[0], &Config.media_lib_album_format)] = *it;
|
||||||
{
|
|
||||||
if ((*j)->GetYear() != EMPTY_TAG)
|
|
||||||
{
|
|
||||||
maplist["(" + (*j)->GetYear() + ") " + *it] = *it;
|
|
||||||
written = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!written)
|
|
||||||
maplist[*it] = *it;
|
|
||||||
FreeSongList(l);
|
FreeSongList(l);
|
||||||
}
|
}
|
||||||
for (std::map<string, string>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
for (std::map<string, string>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
||||||
mLibAlbums->AddOption(StringPair(it->first, it->second));
|
mLibAlbums->AddOption(make_pair(it->first, it->second));
|
||||||
mLibAlbums->Window::Clear();
|
mLibAlbums->Window::Clear();
|
||||||
mLibAlbums->Refresh();
|
mLibAlbums->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wCurrent == mLibAlbums && mLibAlbums->Empty())
|
if (!mLibArtists->Empty() && wCurrent == mLibAlbums && mLibAlbums->Empty())
|
||||||
{
|
{
|
||||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
mLibArtists->HighlightColor(Config.active_column_color);
|
mLibArtists->HighlightColor(Config.active_column_color);
|
||||||
wCurrent = mLibArtists;
|
wCurrent = mLibArtists;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLibSongs->Empty())
|
if (!mLibArtists->Empty() && mLibSongs->Empty())
|
||||||
{
|
{
|
||||||
mLibSongs->Reset();
|
mLibSongs->Reset();
|
||||||
SongList list;
|
SongList list;
|
||||||
@@ -489,14 +501,14 @@ int main(int argc, char *argv[])
|
|||||||
mLibAlbums->WriteXY(0, 0, "No albums found.");
|
mLibAlbums->WriteXY(0, 0, "No albums found.");
|
||||||
mLibSongs->Clear(0);
|
mLibSongs->Clear(0);
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetOption());
|
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->GetOption());
|
||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLibSongs->Clear(0);
|
mLibSongs->Clear(0);
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetOption());
|
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->GetOption());
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, mLibAlbums->Current().second);
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, mLibAlbums->Current().second);
|
||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
}
|
}
|
||||||
@@ -595,7 +607,6 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->GetAlbums("", list);
|
Mpd->GetAlbums("", list);
|
||||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
bool written = 0;
|
|
||||||
SongList l;
|
SongList l;
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
||||||
@@ -604,7 +615,7 @@ int main(int argc, char *argv[])
|
|||||||
FreeSongList(l);
|
FreeSongList(l);
|
||||||
}
|
}
|
||||||
for (std::map<string, string>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
for (std::map<string, string>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
||||||
mEditorAlbums->AddOption(StringPair(it->first, it->second));
|
mEditorAlbums->AddOption(make_pair(it->first, it->second));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -615,13 +626,13 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int slash = editor_browsed_dir.find_last_of("/");
|
int slash = editor_browsed_dir.find_last_of("/");
|
||||||
string parent = slash != string::npos ? editor_browsed_dir.substr(0, slash) : "/";
|
string parent = slash != string::npos ? editor_browsed_dir.substr(0, slash) : "/";
|
||||||
mEditorDirs->AddOption(StringPair("[..]", parent));
|
mEditorDirs->AddOption(make_pair("[..]", parent));
|
||||||
}
|
}
|
||||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
int slash = it->find_last_of("/");
|
int slash = it->find_last_of("/");
|
||||||
string to_display = slash != string::npos ? it->substr(slash+1) : *it;
|
string to_display = slash != string::npos ? it->substr(slash+1) : *it;
|
||||||
mEditorDirs->AddOption(StringPair(to_display, *it));
|
mEditorDirs->AddOption(make_pair(to_display, *it));
|
||||||
if (*it == editor_highlighted_dir)
|
if (*it == editor_highlighted_dir)
|
||||||
highlightme = mEditorDirs->Size()-1;
|
highlightme = mEditorDirs->Size()-1;
|
||||||
}
|
}
|
||||||
@@ -1312,15 +1323,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (wCurrent == mLibArtists)
|
if (wCurrent == mLibArtists)
|
||||||
{
|
{
|
||||||
const string &artist = mLibArtists->GetOption();
|
const string &tag = mLibArtists->GetOption();
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, artist);
|
Mpd->AddSearch(Config.media_lib_primary_tag, tag);
|
||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
Mpd->QueueAddSong(**it);
|
Mpd->QueueAddSong(**it);
|
||||||
if (Mpd->CommitQueue())
|
if (Mpd->CommitQueue())
|
||||||
{
|
{
|
||||||
ShowMessage("Adding all songs artist's: " + artist);
|
string tag_type = IntoStr(Config.media_lib_primary_tag);
|
||||||
|
ToLower(tag_type);
|
||||||
|
ShowMessage("Adding songs of " + tag_type + " \"" + tag + "\"");
|
||||||
Song *s = &mPlaylist->at(mPlaylist->Size()-list.size());
|
Song *s = &mPlaylist->at(mPlaylist->Size()-list.size());
|
||||||
if (s->GetHash() == list[0]->GetHash())
|
if (s->GetHash() == list[0]->GetHash())
|
||||||
{
|
{
|
||||||
@@ -1337,7 +1350,7 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->QueueAddSong(mLibSongs->at(i));
|
Mpd->QueueAddSong(mLibSongs->at(i));
|
||||||
if (Mpd->CommitQueue())
|
if (Mpd->CommitQueue())
|
||||||
{
|
{
|
||||||
ShowMessage("Adding songs from: " + mLibArtists->GetOption() + " \"" + mLibAlbums->Current().second + "\"");
|
ShowMessage("Adding songs from album \"" + mLibAlbums->Current().second + "\"");
|
||||||
Song *s = &mPlaylist->at(mPlaylist->Size()-mLibSongs->Size());
|
Song *s = &mPlaylist->at(mPlaylist->Size()-mLibSongs->Size());
|
||||||
if (s->GetHash() == mLibSongs->at(0).GetHash())
|
if (s->GetHash() == mLibSongs->at(0).GetHash())
|
||||||
{
|
{
|
||||||
@@ -1826,6 +1839,8 @@ int main(int argc, char *argv[])
|
|||||||
vFoundPositions.clear();
|
vFoundPositions.clear();
|
||||||
if (wCurrent == mLibArtists)
|
if (wCurrent == mLibArtists)
|
||||||
{
|
{
|
||||||
|
if (mLibSongs->Empty())
|
||||||
|
continue;
|
||||||
mLibArtists->HighlightColor(Config.main_highlight_color);
|
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
wCurrent = mLibAlbums;
|
wCurrent = mLibAlbums;
|
||||||
@@ -1833,7 +1848,7 @@ int main(int argc, char *argv[])
|
|||||||
if (!mLibAlbums->Empty())
|
if (!mLibAlbums->Empty())
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (wCurrent == mLibAlbums)
|
if (wCurrent == mLibAlbums && !mLibSongs->Empty())
|
||||||
{
|
{
|
||||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
@@ -2432,33 +2447,38 @@ int main(int argc, char *argv[])
|
|||||||
if (wCurrent == mLibArtists)
|
if (wCurrent == mLibArtists)
|
||||||
{
|
{
|
||||||
LockStatusbar();
|
LockStatusbar();
|
||||||
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Artist:[/b] ", 1);
|
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]" + IntoStr(Config.media_lib_primary_tag) + ":[/b] ", 1);
|
||||||
string new_artist = wFooter->GetString(mLibArtists->GetOption());
|
string new_tag = wFooter->GetString(mLibArtists->GetOption());
|
||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
if (!new_artist.empty() && new_artist != mLibArtists->GetOption())
|
if (!new_tag.empty() && new_tag != mLibArtists->GetOption())
|
||||||
{
|
{
|
||||||
bool success = 1;
|
bool success = 1;
|
||||||
SongList list;
|
SongList list;
|
||||||
ShowMessage("Updating tags...");
|
ShowMessage("Updating tags...");
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetOption());
|
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->GetOption());
|
||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
|
SongSetFunction set = IntoSetFunction(Config.media_lib_primary_tag);
|
||||||
|
if (!set)
|
||||||
|
continue;
|
||||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
|
((*it)->*set)(new_tag);
|
||||||
|
ShowMessage("Updating tags in '" + (*it)->GetName() + "'...");
|
||||||
string path = Config.mpd_music_dir + (*it)->GetFile();
|
string path = Config.mpd_music_dir + (*it)->GetFile();
|
||||||
TagLib::FileRef f(path.c_str());
|
if (!WriteTags(**it))
|
||||||
if (f.isNull())
|
|
||||||
{
|
{
|
||||||
|
ShowMessage("Error updating tags in '" + (*it)->GetFile() + "'!");
|
||||||
success = 0;
|
success = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
f.tag()->setArtist(TO_WSTRING(new_artist));
|
|
||||||
f.save();
|
|
||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
|
{
|
||||||
Mpd->UpdateDirectory(FindSharedDir(list));
|
Mpd->UpdateDirectory(FindSharedDir(list));
|
||||||
|
ShowMessage("Tags updated succesfully!");
|
||||||
|
}
|
||||||
FreeSongList(list);
|
FreeSongList(list);
|
||||||
ShowMessage(success ? "Tags written succesfully!" : "Error while writing tags!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (wCurrent == mLibAlbums)
|
else if (wCurrent == mLibAlbums)
|
||||||
@@ -2473,15 +2493,17 @@ int main(int argc, char *argv[])
|
|||||||
SongList list;
|
SongList list;
|
||||||
ShowMessage("Updating tags...");
|
ShowMessage("Updating tags...");
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetOption());
|
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->GetOption());
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, mLibAlbums->Current().second);
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, mLibAlbums->Current().second);
|
||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
|
ShowMessage("Updating tags in '" + (*it)->GetName() + "'...");
|
||||||
string path = Config.mpd_music_dir + (*it)->GetFile();
|
string path = Config.mpd_music_dir + (*it)->GetFile();
|
||||||
TagLib::FileRef f(path.c_str());
|
TagLib::FileRef f(path.c_str());
|
||||||
if (f.isNull())
|
if (f.isNull())
|
||||||
{
|
{
|
||||||
|
ShowMessage("Error updating tags in '" + (*it)->GetFile() + "'!");
|
||||||
success = 0;
|
success = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2489,9 +2511,11 @@ int main(int argc, char *argv[])
|
|||||||
f.save();
|
f.save();
|
||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
|
{
|
||||||
Mpd->UpdateDirectory(FindSharedDir(list));
|
Mpd->UpdateDirectory(FindSharedDir(list));
|
||||||
|
ShowMessage("Tags updated succesfully!");
|
||||||
|
}
|
||||||
FreeSongList(list);
|
FreeSongList(list);
|
||||||
ShowMessage(success ? "Tags written succesfully!" : "Error while writing tags!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
|||||||
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
|
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
|
||||||
conf.song_window_title_format = "{%a - }{%t}|{%f}";
|
conf.song_window_title_format = "{%a - }{%t}|{%f}";
|
||||||
conf.song_library_format = "{%n - }{%t}|{%f}";
|
conf.song_library_format = "{%n - }{%t}|{%f}";
|
||||||
|
conf.media_lib_album_format = "{(%y) }%b";
|
||||||
conf.tag_editor_album_format = "{(%y) }%b";
|
conf.tag_editor_album_format = "{(%y) }%b";
|
||||||
conf.browser_playlist_prefix = "[.red](playlist)[/red] ";
|
conf.browser_playlist_prefix = "[.red](playlist)[/red] ";
|
||||||
conf.pattern = "%n - %t";
|
conf.pattern = "%n - %t";
|
||||||
@@ -183,6 +184,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
|||||||
conf.active_column_color = clRed;
|
conf.active_column_color = clRed;
|
||||||
conf.window_border = brGreen;
|
conf.window_border = brGreen;
|
||||||
conf.active_window_border = brRed;
|
conf.active_window_border = brRed;
|
||||||
|
conf.media_lib_primary_tag = MPD_TAG_ITEM_ARTIST;
|
||||||
conf.colors_enabled = true;
|
conf.colors_enabled = true;
|
||||||
conf.fancy_scrolling = true;
|
conf.fancy_scrolling = true;
|
||||||
conf.columns_in_playlist = false;
|
conf.columns_in_playlist = false;
|
||||||
@@ -274,7 +276,26 @@ namespace
|
|||||||
key[0] = !one.empty() && one[0] == '\'' ? one[1] : (atoi(one.c_str()) == 0 ? null_key : atoi(one.c_str()));
|
key[0] = !one.empty() && one[0] == '\'' ? one[1] : (atoi(one.c_str()) == 0 ? null_key : atoi(one.c_str()));
|
||||||
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;
|
||||||
@@ -298,6 +319,11 @@ namespace
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Border IntoBorder(const string &color)
|
||||||
|
{
|
||||||
|
return (Border) IntoColor(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadKeys(ncmpcpp_keys &keys)
|
void ReadKeys(ncmpcpp_keys &keys)
|
||||||
@@ -511,6 +537,11 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.song_library_format = v;
|
conf.song_library_format = v;
|
||||||
}
|
}
|
||||||
|
else if (it->find("media_library_album_format") != string::npos)
|
||||||
|
{
|
||||||
|
if (!v.empty())
|
||||||
|
conf.media_lib_album_format = v;
|
||||||
|
}
|
||||||
else if (it->find("tag_editor_album_format") != string::npos)
|
else if (it->find("tag_editor_album_format") != string::npos)
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
@@ -660,12 +691,17 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
else if (it->find("window_border_color ") != string::npos)
|
else if (it->find("window_border_color ") != string::npos)
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.window_border = Border(IntoColor(v));
|
conf.window_border = IntoBorder(v);
|
||||||
}
|
}
|
||||||
else if (it->find("active_window_border") != string::npos)
|
else if (it->find("active_window_border") != string::npos)
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.active_window_border = Border(IntoColor(v));
|
conf.active_window_border = IntoBorder(v);
|
||||||
|
}
|
||||||
|
else if (it->find("media_library_left_column") != string::npos)
|
||||||
|
{
|
||||||
|
if (!v.empty())
|
||||||
|
conf.media_lib_primary_tag = IntoTagItem(v[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.close();
|
f.close();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "libmpdclient.h"
|
||||||
#include "ncmpcpp.h"
|
#include "ncmpcpp.h"
|
||||||
|
|
||||||
const string config_dir = home_folder + "/.ncmpcpp/";
|
const string config_dir = home_folder + "/.ncmpcpp/";
|
||||||
@@ -100,6 +101,7 @@ struct ncmpcpp_config
|
|||||||
string song_status_format;
|
string song_status_format;
|
||||||
string song_window_title_format;
|
string song_window_title_format;
|
||||||
string song_library_format;
|
string song_library_format;
|
||||||
|
string media_lib_album_format;
|
||||||
string tag_editor_album_format;
|
string tag_editor_album_format;
|
||||||
string browser_playlist_prefix;
|
string browser_playlist_prefix;
|
||||||
|
|
||||||
@@ -125,6 +127,8 @@ struct ncmpcpp_config
|
|||||||
Border window_border;
|
Border window_border;
|
||||||
Border active_window_border;
|
Border active_window_border;
|
||||||
|
|
||||||
|
mpd_TagItems media_lib_primary_tag;
|
||||||
|
|
||||||
bool colors_enabled;
|
bool colors_enabled;
|
||||||
bool fancy_scrolling;
|
bool fancy_scrolling;
|
||||||
bool columns_in_playlist;
|
bool columns_in_playlist;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Song
|
|||||||
void SetComment(const string &);
|
void SetComment(const string &);
|
||||||
void SetPosition(int);
|
void SetPosition(int);
|
||||||
|
|
||||||
void SetNewName(string name) { itsNewName = name == GetName() ? "" : name; }
|
void SetNewName(const string &name) { itsNewName = name == GetName() ? "" : name; }
|
||||||
string GetNewName() const { return itsNewName; }
|
string GetNewName() const { return itsNewName; }
|
||||||
|
|
||||||
void NullMe() { itsSong = 0; }
|
void NullMe() { itsSong = 0; }
|
||||||
|
|||||||
@@ -35,6 +35,68 @@ extern ncmpcpp_keys Key;
|
|||||||
extern Menu<string> *mTagEditor;
|
extern Menu<string> *mTagEditor;
|
||||||
extern Window *wFooter;
|
extern Window *wFooter;
|
||||||
|
|
||||||
|
string IntoStr(mpd_TagItems tag)
|
||||||
|
{
|
||||||
|
switch (tag)
|
||||||
|
{
|
||||||
|
case MPD_TAG_ITEM_ARTIST:
|
||||||
|
return "Artist";
|
||||||
|
case MPD_TAG_ITEM_ALBUM:
|
||||||
|
return "Album";
|
||||||
|
case MPD_TAG_ITEM_TITLE:
|
||||||
|
return "Title";
|
||||||
|
case MPD_TAG_ITEM_TRACK:
|
||||||
|
return "Track";
|
||||||
|
case MPD_TAG_ITEM_GENRE:
|
||||||
|
return "Genre";
|
||||||
|
case MPD_TAG_ITEM_DATE:
|
||||||
|
return "Year";
|
||||||
|
case MPD_TAG_ITEM_COMPOSER:
|
||||||
|
return "Composer";
|
||||||
|
case MPD_TAG_ITEM_PERFORMER:
|
||||||
|
return "Performer";
|
||||||
|
case MPD_TAG_ITEM_COMMENT:
|
||||||
|
return "Comment";
|
||||||
|
case MPD_TAG_ITEM_DISC:
|
||||||
|
return "Disc";
|
||||||
|
case MPD_TAG_ITEM_FILENAME:
|
||||||
|
return "Filename";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SongSetFunction IntoSetFunction(mpd_TagItems tag)
|
||||||
|
{
|
||||||
|
switch (tag)
|
||||||
|
{
|
||||||
|
case MPD_TAG_ITEM_ARTIST:
|
||||||
|
return &Song::SetArtist;
|
||||||
|
case MPD_TAG_ITEM_ALBUM:
|
||||||
|
return &Song::SetAlbum;
|
||||||
|
case MPD_TAG_ITEM_TITLE:
|
||||||
|
return &Song::SetTitle;
|
||||||
|
case MPD_TAG_ITEM_TRACK:
|
||||||
|
return &Song::SetTrack;
|
||||||
|
case MPD_TAG_ITEM_GENRE:
|
||||||
|
return &Song::SetGenre;
|
||||||
|
case MPD_TAG_ITEM_DATE:
|
||||||
|
return &Song::SetYear;
|
||||||
|
case MPD_TAG_ITEM_COMPOSER:
|
||||||
|
return &Song::SetComposer;
|
||||||
|
case MPD_TAG_ITEM_PERFORMER:
|
||||||
|
return &Song::SetPerformer;
|
||||||
|
case MPD_TAG_ITEM_COMMENT:
|
||||||
|
return &Song::SetComment;
|
||||||
|
case MPD_TAG_ITEM_DISC:
|
||||||
|
return &Song::SetDisc;
|
||||||
|
case MPD_TAG_ITEM_FILENAME:
|
||||||
|
return &Song::SetNewName;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string FindSharedDir(Menu<Song> *menu)
|
string FindSharedDir(Menu<Song> *menu)
|
||||||
{
|
{
|
||||||
SongList list;
|
SongList list;
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ string FindSharedDir(Menu<Song> *);
|
|||||||
string FindSharedDir(const SongList &);
|
string FindSharedDir(const SongList &);
|
||||||
string DisplayTag(const Song &, void *, const Menu<Song> *);
|
string DisplayTag(const Song &, void *, const Menu<Song> *);
|
||||||
|
|
||||||
|
string IntoStr(mpd_TagItems);
|
||||||
|
SongSetFunction IntoSetFunction(mpd_TagItems);
|
||||||
|
|
||||||
bool GetSongTags(Song &);
|
bool GetSongTags(Song &);
|
||||||
bool WriteTags(Song &);
|
bool WriteTags(Song &);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user