new feature: go to currently playing song in browser
This commit is contained in:
@@ -333,6 +333,28 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void Browser::LocateSong(const MPD::Song &s)
|
||||
{
|
||||
if (s.GetDirectory().empty())
|
||||
return;
|
||||
|
||||
Config.local_browser = !s.IsFromDB();
|
||||
|
||||
string option = s.toString(Config.song_status_format);
|
||||
locale_to_utf(option);
|
||||
if (itsBrowsedDir != s.GetDirectory())
|
||||
GetDirectory(s.GetDirectory());
|
||||
for (size_t i = 0; i < w->Size(); i++)
|
||||
{
|
||||
if (w->at(i).type == itSong && option == w->at(i).song->toString(Config.song_status_format))
|
||||
{
|
||||
w->Highlight(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
SwitchTo();
|
||||
}
|
||||
|
||||
void Browser::GetDirectory(string dir, string subdir)
|
||||
{
|
||||
if (dir.empty())
|
||||
|
||||
@@ -50,6 +50,7 @@ class Browser : public Screen< Menu<MPD::Item> >
|
||||
|
||||
const std::string &CurrentDir() { return itsBrowsedDir; }
|
||||
|
||||
void LocateSong(const MPD::Song &);
|
||||
void GetDirectory(std::string, std::string = "/");
|
||||
void ChangeBrowseMode();
|
||||
void UpdateItemList();
|
||||
|
||||
@@ -174,7 +174,7 @@ void Help::GetKeybindings()
|
||||
*w << DisplayKeys(Key.PrevFoundPosition) << "Go to previous found position\n";
|
||||
*w << DisplayKeys(Key.NextFoundPosition) << "Go to next found position\n";
|
||||
*w << DisplayKeys(Key.ToggleFindMode) << "Toggle find mode (normal/wrapped)\n";
|
||||
*w << DisplayKeys(Key.GoToContainingDir) << "Go to directory containing current item\n";
|
||||
*w << DisplayKeys(Key.GoToContainingDir) << "Locate song in browser\n";
|
||||
*w << DisplayKeys(Key.ToggleDisplayMode) << "Toggle display mode\n";
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
*w << DisplayKeys(Key.EditTags) << "Edit song's tags/playlist's name\n";
|
||||
@@ -208,6 +208,7 @@ void Help::GetKeybindings()
|
||||
*w << DisplayKeys(Key.Space) << "Add item to playlist\n";
|
||||
if (Mpd->GetHostname()[0] == '/') // are we connected to unix socket?
|
||||
*w << DisplayKeys(Key.SwitchTagTypeList) << "Browse MPD database/local filesystem\n";
|
||||
*w << DisplayKeys(Key.GoToNowPlaying) << "Locate currently playing song\n";
|
||||
*w << DisplayKeys(Key.GoToParentDir) << "Go to parent directory\n";
|
||||
*w << DisplayKeys(Key.Delete) << "Delete playlist\n\n\n";
|
||||
|
||||
|
||||
@@ -987,8 +987,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.GoToNowPlaying))
|
||||
{
|
||||
if (myScreen != myPlaylist || !myPlaylist->isPlaying())
|
||||
continue;
|
||||
if (myScreen == myPlaylist && myPlaylist->isPlaying())
|
||||
{
|
||||
if (myPlaylist->Main()->isFiltered())
|
||||
{
|
||||
ShowMessage("%s", MPD::Message::FunctionDisabledFilteringEnabled);
|
||||
@@ -996,6 +996,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
myPlaylist->Main()->Highlight(myPlaylist->NowPlaying);
|
||||
}
|
||||
else if (myScreen == myBrowser)
|
||||
{
|
||||
const Song *s = myPlaylist->NowPlayingSong();
|
||||
if (s)
|
||||
myBrowser->LocateSong(*s);
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.ToggleRepeat))
|
||||
{
|
||||
Mpd->SetRepeat(!Mpd->GetRepeat());
|
||||
@@ -1189,24 +1196,8 @@ int main(int argc, char *argv[])
|
||||
else if (Keypressed(input, Key.GoToContainingDir))
|
||||
{
|
||||
Song *s = myScreen->CurrentSong();
|
||||
|
||||
if (!s || s->GetDirectory().empty())
|
||||
continue;
|
||||
|
||||
Config.local_browser = !s->IsFromDB();
|
||||
|
||||
string option = s->toString(Config.song_status_format);
|
||||
locale_to_utf(option);
|
||||
myBrowser->GetDirectory(s->GetDirectory());
|
||||
for (size_t i = 0; i < myBrowser->Main()->Size(); i++)
|
||||
{
|
||||
if (myBrowser->Main()->at(i).type == itSong && option == myBrowser->Main()->at(i).song->toString(Config.song_status_format))
|
||||
{
|
||||
myBrowser->Main()->Highlight(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
myBrowser->SwitchTo();
|
||||
if (s)
|
||||
myBrowser->LocateSong(*s);
|
||||
}
|
||||
else if (Keypressed(input, Key.StartSearching))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user