brand new song info screen

This commit is contained in:
unK
2008-09-10 17:25:35 +02:00
parent c80b7e6568
commit cb79ecdb2a
7 changed files with 109 additions and 3 deletions

View File

@@ -20,6 +20,7 @@
#include <algorithm>
#include "helpers.h"
#include "tag_editor.h"
extern MPDConnection *Mpd;
@@ -698,6 +699,40 @@ string DisplaySong(const Song &s, void *s_template)
return result;
}
string GetInfo(Song &s)
{
string result;
# ifdef HAVE_TAGLIB_H
string path_to_file = Config.mpd_music_dir + "/" + s.GetFile();
TagLib::FileRef f(path_to_file.c_str());
if (!f.isNull())
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";
# 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";
}
# endif // HAVE_TAGLIB_H
result += "\n[.b]Title:[/b] " + s.GetTitle();
result += "\n[.b]Artist:[/b] " + s.GetArtist();
result += "\n[.b]Album:[/b] " + s.GetAlbum();
result += "\n[.b]Year:[/b] " + s.GetYear();
result += "\n[.b]Track:[/b] " + s.GetTrack();
result += "\n[.b]Genre:[/b] " + s.GetGenre();
result += "\n[.b]Composer:[/b] " + s.GetComposer();
result += "\n[.b]Performer:[/b] " + s.GetPerformer();
result += "\n[.b]Disc:[/b] " + s.GetDisc();
result += "\n[.b]Comment:[/b] " + s.GetComment();
return result;
}
void ShowMessage(const string &message, int delay)
{
if (messages_allowed)

View File

@@ -51,6 +51,7 @@ string DisplayItem(const Item &, void * = NULL);
string DisplayColumns(string);
string DisplaySongInColumns(const Song &, void *);
string DisplaySong(const Song &, void * = &Config.song_list_format);
string GetInfo(Song &);
void ShowMessage(const string &, int = Config.message_delay_time);
void GetDirectory(string, string = "/");

View File

@@ -94,6 +94,7 @@ Menu<Song> *mPlaylistEditor;
Scrollpad *sHelp;
Scrollpad *sLyrics;
Scrollpad *sInfo;
Window *wHeader;
Window *wFooter;
@@ -232,6 +233,7 @@ int main(int argc, char *argv[])
sHelp = new Scrollpad(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
sLyrics = static_cast<Scrollpad *>(sHelp->EmptyClone());
sInfo = static_cast<Scrollpad *>(sHelp->EmptyClone());
sHelp->Add(" [.b]Keys - Movement\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Up) + "Move Cursor up\n");
@@ -283,6 +285,7 @@ int main(int argc, char *argv[])
sHelp->Add(DisplayKeys(Key.EditTags) + "Edit song's tags/playlist's name\n");
# endif // HAVE_TAGLIB_H
sHelp->Add(DisplayKeys(Key.GoToPosition) + "Go to chosen position in current song\n");
sHelp->Add(DisplayKeys(Key.ShowInfo) + "Show song's info\n");
sHelp->Add(DisplayKeys(Key.Lyrics) + "Show/hide song's lyrics\n\n");
sHelp->Add(DisplayKeys(Key.Quit) + "Quit\n\n\n");
@@ -365,6 +368,7 @@ int main(int argc, char *argv[])
mEditorTags->SetTimeout(ncmpcpp_window_timeout);
# endif // HAVE_TAGLIB_H
sLyrics->SetTimeout(ncmpcpp_window_timeout);
sInfo->SetTimeout(ncmpcpp_window_timeout);
wFooter->SetTimeout(ncmpcpp_window_timeout);
mPlaylistList->SetTimeout(ncmpcpp_window_timeout);
mPlaylistEditor->SetTimeout(ncmpcpp_window_timeout);
@@ -435,6 +439,9 @@ int main(int argc, char *argv[])
case csTagEditor:
title = "Tag editor";
break;
case csInfo:
title = "Song info";
break;
case csSearcher:
title = "Search engine";
break;
@@ -811,6 +818,7 @@ int main(int argc, char *argv[])
mPlaylist->SetTitle(Config.columns_in_playlist ? DisplayColumns(Config.song_columns_list_format) : "");
mBrowser->Resize(COLS, main_height);
mSearcher->Resize(COLS, main_height);
sInfo->Resize(COLS, main_height);
sLyrics->Resize(COLS, main_height);
lib_artist_width = COLS/3-1;
@@ -846,8 +854,7 @@ int main(int argc, char *argv[])
wFooter->MoveTo(0, footer_start_y);
wFooter->Resize(COLS, wFooter->GetHeight());
if (wCurrent != sHelp && wCurrent != sLyrics)
wCurrent->Window::Clear();
wCurrent->Hide();
# ifdef HAVE_TAGLIB_H
if (current_screen == csLibrary)
@@ -2624,11 +2631,66 @@ int main(int argc, char *argv[])
Config.space_selects = !Config.space_selects;
ShowMessage("Space mode: " + string(Config.space_selects ? "Select/deselect" : "Add") + " item");
}
else if (Keypressed(input, Key.ShowInfo))
{
if (wCurrent == sInfo)
{
wCurrent->Hide();
current_screen = prev_screen;
wCurrent = wPrev;
redraw_screen = 1;
if (current_screen == csLibrary)
{
REFRESH_MEDIA_LIBRARY_SCREEN;
}
else if (current_screen == csPlaylistEditor)
{
REFRESH_PLAYLIST_EDITOR_SCREEN;
}
}
else if (
(wCurrent == mPlaylist && !mPlaylist->Empty())
|| (wCurrent == mBrowser && mBrowser->at(mBrowser->GetChoice()).type == itSong)
|| (wCurrent == mSearcher && mSearcher->Current().first == ".")
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
{
Song *s;
int id = wCurrent->GetChoice();
switch (current_screen)
{
case csPlaylist:
s = &mPlaylist->at(id);
break;
case csBrowser:
s = mBrowser->at(id).song;
break;
case csSearcher:
s = &mSearcher->at(id).second;
break;
case csLibrary:
s = &mLibSongs->at(id);
break;
case csPlaylistEditor:
s = &mPlaylistEditor->at(id);
break;
default:
break;
}
wPrev = wCurrent;
wCurrent = sInfo;
prev_screen = current_screen;
current_screen = csInfo;
sInfo->Clear();
sInfo->Add(GetInfo(*s));
sInfo->Hide();
}
}
else if (Keypressed(input, Key.Lyrics))
{
if (wCurrent == sLyrics)
{
wCurrent->Window::Clear();
wCurrent->Hide();
current_screen = prev_screen;
wCurrent = wPrev;
redraw_screen = 1;

View File

@@ -49,6 +49,7 @@ enum NcmpcppScreen
csPlaylist,
csBrowser,
csTagEditor,
csInfo,
csSearcher,
csLibrary,
csLyrics,

View File

@@ -66,6 +66,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
keys.PrevFoundPosition[0] = ',';
keys.ToggleFindMode[0] = 'w';
keys.EditTags[0] = 'e';
keys.ShowInfo[0] = 'i';
keys.GoToPosition[0] = 'g';
keys.Lyrics[0] = 'l';
keys.ReverseSelection[0] = 'v';
@@ -124,6 +125,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
keys.PrevFoundPosition[1] = null_key;
keys.ToggleFindMode[1] = null_key;
keys.EditTags[1] = null_key;
keys.ShowInfo[1] = null_key;
keys.GoToPosition[1] = null_key;
keys.Lyrics[1] = null_key;
keys.ReverseSelection[1] = null_key;
@@ -369,6 +371,8 @@ void ReadKeys(ncmpcpp_keys &keys)
GetKeys(*it, keys.EditTags);
else if (it->find("key_go_to_position ") != string::npos)
GetKeys(*it, keys.GoToPosition);
else if (it->find("key_song_info ") != string::npos)
GetKeys(*it, keys.ShowInfo);
else if (it->find("key_lyrics ") != string::npos)
GetKeys(*it, keys.Lyrics);
else if (it->find("key_reverse_selection ") != string::npos)

View File

@@ -68,6 +68,7 @@ struct ncmpcpp_keys
int PrevFoundPosition[2];
int ToggleFindMode[2];
int EditTags[2];
int ShowInfo[2];
int GoToPosition[2];
int Lyrics[2];
int ReverseSelection[2];