new feature: display bitrate in statusbar (optional, disabled by default)

This commit is contained in:
Andrzej Rybczak
2009-08-24 01:37:44 +02:00
parent deaa456383
commit 216b0b6af6
6 changed files with 26 additions and 2 deletions

View File

@@ -201,6 +201,8 @@
#
#clock_display_seconds = "no"
#
#display_bitrate = "no"
#
#regular_expressions = "basic" (basic/extended)
#
##

View File

@@ -192,6 +192,9 @@ If enabled, user will be asked if he really wants to clear the main playlist aft
.B clock_display_seconds = yes/no
If enabled, clock will display time in format hh:mm:ss, otherwise hh:mm.
.TP
.B display_bitrate = yes/no
If enabled, bitrate of currently playing song will be displayed in statusbar.
.TP
.B ignore_leading_the = yes/no
If enabled, word "the" at the beginning of tags/filenames will be ignored while sorting items.
.TP

View File

@@ -129,6 +129,7 @@ namespace MPD
long long GetPlaylistID() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlist : -1; }
long long GetOldPlaylistID() const { return isConnected && itsOldStatus ? itsOldStatus->playlist : -1; }
int GetElapsedTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->elapsedTime : -1; }
unsigned GetBitrate() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->bitRate : 0; }
size_t GetMaxPlaylistLength() const { return itsMaxPlaylistLength; }
size_t GetPlaylistLength() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlistLength : 0; }

View File

@@ -289,6 +289,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.search_in_db = true;
conf.display_screens_numbers_on_start = true;
conf.clock_display_seconds = false;
conf.display_bitrate = false;
conf.ignore_leading_the = false;
conf.block_search_constraints_change = true;
conf.use_console_editor = false;
@@ -723,6 +724,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
{
conf.clock_display_seconds = v == "yes";
}
else if (cl.find("display_bitrate") != std::string::npos)
{
conf.display_bitrate = v == "yes";
}
else if (cl.find("ignore_leading_the") != std::string::npos)
{
conf.ignore_leading_the = v == "yes";

View File

@@ -184,6 +184,7 @@ struct ncmpcpp_config
bool search_in_db;
bool display_screens_numbers_on_start;
bool clock_display_seconds;
bool display_bitrate;
bool ignore_leading_the;
bool block_search_constraints_change;
bool use_console_editor;

View File

@@ -421,6 +421,13 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
tracklength += "/";
tracklength += np.GetLength();
}
// bitrate here doesn't look good, but it can be moved somewhere else later
if (Config.display_bitrate && Mpd.GetBitrate())
{
tracklength += " ";
tracklength += IntoStr(Mpd.GetBitrate());
tracklength += " kbps";
}
basic_buffer<my_char_t> first, second;
String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.new_header_first_line))), first);
@@ -449,9 +456,15 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
}
else if (!block_statusbar_update && Config.statusbar_visibility)
{
if (Config.display_bitrate && Mpd.GetBitrate())
{
tracklength += " [";
tracklength += IntoStr(Mpd.GetBitrate());
tracklength += " kbps]";
}
tracklength += " [";
if (np.GetTotalLength())
{
tracklength = " [";
tracklength += Song::ShowTime(elapsed);
tracklength += "/";
tracklength += np.GetLength();
@@ -459,7 +472,6 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
}
else
{
tracklength = " [";
tracklength += Song::ShowTime(elapsed);
tracklength += "]";
}