extend configuration
This commit is contained in:
@@ -106,6 +106,8 @@
|
||||
#
|
||||
#default_tag_editor_left_col = "albums" (albums/dirs)
|
||||
#
|
||||
#default_tag_editor_pattern = "%n - %t"
|
||||
#
|
||||
#header_visibility = "yes"
|
||||
#
|
||||
#statusbar_visibility = "yes"
|
||||
@@ -130,6 +132,10 @@
|
||||
#
|
||||
#main_window_color = "yellow"
|
||||
#
|
||||
#color1 = "white"
|
||||
#
|
||||
#color2 = "green"
|
||||
#
|
||||
#main_window_highlight_color = "yellow"
|
||||
#
|
||||
#progressbar_color = "default"
|
||||
@@ -138,3 +144,7 @@
|
||||
#
|
||||
#active_column_color = "red"
|
||||
#
|
||||
#window_border_color = "green"
|
||||
#
|
||||
#active_window_border = "red"
|
||||
#
|
||||
|
||||
@@ -54,6 +54,12 @@ ColorPair Window::IntoColor(const string &str)
|
||||
Bold(1);
|
||||
else if (str == "[.r]")
|
||||
Reverse(1);
|
||||
else if (str == "[.default]")
|
||||
{
|
||||
colors.first = itsBaseColor;
|
||||
colors.second = itsBaseBgColor;
|
||||
itsColors.push(colors);
|
||||
}
|
||||
else if (str == "[.red]")
|
||||
{
|
||||
colors.first = clRed;
|
||||
@@ -410,6 +416,8 @@ bool Window::IsValidColor(const string &str)
|
||||
str == "[.a]" ||
|
||||
str == "[/a]" ||
|
||||
|
||||
str == "[.default]" ||
|
||||
str == "[/default]" ||
|
||||
str == "[.black]" ||
|
||||
str == "[/black]" ||
|
||||
str == "[.red]" ||
|
||||
|
||||
@@ -665,7 +665,7 @@ string DisplaySong(const Song &s, void *s_template, const Menu<Song> *menu)
|
||||
{
|
||||
right = 1;
|
||||
lresult = result;
|
||||
result = "";
|
||||
result.clear();
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
@@ -690,15 +690,15 @@ string GetInfo(Song &s)
|
||||
s.SetComment(f.tag()->comment().to8Bit(UNICODE));
|
||||
# endif // HAVE_TAGLIB_H
|
||||
|
||||
result = "[.b][.white]Filename: [/white][.green][/b]" + s.GetShortFilename() + "[/green]\n";
|
||||
result += "[.b][.white]Directory: [/white][.green][/b]" + s.GetDirectory() + "[/green]\n\n";
|
||||
result += "[.b][.white]Length: [/white][.green][/b]" + s.GetLength() + "[/green]\n";
|
||||
result = "[.b][." + Config.color1 + "]Filename: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetShortFilename() + "[/" + Config.color2 + "]\n";
|
||||
result += "[.b][." + Config.color1 + "]Directory: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetDirectory() + "[/" + Config.color2 + "]\n\n";
|
||||
result += "[.b][." + Config.color1 + "]Length: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetLength() + "[/" + Config.color2 + "]\n";
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (!f.isNull())
|
||||
{
|
||||
result += "[.b][.white]Bitrate: [/white][.green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/green]\n";
|
||||
result += "[.b][.white]Sample rate: [/white][.green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/green]\n";
|
||||
result += "[.b][.white]Channels: [/white][.green][/b]" + string(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]\n";
|
||||
result += "[.b][." + Config.color1 + "]Bitrate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/" + Config.color2 + "]\n";
|
||||
result += "[.b][." + Config.color1 + "]Sample rate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/" + Config.color2 + "]\n";
|
||||
result += "[.b][." + Config.color1 + "]Channels: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + string(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/" + Config.color2 + "]\n";
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
result += "\n[.b]Title:[/b] " + s.GetTitle();
|
||||
|
||||
@@ -1151,7 +1151,7 @@ int main(int argc, char *argv[])
|
||||
bool bold = 0;
|
||||
int found = mSearcher->Size()-search_engine_static_options;
|
||||
mSearcher->InsertSeparator(14);
|
||||
mSearcher->Insert(15, std::pair<string, Song>("[.white]Search results:[/white] [.green]Found " + IntoStr(found) + (found > 1 ? " songs" : " song") + "[/green]", Song()), 1, 1);
|
||||
mSearcher->Insert(15, std::pair<string, Song>("[." + Config.color1 + "]Search results:[/" + Config.color1 + "] [." + Config.color2 + "]Found " + IntoStr(found) + (found > 1 ? " songs" : " song") + "[/" + Config.color2 + "]", Song()), 1, 1);
|
||||
mSearcher->InsertSeparator(16);
|
||||
UpdateFoundList();
|
||||
ShowMessage("Searching finished!");
|
||||
@@ -2485,7 +2485,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
const int dialog_width = COLS*0.8;
|
||||
const int dialog_height = LINES*0.6;
|
||||
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", clYellow, brGreen);
|
||||
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border);
|
||||
mDialog->SetTimeout(ncmpcpp_window_timeout);
|
||||
|
||||
mDialog->AddOption("Current MPD playlist");
|
||||
|
||||
@@ -156,8 +156,11 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.song_library_format = "{%n - }{%t}|{%f}";
|
||||
conf.tag_editor_album_format = "{(%y) }%b";
|
||||
conf.browser_playlist_prefix = "[.red](playlist)[/red] ";
|
||||
conf.pattern = "%n - %t";
|
||||
conf.selected_item_prefix = "[.magenta]";
|
||||
conf.selected_item_suffix = "[/magenta]";
|
||||
conf.color1 = "white";
|
||||
conf.color2 = "green";
|
||||
conf.empty_tags_color = clCyan;
|
||||
conf.header_color = clDefault;
|
||||
conf.volume_color = clDefault;
|
||||
@@ -168,6 +171,8 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.progressbar_color = clDefault;
|
||||
conf.statusbar_color = clDefault;
|
||||
conf.active_column_color = clRed;
|
||||
conf.window_border = brGreen;
|
||||
conf.active_window_border = brRed;
|
||||
conf.colors_enabled = true;
|
||||
conf.fancy_scrolling = true;
|
||||
conf.columns_in_playlist = false;
|
||||
@@ -230,9 +235,11 @@ string GetLineValue(const string &line, char a, char b)
|
||||
|
||||
string IntoStr(Color color)
|
||||
{
|
||||
string result = "";
|
||||
string result;
|
||||
|
||||
if (color == clBlack)
|
||||
if (color == clDefault)
|
||||
result = "default";
|
||||
else if (color == clBlack)
|
||||
result = "black";
|
||||
else if (color == clRed)
|
||||
result = "red";
|
||||
@@ -488,6 +495,11 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
if (!v.empty())
|
||||
conf.browser_playlist_prefix = v;
|
||||
}
|
||||
else if (it->find("default_tag_editor_pattern") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.pattern = v;
|
||||
}
|
||||
else if (it->find("selected_item_prefix") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
@@ -498,6 +510,16 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
if (!v.empty())
|
||||
conf.selected_item_suffix = v;
|
||||
}
|
||||
else if (it->find("color1") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.color1 = v;
|
||||
}
|
||||
else if (it->find("color2") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.color2 = v;
|
||||
}
|
||||
else if (it->find("colors_enabled") != string::npos)
|
||||
{
|
||||
conf.colors_enabled = v == "yes";
|
||||
@@ -597,6 +619,16 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
if (!v.empty())
|
||||
conf.active_column_color = IntoColor(v);
|
||||
}
|
||||
else if (it->find("window_border_color ") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.window_border = Border(IntoColor(v));
|
||||
}
|
||||
else if (it->find("active_window_border") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.active_window_border = Border(IntoColor(v));
|
||||
}
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
|
||||
@@ -100,9 +100,14 @@ struct ncmpcpp_config
|
||||
string tag_editor_album_format;
|
||||
string browser_playlist_prefix;
|
||||
|
||||
string pattern;
|
||||
|
||||
string selected_item_prefix;
|
||||
string selected_item_suffix;
|
||||
|
||||
string color1;
|
||||
string color2;
|
||||
|
||||
Color empty_tags_color;
|
||||
Color header_color;
|
||||
Color volume_color;
|
||||
@@ -114,6 +119,9 @@ struct ncmpcpp_config
|
||||
Color statusbar_color;
|
||||
Color active_column_color;
|
||||
|
||||
Border window_border;
|
||||
Border active_window_border;
|
||||
|
||||
bool colors_enabled;
|
||||
bool fancy_scrolling;
|
||||
bool columns_in_playlist;
|
||||
|
||||
@@ -31,8 +31,6 @@ extern ncmpcpp_keys Key;
|
||||
extern Menu<string> *mTagEditor;
|
||||
extern Window *wFooter;
|
||||
|
||||
string pattern = "%n - %t";
|
||||
|
||||
string FindSharedDir(Menu<Song> *menu)
|
||||
{
|
||||
SongList list;
|
||||
@@ -79,7 +77,7 @@ string DisplayTag(const Song &s, void *data, const Menu<Song> *null)
|
||||
case 6:
|
||||
return s.GetComment();
|
||||
case 8:
|
||||
return s.GetNewName().empty() ? s.GetShortFilename() : s.GetShortFilename() + " [.green]->[/green] " + s.GetNewName();
|
||||
return s.GetNewName().empty() ? s.GetShortFilename() : s.GetShortFilename() + " [." + Config.color2 + "]->[/" + Config.color2 + "] " + s.GetNewName();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -97,13 +95,13 @@ bool GetSongTags(Song &s)
|
||||
mTagEditor->Clear();
|
||||
mTagEditor->Reset();
|
||||
|
||||
mTagEditor->AddOption("[.b][.white]Song name: [/white][.green][/b]" + s.GetShortFilename() + "[/green]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][.white]Location in DB: [/white][.green][/b]" + s.GetDirectory() + "[/green]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][." + Config.color1 + "]Song name: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetShortFilename() + "[/" + Config.color2 + "]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][." + Config.color1 + "]Location in DB: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetDirectory() + "[/" + Config.color2 + "]", 0, 1);
|
||||
mTagEditor->AddOption("", 0, 1);
|
||||
mTagEditor->AddOption("[.b][.white]Length: [/white][.green][/b]" + s.GetLength() + "[/green]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][.white]Bitrate: [/white][.green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/green]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][.white]Sample rate: [/white][.green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/green]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][.white]Channels: [/white][.green][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][." + Config.color1 + "]Length: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + s.GetLength() + "[/" + Config.color2 + "]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][." + Config.color1 + "]Bitrate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/" + Config.color2 + "]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][." + Config.color1 + "]Sample rate: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/" + Config.color2 + "]", 0, 1);
|
||||
mTagEditor->AddOption("[.b][." + Config.color1 + "]Channels: [/" + Config.color1 + "][." + Config.color2 + "][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/" + Config.color2 + "]", 0, 1);
|
||||
|
||||
mTagEditor->AddSeparator();
|
||||
|
||||
@@ -247,7 +245,7 @@ void __deal_with_filenames(SongList &v)
|
||||
int width = 30;
|
||||
int height = 6;
|
||||
|
||||
Menu<string> *Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, width, height, "", Config.main_color, brGreen);
|
||||
Menu<string> *Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, width, height, "", Config.main_color, Config.window_border);
|
||||
Main->SetTimeout(ncmpcpp_window_timeout);
|
||||
Main->AddOption("Get tags from filename");
|
||||
Main->AddOption("Rename files");
|
||||
@@ -285,7 +283,7 @@ void __deal_with_filenames(SongList &v)
|
||||
|
||||
if (choice != 3)
|
||||
{
|
||||
Legend = new Scrollpad((COLS-width)/2+one_width, (LINES-height)/2, two_width, height, "Legend", Config.main_color, brGreen);
|
||||
Legend = new Scrollpad((COLS-width)/2+one_width, (LINES-height)/2, two_width, height, "Legend", Config.main_color, Config.window_border);
|
||||
Legend->SetTimeout(ncmpcpp_window_timeout);
|
||||
Legend->Add("%a - artist\n");
|
||||
Legend->Add("%t - title\n");
|
||||
@@ -302,16 +300,16 @@ void __deal_with_filenames(SongList &v)
|
||||
Legend->Add("%C - comment\n\n");
|
||||
Legend->Add("[.b]Files:[/b]\n");
|
||||
for (SongList::const_iterator it = v.begin(); it != v.end(); it++)
|
||||
Legend->Add("[.green]*[/green] " + (*it)->GetShortFilename() + "\n");
|
||||
Legend->Add("[." + Config.color2 + "]*[/" + Config.color2 + "] " + (*it)->GetShortFilename() + "\n");
|
||||
|
||||
Preview = static_cast<Scrollpad *>(Legend->EmptyClone());
|
||||
Preview->SetTitle("Preview");
|
||||
Preview->SetTimeout(ncmpcpp_window_timeout);
|
||||
|
||||
Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, one_width, height, "", Config.main_color, brRed);
|
||||
Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, one_width, height, "", Config.main_color, Config.active_window_border);
|
||||
Main->SetTimeout(ncmpcpp_window_timeout);
|
||||
|
||||
Main->AddOption("[.b]Pattern:[/b] " + pattern);
|
||||
Main->AddOption("[.b]Pattern:[/b] " + Config.pattern);
|
||||
Main->AddOption("Preview");
|
||||
Main->AddOption("Legend");
|
||||
Main->AddSeparator();
|
||||
@@ -356,12 +354,12 @@ void __deal_with_filenames(SongList &v)
|
||||
{
|
||||
LockStatusbar();
|
||||
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Pattern:[/b] ", 1);
|
||||
string new_pattern = wFooter->GetString(pattern);
|
||||
string new_pattern = wFooter->GetString(Config.pattern);
|
||||
UnlockStatusbar();
|
||||
if (!new_pattern.empty())
|
||||
{
|
||||
pattern = new_pattern;
|
||||
Main->UpdateOption(0, "[.b]Pattern:[/b] " + pattern);
|
||||
Config.pattern = new_pattern;
|
||||
Main->UpdateOption(0, "[.b]Pattern:[/b] " + Config.pattern);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -380,10 +378,10 @@ void __deal_with_filenames(SongList &v)
|
||||
if (preview)
|
||||
{
|
||||
Preview->Add("[.b]" + s.GetShortFilename() + ":[/b]\n");
|
||||
Preview->Add(ParseFilename(s, pattern, preview) + "\n");
|
||||
Preview->Add(ParseFilename(s, Config.pattern, preview) + "\n");
|
||||
}
|
||||
else
|
||||
ParseFilename(s, pattern, preview);
|
||||
ParseFilename(s, Config.pattern, preview);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -391,7 +389,7 @@ void __deal_with_filenames(SongList &v)
|
||||
int last_dot = file.find_last_of(".");
|
||||
string extension = file.substr(last_dot);
|
||||
s.GetEmptyFields(1);
|
||||
string new_file = GenerateFilename(s, pattern);
|
||||
string new_file = GenerateFilename(s, Config.pattern);
|
||||
if (new_file.empty())
|
||||
{
|
||||
if (preview)
|
||||
@@ -405,7 +403,7 @@ void __deal_with_filenames(SongList &v)
|
||||
}
|
||||
if (!preview)
|
||||
s.SetNewName(new_file + extension);
|
||||
Preview->Add(file + " [.green]->[/green] " + new_file + extension + "\n");
|
||||
Preview->Add(file + " [." + Config.color2 + "]->[/" + Config.color2 + "] " + new_file + extension + "\n");
|
||||
s.GetEmptyFields(0);
|
||||
}
|
||||
}
|
||||
@@ -437,18 +435,18 @@ void __deal_with_filenames(SongList &v)
|
||||
}
|
||||
else if (Keypressed(input, Key.VolumeUp) && Active == Main)
|
||||
{
|
||||
Active->SetBorder(brGreen);
|
||||
Active->SetBorder(Config.window_border);
|
||||
Active->Display(1);
|
||||
Active = Helper;
|
||||
Active->SetBorder(brRed);
|
||||
Active->SetBorder(Config.active_window_border);
|
||||
Active->Display();
|
||||
}
|
||||
else if (Keypressed(input, Key.VolumeDown) && Active == Helper)
|
||||
{
|
||||
Active->SetBorder(brGreen);
|
||||
Active->SetBorder(Config.window_border);
|
||||
Active->Display();
|
||||
Active = Main;
|
||||
Active->SetBorder(brRed);
|
||||
Active->SetBorder(Config.active_window_border);
|
||||
Active->Display(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user