playlists management support and playlist editor screen added
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
#
|
||||
#key_volume_down = 260 '-'
|
||||
#
|
||||
#key_toggle_space_mode = 't'
|
||||
#
|
||||
#key_screen_switcher = 9
|
||||
#
|
||||
#key_help = '1' 265
|
||||
@@ -47,6 +49,8 @@
|
||||
#
|
||||
#key_media_library = '5' 269
|
||||
#
|
||||
#key_playlist_editor = '6' 270
|
||||
#
|
||||
#key_stop = 's'
|
||||
#
|
||||
#key_pause = 'P'
|
||||
@@ -93,6 +97,8 @@
|
||||
#
|
||||
#key_deselect_all = 'V'
|
||||
#
|
||||
#key_add_selected_items = 'A'
|
||||
#
|
||||
#key_clear = 'c'
|
||||
#
|
||||
#key_crop = 'C'
|
||||
|
||||
@@ -80,7 +80,9 @@
|
||||
#
|
||||
#repeat_one_mode = "no"
|
||||
#
|
||||
#find_mode = "wrapped"
|
||||
#default_find_mode = "wrapped"
|
||||
#
|
||||
#default_space_mode = "add"
|
||||
#
|
||||
#header_visibility = "yes"
|
||||
#
|
||||
@@ -110,5 +112,5 @@
|
||||
#
|
||||
#statusbar_color = "default"
|
||||
#
|
||||
#library_active_column_color = "red"
|
||||
#active_column_color = "red"
|
||||
#
|
||||
|
||||
@@ -29,10 +29,12 @@ extern Menu *mPlaylist;
|
||||
extern Menu *mBrowser;
|
||||
extern Menu *mTagEditor;
|
||||
extern Menu *mSearcher;
|
||||
extern Menu *mPlaylistEditor;
|
||||
|
||||
extern Window *wFooter;
|
||||
|
||||
extern SongList vPlaylist;
|
||||
extern SongList vPlaylistContent;
|
||||
extern ItemList vBrowser;
|
||||
|
||||
extern NcmpcppScreen current_screen;
|
||||
@@ -70,6 +72,14 @@ void DeleteSong(int id)
|
||||
mPlaylist->DeleteOption(id+1);
|
||||
}
|
||||
|
||||
void PlaylistDeleteSong(const string &path, int id)
|
||||
{
|
||||
Mpd->QueueDeleteFromPlaylist(path, id);
|
||||
delete vPlaylistContent[id];
|
||||
vPlaylistContent.erase(vPlaylistContent.begin()+id);
|
||||
mPlaylistEditor->DeleteOption(id+1);
|
||||
}
|
||||
|
||||
bool MoveSongUp(int pos)
|
||||
{
|
||||
if (pos > 0 && !mPlaylist->Empty() && current_screen == csPlaylist)
|
||||
@@ -96,6 +106,30 @@ bool MoveSongDown(int pos)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlaylistMoveSongUp(const string &path, int pos)
|
||||
{
|
||||
if (pos > 0 && !mPlaylistEditor->Empty() && current_screen == csPlaylistEditor)
|
||||
{
|
||||
mPlaylistEditor->Swap(pos, pos-1);
|
||||
Mpd->Move(path, pos, pos-1);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlaylistMoveSongDown(const string &path, int pos)
|
||||
{
|
||||
if (pos+1 < mPlaylistEditor->MaxChoice() && !mPlaylistEditor->Empty() && current_screen == csPlaylistEditor)
|
||||
{
|
||||
mPlaylistEditor->Swap(pos+1, pos);
|
||||
Mpd->Move(path, pos, pos+1);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
string DisplayKeys(int *key, int size)
|
||||
{
|
||||
bool backspace = 1;
|
||||
|
||||
@@ -31,8 +31,11 @@
|
||||
extern ncmpcpp_config Config;
|
||||
|
||||
void DeleteSong(int);
|
||||
void PlaylistDeleteSong(const string &, int);
|
||||
bool MoveSongUp(int);
|
||||
bool MoveSongDown(int);
|
||||
bool PlaylistMoveSongUp(const string &, int);
|
||||
bool PlaylistMoveSongDown(const string &, int);
|
||||
|
||||
string DisplayKeys(int *, int = 2);
|
||||
bool Keypressed(int, const int *);
|
||||
|
||||
31
src/menu.cpp
31
src/menu.cpp
@@ -21,6 +21,23 @@
|
||||
#include "menu.h"
|
||||
#include "misc.h"
|
||||
|
||||
Menu::Menu(const Menu &m) : Window(m)
|
||||
{
|
||||
for (vector<Option *>::const_iterator it = m.itsOptions.begin(); it != m.itsOptions.end(); it++)
|
||||
{
|
||||
Option *new_option = new Option(**it);
|
||||
itsOptions.push_back(new_option);
|
||||
}
|
||||
NeedsRedraw = m.NeedsRedraw;
|
||||
itsSelectedPrefix = m.itsSelectedPrefix;
|
||||
itsSelectedSuffix = m.itsSelectedSuffix;
|
||||
itsStaticsNumber = m.itsStaticsNumber;
|
||||
itsBeginning = m.itsBeginning;
|
||||
itsHighlight = m.itsHighlight;
|
||||
itsHighlightColor = m.itsHighlightColor;
|
||||
itsHighlightEnabled = m.itsHighlightEnabled;
|
||||
}
|
||||
|
||||
Menu::~Menu()
|
||||
{
|
||||
for (vector<Option *>::iterator it = itsOptions.begin(); it != itsOptions.end(); it++)
|
||||
@@ -274,7 +291,10 @@ void Menu::Refresh(bool redraw_whole_window)
|
||||
Highlight(itsOptions.size());
|
||||
|
||||
if (redraw_whole_window)
|
||||
{
|
||||
Window::Clear();
|
||||
redraw_screen();
|
||||
}
|
||||
|
||||
for (vector<int>::const_iterator it = NeedsRedraw.begin(); it != NeedsRedraw.end(); it++)
|
||||
{
|
||||
@@ -356,17 +376,12 @@ void Menu::Refresh(bool redraw_whole_window)
|
||||
}
|
||||
}
|
||||
|
||||
if (*it == itsHighlight && itsHighlightEnabled)
|
||||
{
|
||||
Reverse(0);
|
||||
SetBaseColor(old_basecolor);
|
||||
SetColor(old_basecolor);
|
||||
}
|
||||
if (itsOptions[*it]->is_bold)
|
||||
while (!itsColors.empty()) // clear color stack and disable bold and reverse as
|
||||
itsColors.pop(); // some items are too long to close all tags properly
|
||||
Reverse(0);
|
||||
Bold(0);
|
||||
|
||||
while (!itsColors.empty()) // clear color stack as some items are
|
||||
itsColors.pop(); // too long to close all tags properly
|
||||
}
|
||||
NeedsRedraw.clear();
|
||||
wrefresh(itsWindow);
|
||||
|
||||
@@ -46,6 +46,7 @@ class Menu : public Window
|
||||
{
|
||||
public:
|
||||
Menu(int startx, int starty, int width, int height, string title, COLOR color, BORDER border) : Window(startx, starty, width, height, title, color, border), itsSelectedPrefix("[r]"), itsSelectedSuffix("[/r]"), itsStaticsNumber(0), itsBeginning(0), itsHighlight(0), itsHighlightColor(itsBaseColor), itsHighlightEnabled(1) { SetColor(color); }
|
||||
Menu(const Menu &);
|
||||
virtual ~Menu();
|
||||
|
||||
virtual void Add(string str) { AddOption(str); }
|
||||
@@ -87,6 +88,7 @@ class Menu : public Window
|
||||
|
||||
bool Empty() { return itsOptions.empty(); }
|
||||
bool IsStatic(int);
|
||||
virtual Window * Clone() { return new Menu(*this); }
|
||||
virtual Window * EmptyClone();
|
||||
protected:
|
||||
vector<Option *> itsOptions;
|
||||
|
||||
@@ -266,6 +266,30 @@ void MPDConnection::ClearPlaylist() const
|
||||
}
|
||||
}
|
||||
|
||||
void MPDConnection::AddToPlaylist(const string &path, const Song &s) const
|
||||
{
|
||||
if (!s.Empty())
|
||||
AddToPlaylist(path, s.GetFile());
|
||||
}
|
||||
|
||||
void MPDConnection::AddToPlaylist(const string &path, const string &file) const
|
||||
{
|
||||
if (isConnected)
|
||||
{
|
||||
mpd_sendPlaylistAddCommand(itsConnection, (char *) path.c_str(), (char *) file.c_str());
|
||||
mpd_finishCommand(itsConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void MPDConnection::Move(const string &path, int from, int to) const
|
||||
{
|
||||
if (isConnected)
|
||||
{
|
||||
mpd_sendPlaylistMoveCommand(itsConnection, (char *) path.c_str(), from, to);
|
||||
mpd_finishCommand(itsConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void MPDConnection::GetPlaylistChanges(long long id, SongList &v) const
|
||||
{
|
||||
if (isConnected)
|
||||
@@ -411,7 +435,7 @@ void MPDConnection::QueueAddSong(const string &path)
|
||||
{
|
||||
QueueCommand *q = new QueueCommand;
|
||||
q->type = qctAdd;
|
||||
q->path = path;
|
||||
q->item_path = path;
|
||||
itsQueue.push_back(q);
|
||||
}
|
||||
}
|
||||
@@ -422,6 +446,24 @@ void MPDConnection::QueueAddSong(const Song &s)
|
||||
QueueAddSong(s.GetFile());
|
||||
}
|
||||
|
||||
void MPDConnection::QueueAddToPlaylist(const string &playlist, const string &path)
|
||||
{
|
||||
if (isConnected)
|
||||
{
|
||||
QueueCommand *q = new QueueCommand;
|
||||
q->type = qctAddToPlaylist;
|
||||
q->playlist_path = playlist;
|
||||
q->item_path = path;
|
||||
itsQueue.push_back(q);
|
||||
}
|
||||
}
|
||||
|
||||
void MPDConnection::QueueAddToPlaylist(const string &playlist, const Song &s)
|
||||
{
|
||||
if (!s.Empty())
|
||||
QueueAddToPlaylist(playlist, s.GetFile());
|
||||
}
|
||||
|
||||
void MPDConnection::QueueDeleteSong(int id)
|
||||
{
|
||||
if (isConnected)
|
||||
@@ -444,6 +486,18 @@ void MPDConnection::QueueDeleteSongId(int id)
|
||||
}
|
||||
}
|
||||
|
||||
void MPDConnection::QueueDeleteFromPlaylist(const string &playlist, int pos)
|
||||
{
|
||||
if (isConnected)
|
||||
{
|
||||
QueueCommand *q = new QueueCommand;
|
||||
q->type = qctDeleteFromPlaylist;
|
||||
q->playlist_path = playlist;
|
||||
q->id = pos;
|
||||
itsQueue.push_back(q);
|
||||
}
|
||||
}
|
||||
|
||||
bool MPDConnection::CommitQueue()
|
||||
{
|
||||
bool retval = false;
|
||||
@@ -455,7 +509,10 @@ bool MPDConnection::CommitQueue()
|
||||
switch ((*it)->type)
|
||||
{
|
||||
case qctAdd:
|
||||
mpd_sendAddCommand(itsConnection, (*it)->path.c_str());
|
||||
mpd_sendAddCommand(itsConnection, (*it)->item_path.c_str());
|
||||
break;
|
||||
case qctAddToPlaylist:
|
||||
mpd_sendPlaylistAddCommand(itsConnection, (char *) (*it)->playlist_path.c_str(), (char *) (*it)->item_path.c_str());
|
||||
break;
|
||||
case qctDelete:
|
||||
mpd_sendDeleteCommand(itsConnection, (*it)->id);
|
||||
@@ -463,6 +520,9 @@ bool MPDConnection::CommitQueue()
|
||||
case qctDeleteID:
|
||||
mpd_sendDeleteIdCommand(itsConnection, (*it)->id);
|
||||
break;
|
||||
case qctDeleteFromPlaylist:
|
||||
mpd_sendPlaylistDeleteCommand(itsConnection, (char *) (*it)->playlist_path.c_str(), (*it)->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mpd_sendCommandListEnd(itsConnection);
|
||||
@@ -497,6 +557,21 @@ bool MPDConnection::SavePlaylist(const string &name) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void MPDConnection::GetPlaylists(TagList &v) const
|
||||
{
|
||||
if (isConnected)
|
||||
{
|
||||
ItemList list;
|
||||
GetDirectory("/", list);
|
||||
for (ItemList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
if (it->type == itPlaylist)
|
||||
v.push_back(it->name);
|
||||
}
|
||||
FreeItemList(list);
|
||||
}
|
||||
}
|
||||
|
||||
void MPDConnection::GetArtists(TagList &v) const
|
||||
{
|
||||
if (isConnected)
|
||||
|
||||
13
src/mpdpp.h
13
src/mpdpp.h
@@ -24,7 +24,7 @@
|
||||
#include "ncmpcpp.h"
|
||||
#include "song.h"
|
||||
|
||||
enum QueueCommandType { qctAdd, qctDelete, qctDeleteID };
|
||||
enum QueueCommandType { qctAdd, qctAddToPlaylist, qctDelete, qctDeleteID, qctDeleteFromPlaylist };
|
||||
enum ItemType { itDirectory, itSong, itPlaylist };
|
||||
enum PlayerState { psUnknown, psStop, psPlay, psPause };
|
||||
|
||||
@@ -47,7 +47,8 @@ struct QueueCommand
|
||||
{
|
||||
QueueCommand() : id(0) { }
|
||||
QueueCommandType type;
|
||||
string path;
|
||||
string playlist_path;
|
||||
string item_path;
|
||||
int id;
|
||||
};
|
||||
|
||||
@@ -132,12 +133,19 @@ class MPDConnection
|
||||
int AddSong(const Song &); // returns id of added song
|
||||
void QueueAddSong(const string &);
|
||||
void QueueAddSong(const Song &);
|
||||
void QueueAddToPlaylist(const string &, const string &);
|
||||
void QueueAddToPlaylist(const string &, const Song &);
|
||||
void QueueDeleteSong(int);
|
||||
void QueueDeleteSongId(int);
|
||||
void QueueDeleteFromPlaylist(const string &, int);
|
||||
bool CommitQueue();
|
||||
|
||||
void DeletePlaylist(const string &) const;
|
||||
bool SavePlaylist(const string &) const;
|
||||
void ClearPlaylist(const string &) const;
|
||||
void AddToPlaylist(const string &, const Song &) const;
|
||||
void AddToPlaylist(const string &, const string &) const;
|
||||
void Move(const string &, int, int) const;
|
||||
|
||||
void StartSearch(bool) const;
|
||||
void StartFieldSearch(mpd_TagItems);
|
||||
@@ -145,6 +153,7 @@ class MPDConnection
|
||||
void CommitSearch(SongList &) const;
|
||||
void CommitSearch(TagList &) const;
|
||||
|
||||
void GetPlaylists(TagList &) const;
|
||||
void GetArtists(TagList &) const;
|
||||
void GetAlbums(string, TagList &) const;
|
||||
void GetDirectory(const string &, ItemList &) const;
|
||||
|
||||
567
src/ncmpcpp.cpp
567
src/ncmpcpp.cpp
@@ -50,6 +50,11 @@
|
||||
mvvline(main_start_y, lib_songs_start_x-1, 0, main_height); \
|
||||
mLibSongs->Display(redraw_me)
|
||||
|
||||
#define REFRESH_PLAYLIST_EDITOR_SCREEN \
|
||||
mPlaylistList->Display(redraw_me); \
|
||||
mvvline(main_start_y, lib_albums_start_x-1, 0, main_height); \
|
||||
mPlaylistEditor->Display(redraw_me)
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
const string tag_screen = "Tag editor";
|
||||
const string tag_screen_keydesc = "Edit song's tags\n";
|
||||
@@ -63,10 +68,12 @@ ncmpcpp_keys Key;
|
||||
|
||||
SongList vPlaylist;
|
||||
SongList vSearched;
|
||||
ItemList vBrowser;
|
||||
SongList vLibSongs;
|
||||
SongList vPlaylistContent;
|
||||
|
||||
ItemList vBrowser;
|
||||
TagList vArtists;
|
||||
SongList vSongs;
|
||||
|
||||
|
||||
vector<int> vFoundPositions;
|
||||
int found_pos = 0;
|
||||
@@ -80,6 +87,8 @@ Menu *mSearcher;
|
||||
Menu *mLibArtists;
|
||||
Menu *mLibAlbums;
|
||||
Menu *mLibSongs;
|
||||
Menu *mPlaylistList;
|
||||
Menu *mPlaylistEditor;
|
||||
Scrollpad *sHelp;
|
||||
Scrollpad *sLyrics;
|
||||
|
||||
@@ -128,7 +137,6 @@ bool block_progressbar_update = 0;
|
||||
bool block_statusbar_update = 0;
|
||||
bool allow_statusbar_unblock = 1;
|
||||
bool block_playlist_update = 0;
|
||||
bool block_library_update = 0;
|
||||
|
||||
bool search_case_sensitive = 1;
|
||||
bool search_mode_match = 1;
|
||||
@@ -193,9 +201,9 @@ int main(int argc, char *argv[])
|
||||
mPlaylist->SetSelectPrefix(Config.selected_item_prefix);
|
||||
mPlaylist->SetSelectSuffix(Config.selected_item_suffix);
|
||||
|
||||
mBrowser = static_cast<Menu *>(mPlaylist->EmptyClone());
|
||||
mTagEditor = static_cast<Menu *>(mPlaylist->EmptyClone());
|
||||
mSearcher = static_cast<Menu *>(mPlaylist->EmptyClone());
|
||||
mBrowser = static_cast<Menu *>(mPlaylist->Clone());
|
||||
mTagEditor = static_cast<Menu *>(mPlaylist->Clone());
|
||||
mSearcher = static_cast<Menu *>(mPlaylist->Clone());
|
||||
|
||||
int lib_artist_width = COLS/3-1;
|
||||
int lib_albums_width = COLS/3;
|
||||
@@ -206,6 +214,13 @@ int main(int argc, char *argv[])
|
||||
mLibArtists = new Menu(0, main_start_y, lib_artist_width, main_height, "Artists", Config.main_color, brNone);
|
||||
mLibAlbums = new Menu(lib_albums_start_x, main_start_y, lib_albums_width, main_height, "Albums", Config.main_color, brNone);
|
||||
mLibSongs = new Menu(lib_songs_start_x, main_start_y, lib_songs_width, main_height, "Songs", Config.main_color, brNone);
|
||||
mLibSongs->SetSelectPrefix(Config.selected_item_prefix);
|
||||
mLibSongs->SetSelectSuffix(Config.selected_item_suffix);
|
||||
|
||||
mPlaylistList = new Menu(0, main_start_y, lib_artist_width, main_height, "Playlists", Config.main_color, brNone);
|
||||
mPlaylistEditor = new Menu(lib_albums_start_x, main_start_y, lib_albums_width+lib_songs_width+1, main_height, "Playlist's content", Config.main_color, brNone);
|
||||
mPlaylistEditor->SetSelectPrefix(Config.selected_item_prefix);
|
||||
mPlaylistEditor->SetSelectSuffix(Config.selected_item_suffix);
|
||||
|
||||
sHelp = new Scrollpad(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
||||
sLyrics = static_cast<Scrollpad *>(sHelp->EmptyClone());
|
||||
@@ -223,7 +238,8 @@ int main(int argc, char *argv[])
|
||||
sHelp->Add(DisplayKeys(Key.Playlist) + "Playlist screen\n");
|
||||
sHelp->Add(DisplayKeys(Key.Browser) + "Browse screen\n");
|
||||
sHelp->Add(DisplayKeys(Key.SearchEngine) + "Search engine\n");
|
||||
sHelp->Add(DisplayKeys(Key.MediaLibrary) + "Media library\n\n\n");
|
||||
sHelp->Add(DisplayKeys(Key.MediaLibrary) + "Media library\n");
|
||||
sHelp->Add(DisplayKeys(Key.PlaylistEditor) + "Playlist editor\n\n\n");
|
||||
|
||||
sHelp->Add(" [b]Keys - Global\n -----------------------------------------[/b]\n");
|
||||
sHelp->Add(DisplayKeys(Key.Stop) + "Stop\n");
|
||||
@@ -235,6 +251,11 @@ int main(int argc, char *argv[])
|
||||
sHelp->Add(DisplayKeys(Key.VolumeDown) + "Decrease volume\n");
|
||||
sHelp->Add(DisplayKeys(Key.VolumeUp) + "Increase volume\n\n");
|
||||
|
||||
sHelp->Add(DisplayKeys(Key.ToggleSpaceMode) + "Toggle space mode (select/add items)\n");
|
||||
sHelp->Add(DisplayKeys(Key.ReverseSelection) + "Reverse selection\n");
|
||||
sHelp->Add(DisplayKeys(Key.DeselectAll) + "Deselect all items\n");
|
||||
sHelp->Add(DisplayKeys(Key.AddSelected) + "Add selected items to playlist/m3u file\n\n");
|
||||
|
||||
sHelp->Add(DisplayKeys(Key.ToggleRepeat) + "Toggle repeat mode\n");
|
||||
sHelp->Add(DisplayKeys(Key.ToggleRepeatOne) + "Toggle \"repeat one\" mode\n");
|
||||
sHelp->Add(DisplayKeys(Key.ToggleRandom) + "Toggle random mode\n");
|
||||
@@ -247,7 +268,7 @@ int main(int argc, char *argv[])
|
||||
sHelp->Add(DisplayKeys(Key.FindBackward) + "Backward find\n");
|
||||
sHelp->Add(DisplayKeys(Key.PrevFoundPosition) + "Go to previous found position\n");
|
||||
sHelp->Add(DisplayKeys(Key.NextFoundPosition) + "Go to next found position\n");
|
||||
sHelp->Add(DisplayKeys(Key.ToggleFindMode) + "Toggle find mode\n");
|
||||
sHelp->Add(DisplayKeys(Key.ToggleFindMode) + "Toggle find mode (normal/wrapped)\n");
|
||||
sHelp->Add(DisplayKeys(Key.EditTags) + tag_screen_keydesc);
|
||||
sHelp->Add(DisplayKeys(Key.GoToPosition) + "Go to chosen position in current song\n");
|
||||
sHelp->Add(DisplayKeys(Key.Lyrics) + "Show/hide song's lyrics\n\n");
|
||||
@@ -257,9 +278,6 @@ int main(int argc, char *argv[])
|
||||
sHelp->Add(" [b]Keys - Playlist screen\n -----------------------------------------[/b]\n");
|
||||
sHelp->Add(DisplayKeys(Key.Enter) + "Play\n");
|
||||
sHelp->Add(DisplayKeys(Key.Delete) + "Delete item/selected items from playlist\n");
|
||||
sHelp->Add(DisplayKeys(Key.Space) + "Select/deselect item\n");
|
||||
sHelp->Add(DisplayKeys(Key.ReverseSelection) + "Reverse selection\n");
|
||||
sHelp->Add(DisplayKeys(Key.DeselectAll) + "Deselect all items\n");
|
||||
sHelp->Add(DisplayKeys(Key.Clear) + "Clear whole playlist\n");
|
||||
sHelp->Add(DisplayKeys(Key.Crop) + "Clear playlist but hold currently playing/selected items\n");
|
||||
sHelp->Add(DisplayKeys(Key.MvSongUp) + "Move item up\n");
|
||||
@@ -323,15 +341,18 @@ int main(int argc, char *argv[])
|
||||
mLibSongs->Timeout(ncmpcpp_window_timeout);
|
||||
sLyrics->Timeout(ncmpcpp_window_timeout);
|
||||
wFooter->Timeout(ncmpcpp_window_timeout);
|
||||
mPlaylistList->Timeout(ncmpcpp_window_timeout);
|
||||
mPlaylistEditor->Timeout(ncmpcpp_window_timeout);
|
||||
|
||||
mPlaylist->HighlightColor(Config.main_highlight_color);
|
||||
mBrowser->HighlightColor(Config.main_highlight_color);
|
||||
mTagEditor->HighlightColor(Config.main_highlight_color);
|
||||
mSearcher->HighlightColor(Config.main_highlight_color);
|
||||
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||
mPlaylistList->HighlightColor(Config.main_highlight_color);
|
||||
mPlaylistEditor->HighlightColor(Config.main_highlight_color);
|
||||
|
||||
Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL);
|
||||
Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL);
|
||||
@@ -380,6 +401,9 @@ int main(int argc, char *argv[])
|
||||
case csLyrics:
|
||||
title = song_lyrics;
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
title = "Playlist editor";
|
||||
break;
|
||||
}
|
||||
|
||||
if (title_allowed)
|
||||
@@ -417,26 +441,33 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
else
|
||||
wHeader->WriteXY(0, 0, max_allowed_title_length, "[b]1:[/b]Help [b]2:[/b]Playlist [b]3:[/b]Browse [b]4:[/b]Search [b]5:[/b]Library", 1);
|
||||
wHeader->WriteXY(0, 0, max_allowed_title_length, "[b]1:[/b]Help [b]2:[/b]Playlist [b]3:[/b]Browse [b]4:[/b]Search [b]5:[/b]Library [b]6:[/b]Playlist editor", 1);
|
||||
|
||||
wHeader->SetColor(Config.volume_color);
|
||||
wHeader->WriteXY(max_allowed_title_length, 0, volume_state);
|
||||
wHeader->SetColor(Config.header_color);
|
||||
}
|
||||
|
||||
if (current_screen == csLibrary && !block_library_update)
|
||||
// media library stuff
|
||||
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
if (wCurrent == mLibAlbums && mLibAlbums->Empty())
|
||||
if (mLibArtists->Empty())
|
||||
{
|
||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||
wCurrent = mLibArtists;
|
||||
mLibAlbums->Clear(0);
|
||||
vArtists.clear();
|
||||
Mpd->GetArtists(vArtists);
|
||||
sort(vArtists.begin(), vArtists.end(), CaseInsensitiveComparison);
|
||||
for (TagList::const_iterator it = vArtists.begin(); it != vArtists.end(); it++)
|
||||
mLibArtists->AddOption(*it);
|
||||
mLibArtists->Window::Clear();
|
||||
mLibArtists->Refresh();
|
||||
}
|
||||
|
||||
if (wCurrent == mLibArtists)
|
||||
if (mLibAlbums->Empty())
|
||||
{
|
||||
mLibSongs->Clear(0);
|
||||
TagList list;
|
||||
mLibAlbums->Clear(0);
|
||||
Mpd->GetAlbums(mLibArtists->GetCurrentOption(), list);
|
||||
for (TagList::iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
@@ -459,17 +490,26 @@ int main(int argc, char *argv[])
|
||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
mLibAlbums->AddOption(*it);
|
||||
mLibAlbums->Window::Clear();
|
||||
mLibAlbums->Refresh();
|
||||
}
|
||||
|
||||
FreeSongList(vSongs);
|
||||
if (wCurrent == mLibAlbums && mLibAlbums->Empty())
|
||||
{
|
||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||
mLibArtists->HighlightColor(Config.active_column_color);
|
||||
wCurrent = mLibArtists;
|
||||
}
|
||||
|
||||
if (mLibSongs->Empty())
|
||||
{
|
||||
FreeSongList(vLibSongs);
|
||||
if (mLibAlbums->Empty())
|
||||
{
|
||||
mLibAlbums->WriteXY(0, 0, "No albums found.");
|
||||
mLibSongs->Clear(0);
|
||||
Mpd->StartSearch(1);
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetCurrentOption());
|
||||
Mpd->CommitSearch(vSongs);
|
||||
Mpd->CommitSearch(vLibSongs);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -477,20 +517,20 @@ int main(int argc, char *argv[])
|
||||
Mpd->StartSearch(1);
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetCurrentOption());
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, mLibAlbums->GetCurrentOption());
|
||||
Mpd->CommitSearch(vSongs);
|
||||
if (vSongs.empty())
|
||||
Mpd->CommitSearch(vLibSongs);
|
||||
if (vLibSongs.empty())
|
||||
{
|
||||
const string &album = mLibAlbums->GetCurrentOption();
|
||||
Mpd->StartSearch(1);
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ARTIST, mLibArtists->GetCurrentOption());
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, album.substr(7, album.length()-7));
|
||||
Mpd->CommitSearch(vSongs);
|
||||
Mpd->CommitSearch(vLibSongs);
|
||||
}
|
||||
}
|
||||
sort(vSongs.begin(), vSongs.end(), SortSongsByTrack);
|
||||
sort(vLibSongs.begin(), vLibSongs.end(), SortSongsByTrack);
|
||||
bool bold = 0;
|
||||
|
||||
for (SongList::const_iterator it = vSongs.begin(); it != vSongs.end(); it++)
|
||||
for (SongList::const_iterator it = vLibSongs.begin(); it != vLibSongs.end(); it++)
|
||||
{
|
||||
for (SongList::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++)
|
||||
{
|
||||
@@ -503,13 +543,50 @@ int main(int argc, char *argv[])
|
||||
bold ? mLibSongs->AddBoldOption(DisplaySong(**it, Config.song_library_format)) : mLibSongs->AddOption(DisplaySong(**it, Config.song_library_format));
|
||||
bold = 0;
|
||||
}
|
||||
|
||||
mLibAlbums->Refresh();
|
||||
mLibSongs->Window::Clear();
|
||||
mLibSongs->Refresh();
|
||||
|
||||
block_library_update = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// media library end
|
||||
|
||||
// playlist editor stuff
|
||||
|
||||
if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
if (mPlaylistList->Empty())
|
||||
{
|
||||
mPlaylistEditor->Clear(0);
|
||||
TagList list;
|
||||
Mpd->GetPlaylists(list);
|
||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
mPlaylistList->AddOption(*it);
|
||||
mPlaylistList->Window::Clear();
|
||||
mPlaylistList->Refresh();
|
||||
}
|
||||
|
||||
if (wCurrent == mPlaylistList && mPlaylistEditor->Empty())
|
||||
{
|
||||
FreeSongList(vPlaylistContent);
|
||||
Mpd->GetPlaylistContent(mPlaylistList->GetCurrentOption(), vPlaylistContent);
|
||||
for (SongList::const_iterator it = vPlaylistContent.begin(); it != vPlaylistContent.end(); it++)
|
||||
mPlaylistEditor->AddOption(DisplaySong(**it));
|
||||
mPlaylistEditor->Window::Clear();
|
||||
mPlaylistEditor->Refresh();
|
||||
}
|
||||
|
||||
if (wCurrent == mPlaylistEditor && mPlaylistEditor->Empty())
|
||||
{
|
||||
mPlaylistEditor->HighlightColor(Config.main_highlight_color);
|
||||
mPlaylistList->HighlightColor(Config.active_column_color);
|
||||
wCurrent = mPlaylistList;
|
||||
}
|
||||
|
||||
if (mPlaylistEditor->Empty())
|
||||
mPlaylistEditor->WriteXY(0, 0, "Playlist is empty.");
|
||||
}
|
||||
|
||||
// playlist editor end
|
||||
|
||||
wCurrent->Refresh(redraw_me);
|
||||
redraw_me = 0;
|
||||
@@ -518,9 +595,6 @@ int main(int argc, char *argv[])
|
||||
if (input == ERR)
|
||||
continue;
|
||||
|
||||
if (current_screen == csLibrary)
|
||||
block_library_update = 0;
|
||||
|
||||
title_allowed = 1;
|
||||
timer = time(NULL);
|
||||
|
||||
@@ -529,24 +603,25 @@ int main(int argc, char *argv[])
|
||||
case csPlaylist:
|
||||
mPlaylist->Highlighting(1);
|
||||
break;
|
||||
|
||||
case csBrowser:
|
||||
browsed_dir_scroll_begin--;
|
||||
break;
|
||||
case csLibrary:
|
||||
{
|
||||
if (Keypressed(input, Key.Up) || Keypressed(input, Key.Down) || Keypressed(input, Key.PageUp) || Keypressed(input, Key.PageDown) || Keypressed(input, Key.Home) || Keypressed(input, Key.End))
|
||||
if (Keypressed(input, Key.Up) || Keypressed(input, Key.Down) || Keypressed(input, Key.PageUp) || Keypressed(input, Key.PageDown) || Keypressed(input, Key.Home) || Keypressed(input, Key.End) || Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward) || Keypressed(input, Key.NextFoundPosition) || Keypressed(input, Key.PrevFoundPosition))
|
||||
{
|
||||
if (wCurrent == mLibArtists)
|
||||
{
|
||||
mLibAlbums->Reset();
|
||||
mLibSongs->Reset();
|
||||
}
|
||||
if (wCurrent == mLibAlbums)
|
||||
mLibSongs->Reset();
|
||||
mLibAlbums->Clear(0);
|
||||
else if (wCurrent == mLibAlbums)
|
||||
mLibSongs->Clear(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case csPlaylistEditor:
|
||||
{
|
||||
if (wCurrent == mPlaylistList && (Keypressed(input, Key.Up) || Keypressed(input, Key.Down) || Keypressed(input, Key.PageUp) || Keypressed(input, Key.PageDown) || Keypressed(input, Key.Home) || Keypressed(input, Key.End) || Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward) || Keypressed(input, Key.NextFoundPosition) || Keypressed(input, Key.PrevFoundPosition)))
|
||||
mPlaylistEditor->Clear(0);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -646,6 +721,10 @@ int main(int argc, char *argv[])
|
||||
mLibAlbums->MoveTo(lib_albums_start_x, main_start_y);
|
||||
mLibSongs->MoveTo(lib_songs_start_x, main_start_y);
|
||||
|
||||
mPlaylistList->Resize(lib_artist_width, main_height);
|
||||
mPlaylistEditor->Resize(lib_albums_width+lib_songs_width+1, main_height);
|
||||
mPlaylistEditor->MoveTo(lib_albums_start_x, main_start_y);
|
||||
|
||||
if (Config.header_visibility)
|
||||
wHeader->Resize(COLS, wHeader->GetHeight());
|
||||
|
||||
@@ -658,12 +737,12 @@ int main(int argc, char *argv[])
|
||||
wCurrent->Display(redraw_me);
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
mLibArtists->Hide();
|
||||
mLibAlbums->Hide();
|
||||
mLibSongs->Hide();
|
||||
REFRESH_MEDIA_LIBRARY_SCREEN;
|
||||
}
|
||||
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
REFRESH_PLAYLIST_EDITOR_SCREEN;
|
||||
}
|
||||
header_update_status = 1;
|
||||
PlayerState mpd_state = Mpd->GetState();
|
||||
MPDStatusChanges changes;
|
||||
@@ -883,7 +962,7 @@ int main(int argc, char *argv[])
|
||||
if (id == 8)
|
||||
{
|
||||
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||
mLibArtists->HighlightColor(Config.active_column_color);
|
||||
wCurrent = mLibArtists;
|
||||
}
|
||||
else
|
||||
@@ -1090,13 +1169,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (wCurrent == mLibAlbums)
|
||||
{
|
||||
for (SongList::const_iterator it = vSongs.begin(); it != vSongs.end(); it++)
|
||||
for (SongList::const_iterator it = vLibSongs.begin(); it != vLibSongs.end(); it++)
|
||||
Mpd->QueueAddSong(**it);
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Adding songs from: " + mLibArtists->GetCurrentOption() + " \"" + mLibAlbums->GetCurrentOption() + "\"");
|
||||
Song *s = vPlaylist[vPlaylist.size()-vSongs.size()];
|
||||
if (s->GetHash() == vSongs[0]->GetHash())
|
||||
Song *s = vPlaylist[vPlaylist.size()-vLibSongs.size()];
|
||||
if (s->GetHash() == vLibSongs[0]->GetHash())
|
||||
{
|
||||
if (Keypressed(input, Key.Enter))
|
||||
Mpd->PlayID(s->GetID());
|
||||
@@ -1107,9 +1186,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (wCurrent == mLibSongs)
|
||||
{
|
||||
if (!vSongs.empty())
|
||||
if (!vLibSongs.empty())
|
||||
{
|
||||
Song &s = *vSongs[mLibSongs->GetChoice()-1];
|
||||
Song &s = *vLibSongs[mLibSongs->GetChoice()-1];
|
||||
int id = Mpd->AddSong(s);
|
||||
if (id >= 0)
|
||||
{
|
||||
@@ -1133,13 +1212,19 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.Space))
|
||||
{
|
||||
if (current_screen == csPlaylist)
|
||||
if (Config.space_selects || wCurrent == mPlaylist || wCurrent == mPlaylistEditor)
|
||||
{
|
||||
int i = mPlaylist->GetChoice();
|
||||
mPlaylist->Select(i, !mPlaylist->Selected(i));
|
||||
mPlaylist->Go(DOWN);
|
||||
if (wCurrent == mPlaylist || (wCurrent == mBrowser && wCurrent->GetChoice() > (browsed_dir != "/" ? 1 : 0)) || (wCurrent == mSearcher && !vSearched.empty() && wCurrent->GetChoice() > search_engine_static_option) || wCurrent == mLibSongs || wCurrent == mPlaylistEditor)
|
||||
{
|
||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||
int i = mCurrent->GetChoice();
|
||||
mCurrent->Select(i, !mCurrent->Selected(i));
|
||||
mCurrent->Go(DOWN);
|
||||
}
|
||||
else if (current_screen == csBrowser)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (current_screen == csBrowser)
|
||||
{
|
||||
int ci = mBrowser->GetChoice()-1;
|
||||
switch (vBrowser[ci].type)
|
||||
@@ -1203,16 +1288,19 @@ int main(int argc, char *argv[])
|
||||
else if (current_screen == csLibrary)
|
||||
goto ENTER_LIBRARY_SCREEN; // sorry, but that's stupid to copy the same code here.
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.VolumeUp))
|
||||
{
|
||||
if (current_screen == csLibrary && input == Key.VolumeUp[0])
|
||||
{
|
||||
found_pos = 0;
|
||||
vFoundPositions.clear();
|
||||
if (wCurrent == mLibArtists)
|
||||
{
|
||||
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mLibAlbums;
|
||||
mLibAlbums->HighlightColor(Config.library_active_column_color);
|
||||
mLibAlbums->HighlightColor(Config.active_column_color);
|
||||
if (!mLibAlbums->Empty())
|
||||
continue;
|
||||
}
|
||||
@@ -1221,9 +1309,18 @@ int main(int argc, char *argv[])
|
||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mLibSongs;
|
||||
mLibSongs->HighlightColor(Config.library_active_column_color);
|
||||
mLibSongs->HighlightColor(Config.active_column_color);
|
||||
}
|
||||
}
|
||||
else if (wCurrent == mPlaylistList && input == Key.VolumeUp[0])
|
||||
{
|
||||
found_pos = 0;
|
||||
vFoundPositions.clear();
|
||||
mPlaylistList->HighlightColor(Config.main_highlight_color);
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mPlaylistEditor;
|
||||
mPlaylistEditor->HighlightColor(Config.active_column_color);
|
||||
}
|
||||
else
|
||||
Mpd->SetVolume(Mpd->GetVolume()+1);
|
||||
}
|
||||
@@ -1231,12 +1328,14 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (current_screen == csLibrary && input == Key.VolumeDown[0])
|
||||
{
|
||||
found_pos = 0;
|
||||
vFoundPositions.clear();
|
||||
if (wCurrent == mLibSongs)
|
||||
{
|
||||
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mLibAlbums;
|
||||
mLibAlbums->HighlightColor(Config.library_active_column_color);
|
||||
mLibAlbums->HighlightColor(Config.active_column_color);
|
||||
if (!mLibAlbums->Empty())
|
||||
continue;
|
||||
}
|
||||
@@ -1245,9 +1344,18 @@ int main(int argc, char *argv[])
|
||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mLibArtists;
|
||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||
mLibArtists->HighlightColor(Config.active_column_color);
|
||||
}
|
||||
}
|
||||
else if (wCurrent == mPlaylistEditor && input == Key.VolumeDown[0])
|
||||
{
|
||||
found_pos = 0;
|
||||
vFoundPositions.clear();
|
||||
mPlaylistEditor->HighlightColor(Config.main_highlight_color);
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mPlaylistList;
|
||||
mPlaylistList->HighlightColor(Config.active_column_color);
|
||||
}
|
||||
else
|
||||
Mpd->SetVolume(Mpd->GetVolume()-1);
|
||||
}
|
||||
@@ -1282,13 +1390,15 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Mpd->CommitQueue();
|
||||
}
|
||||
if (current_screen == csBrowser)
|
||||
else if (current_screen == csBrowser || wCurrent == mPlaylistList)
|
||||
{
|
||||
LOCK_STATUSBAR;
|
||||
int id = mBrowser->GetChoice()-1;
|
||||
if (vBrowser[id].type == itPlaylist)
|
||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||
int id = mCurrent->GetChoice()-1;
|
||||
const string &name = wCurrent == mBrowser ? vBrowser[id].name : mPlaylistList->GetCurrentOption();
|
||||
if (current_screen != csBrowser || vBrowser[id].type == itPlaylist)
|
||||
{
|
||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Delete playlist " + vBrowser[id].name + " ? [y/n] ", 1);
|
||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Delete playlist " + name + " ? [y/n] ", 1);
|
||||
curs_set(1);
|
||||
int in = 0;
|
||||
do
|
||||
@@ -1299,16 +1409,43 @@ int main(int argc, char *argv[])
|
||||
while (in != 'y' && in != 'n');
|
||||
if (in == 'y')
|
||||
{
|
||||
Mpd->DeletePlaylist(vBrowser[id].name);
|
||||
ShowMessage("Playlist " + vBrowser[id].name + " deleted!");
|
||||
Mpd->DeletePlaylist(name);
|
||||
ShowMessage("Playlist " + name + " deleted!");
|
||||
GetDirectory("/");
|
||||
}
|
||||
else
|
||||
ShowMessage("Aborted!");
|
||||
curs_set(0);
|
||||
mPlaylistList->Clear(0); // make playlists list update itself
|
||||
}
|
||||
UNLOCK_STATUSBAR;
|
||||
}
|
||||
else if (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||
{
|
||||
if (mPlaylistEditor->IsAnySelected())
|
||||
{
|
||||
vector<int> list;
|
||||
mPlaylistEditor->GetSelectedList(list);
|
||||
for (vector<int>::const_reverse_iterator it = list.rbegin(); it != list.rend(); it++)
|
||||
PlaylistDeleteSong(mPlaylistList->GetCurrentOption(), *it-1);
|
||||
ShowMessage("Selected items deleted from playlist '" + mPlaylistList->GetCurrentOption() + "'!");
|
||||
redraw_me = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPlaylistEditor->Timeout(50);
|
||||
while (!vPlaylistContent.empty() && Keypressed(input, Key.Delete))
|
||||
{
|
||||
TraceMpdStatus();
|
||||
timer = time(NULL);
|
||||
PlaylistDeleteSong(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1);
|
||||
mPlaylistEditor->Refresh();
|
||||
mPlaylistEditor->ReadKey(input);
|
||||
}
|
||||
mPlaylistEditor->Timeout(ncmpcpp_window_timeout);
|
||||
}
|
||||
Mpd->CommitQueue();
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.Prev))
|
||||
Mpd->Prev();
|
||||
@@ -1330,9 +1467,31 @@ int main(int argc, char *argv[])
|
||||
if (!playlist_name.empty())
|
||||
{
|
||||
if (Mpd->SavePlaylist(playlist_name))
|
||||
{
|
||||
ShowMessage("Playlist saved as: " + playlist_name);
|
||||
mPlaylistList->Clear(0); // make playlist's list update itself
|
||||
}
|
||||
else
|
||||
ShowMessage("Playlist already exists!");
|
||||
{
|
||||
LOCK_STATUSBAR;
|
||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Playlist already exists, overwrite: " + playlist_name + " ? [y/n] ", 1);
|
||||
curs_set(1);
|
||||
int in = 0;
|
||||
while (in != 'y' && in != 'n')
|
||||
wFooter->ReadKey(in);
|
||||
|
||||
if (in == 'y')
|
||||
{
|
||||
Mpd->DeletePlaylist(playlist_name);
|
||||
if (Mpd->SavePlaylist(playlist_name))
|
||||
ShowMessage("Playlist overwritten!");
|
||||
}
|
||||
else
|
||||
ShowMessage("Aborted!");
|
||||
curs_set(0);
|
||||
mPlaylistList->Clear(0); // make playlist's list update itself
|
||||
UNLOCK_STATUSBAR;
|
||||
}
|
||||
}
|
||||
if (browsed_dir == "/" && !vBrowser.empty())
|
||||
GetDirectory(browsed_dir);
|
||||
@@ -1340,6 +1499,8 @@ int main(int argc, char *argv[])
|
||||
else if (Keypressed(input, Key.Stop))
|
||||
Mpd->Stop();
|
||||
else if (Keypressed(input, Key.MvSongUp))
|
||||
{
|
||||
if (current_screen == csPlaylist)
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
if (mPlaylist->IsAnySelected())
|
||||
@@ -1360,7 +1521,30 @@ int main(int argc, char *argv[])
|
||||
if (MoveSongUp(mPlaylist->GetChoice()-1))
|
||||
mPlaylist->Go(UP);
|
||||
}
|
||||
else if (wCurrent == mPlaylistEditor)
|
||||
{
|
||||
if (mPlaylistEditor->IsAnySelected())
|
||||
{
|
||||
vector<int> list;
|
||||
mPlaylistEditor->GetSelectedList(list);
|
||||
mPlaylistEditor->Highlight(list[(list.size()-1)/2]-1);
|
||||
for (vector<int>::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
if (!PlaylistMoveSongUp(mPlaylistList->GetCurrentOption(), *it-1))
|
||||
{
|
||||
mPlaylistEditor->Go(DOWN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (PlaylistMoveSongUp(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1))
|
||||
mPlaylistEditor->Go(UP);
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.MvSongDown))
|
||||
{
|
||||
if (current_screen == csPlaylist)
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
if (mPlaylist->IsAnySelected())
|
||||
@@ -1381,6 +1565,27 @@ int main(int argc, char *argv[])
|
||||
if (MoveSongDown(mPlaylist->GetChoice()-1))
|
||||
mPlaylist->Go(DOWN);
|
||||
}
|
||||
else if (wCurrent == mPlaylistEditor)
|
||||
{
|
||||
if (mPlaylistEditor->IsAnySelected())
|
||||
{
|
||||
vector<int> list;
|
||||
mPlaylistEditor->GetSelectedList(list);
|
||||
mPlaylistEditor->Highlight(list[(list.size()-1)/2]+1);
|
||||
for (vector<int>::const_reverse_iterator it = list.rbegin(); it != list.rend(); it++)
|
||||
{
|
||||
if (!PlaylistMoveSongDown(mPlaylistList->GetCurrentOption(), *it-1))
|
||||
{
|
||||
mPlaylistEditor->Go(UP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (PlaylistMoveSongDown(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1))
|
||||
mPlaylistEditor->Go(DOWN);
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.Add))
|
||||
{
|
||||
LOCK_STATUSBAR;
|
||||
@@ -1506,7 +1711,7 @@ int main(int argc, char *argv[])
|
||||
if ((wCurrent == mPlaylist && !vPlaylist.empty())
|
||||
|| (wCurrent == mBrowser && vBrowser[mBrowser->GetChoice()-1].type == itSong)
|
||||
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|
||||
|| (wCurrent == mLibSongs && !vSongs.empty()))
|
||||
|| (wCurrent == mLibSongs && !vLibSongs.empty()))
|
||||
{
|
||||
int id = wCurrent->GetChoice()-1;
|
||||
Song *s;
|
||||
@@ -1522,7 +1727,7 @@ int main(int argc, char *argv[])
|
||||
s = vSearched[id-search_engine_static_option];
|
||||
break;
|
||||
case csLibrary:
|
||||
s = vSongs[id];
|
||||
s = vLibSongs[id];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1557,22 +1762,173 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.ReverseSelection))
|
||||
{
|
||||
if (current_screen == csPlaylist)
|
||||
if (wCurrent == mPlaylist || wCurrent == mBrowser || (wCurrent == mSearcher && !vSearched.empty()) || wCurrent == mLibSongs || wCurrent == mPlaylistEditor)
|
||||
{
|
||||
for (int i = 1; i <= mPlaylist->MaxChoice(); i++)
|
||||
mPlaylist->Select(i, !mPlaylist->Selected(i));
|
||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||
for (int i = 1; i <= mCurrent->MaxChoice(); i++)
|
||||
mCurrent->Select(i, !mCurrent->Selected(i) && !mCurrent->IsStatic(i));
|
||||
// hackish shit begins
|
||||
if (mCurrent == mBrowser && browsed_dir != "/")
|
||||
mCurrent->Select(1, 0); // [..] cannot be selected, uhm.
|
||||
if (mCurrent == mSearcher)
|
||||
mCurrent->Select(14, 0); // 'Reset' cannot be selected, omgplz.
|
||||
// hacking shit ends. need better solution :/
|
||||
ShowMessage("Selection reversed!");
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.DeselectAll))
|
||||
{
|
||||
if (current_screen == csPlaylist && mPlaylist->IsAnySelected())
|
||||
if (wCurrent == mPlaylist || wCurrent == mBrowser || wCurrent == mSearcher || wCurrent == mLibSongs || wCurrent == mPlaylistEditor)
|
||||
{
|
||||
for (int i = 1; i <= mPlaylist->MaxChoice(); i++)
|
||||
mPlaylist->Select(i, 0);
|
||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||
if (mCurrent->IsAnySelected())
|
||||
{
|
||||
for (int i = 1; i <= mCurrent->MaxChoice(); i++)
|
||||
mCurrent->Select(i, 0);
|
||||
ShowMessage("Items deselected!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.AddSelected))
|
||||
{
|
||||
if (wCurrent == mPlaylist || wCurrent == mBrowser || wCurrent == mSearcher || wCurrent == mLibSongs || wCurrent == mPlaylistEditor)
|
||||
{
|
||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||
if (mCurrent->IsAnySelected())
|
||||
{
|
||||
vector<int> list;
|
||||
mCurrent->GetSelectedList(list);
|
||||
SongList result;
|
||||
for (vector<int>::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
{
|
||||
Song *s = new Song(*vPlaylist[*it-1]);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case csBrowser:
|
||||
{
|
||||
switch (vBrowser[*it-1].type)
|
||||
{
|
||||
case itDirectory:
|
||||
{
|
||||
if (browsed_dir != "/")
|
||||
Mpd->GetDirectoryRecursive(browsed_dir + "/" + vBrowser[*it-1].name, result);
|
||||
else
|
||||
Mpd->GetDirectoryRecursive(vBrowser[*it-1].name, result);
|
||||
break;
|
||||
}
|
||||
case itSong:
|
||||
{
|
||||
Song *s = new Song(*vBrowser[*it-1].song);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case itPlaylist:
|
||||
{
|
||||
Mpd->GetPlaylistContent(vBrowser[*it-1].name, result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case csSearcher:
|
||||
{
|
||||
Song *s = new Song(*vSearched[*it-search_engine_static_option-1]);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case csLibrary:
|
||||
{
|
||||
Song *s = new Song(*vLibSongs[*it-1]);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case csPlaylistEditor:
|
||||
{
|
||||
Song *s = new Song(*vPlaylistContent[*it-1]);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Menu *mDialog = new Menu((COLS-50)/2, (LINES-10)/2, 50, 10, "Add selected items to...", clYellow, brGreen);
|
||||
mDialog->Timeout(ncmpcpp_window_timeout);
|
||||
|
||||
mDialog->AddOption("Current MPD playlist");
|
||||
mDialog->AddSeparator();
|
||||
TagList playlists;
|
||||
Mpd->GetPlaylists(playlists);
|
||||
for (TagList::const_iterator it = playlists.begin(); it != playlists.end(); it++)
|
||||
mDialog->AddOption(*it);
|
||||
mDialog->AddSeparator();
|
||||
mDialog->AddOption("Cancel");
|
||||
|
||||
mDialog->Display();
|
||||
|
||||
while (!Keypressed(input, Key.Enter))
|
||||
{
|
||||
mDialog->Refresh();
|
||||
mDialog->ReadKey(input);
|
||||
|
||||
if (Keypressed(input, Key.Up))
|
||||
mDialog->Go(UP);
|
||||
else if (Keypressed(input, Key.Down))
|
||||
mDialog->Go(DOWN);
|
||||
else if (Keypressed(input, Key.PageUp))
|
||||
mDialog->Go(PAGE_UP);
|
||||
else if (Keypressed(input, Key.PageDown))
|
||||
mDialog->Go(PAGE_DOWN);
|
||||
else if (Keypressed(input, Key.Home))
|
||||
mDialog->Go(HOME);
|
||||
else if (Keypressed(input, Key.End))
|
||||
mDialog->Go(END);
|
||||
}
|
||||
|
||||
int id = mDialog->GetChoice();
|
||||
|
||||
if (id == 1)
|
||||
{
|
||||
for (SongList::const_iterator it = result.begin(); it != result.end(); it++)
|
||||
Mpd->QueueAddSong(**it);
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Selected items added!");
|
||||
Song *s = vPlaylist[vPlaylist.size()-result.size()];
|
||||
if (s->GetHash() != result[0]->GetHash())
|
||||
ShowMessage(message_part_of_songs_added);
|
||||
}
|
||||
}
|
||||
else if (id > 1 && id < mDialog->MaxChoice())
|
||||
{
|
||||
for (SongList::const_iterator it = result.begin(); it != result.end(); it++)
|
||||
Mpd->QueueAddToPlaylist(mDialog->GetCurrentOption(), **it);
|
||||
Mpd->CommitQueue();
|
||||
ShowMessage("Selected items added to playlist '" + mDialog->GetCurrentOption() + "'!");
|
||||
}
|
||||
|
||||
redraw_me = 1;
|
||||
mPlaylistEditor->Clear(0); // make playlist editor update itself
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
REFRESH_MEDIA_LIBRARY_SCREEN;
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
REFRESH_PLAYLIST_EDITOR_SCREEN;
|
||||
}
|
||||
FreeSongList(result);
|
||||
}
|
||||
else
|
||||
ShowMessage("No selected items!");
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.Crop))
|
||||
{
|
||||
if (mPlaylist->IsAnySelected())
|
||||
@@ -1694,6 +2050,11 @@ int main(int argc, char *argv[])
|
||||
Config.wrapped_search = !Config.wrapped_search;
|
||||
ShowMessage("Search mode: " + string(Config.wrapped_search ? "Wrapped" : "Normal"));
|
||||
}
|
||||
else if (Keypressed(input, Key.ToggleSpaceMode))
|
||||
{
|
||||
Config.space_selects = !Config.space_selects;
|
||||
ShowMessage("Space mode: " + string(Config.space_selects ? "Select/deselect" : "Add") + " item");
|
||||
}
|
||||
else if (Keypressed(input, Key.Lyrics))
|
||||
{
|
||||
if (wCurrent == sLyrics)
|
||||
@@ -1711,7 +2072,7 @@ int main(int argc, char *argv[])
|
||||
if ((wCurrent == mPlaylist && !vPlaylist.empty())
|
||||
|| (wCurrent == mBrowser && vBrowser[mBrowser->GetChoice()-1].type == itSong)
|
||||
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|
||||
|| (wCurrent == mLibSongs && !vSongs.empty()))
|
||||
|| (wCurrent == mLibSongs && !vLibSongs.empty()))
|
||||
{
|
||||
Song *s;
|
||||
switch (current_screen)
|
||||
@@ -1726,7 +2087,7 @@ int main(int argc, char *argv[])
|
||||
s = vSearched[mSearcher->GetRealChoice()-2]; // first one is 'Reset'
|
||||
break;
|
||||
case csLibrary:
|
||||
s = vSongs[mLibSongs->GetChoice()-1];
|
||||
s = vLibSongs[mLibSongs->GetChoice()-1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1855,25 +2216,55 @@ int main(int argc, char *argv[])
|
||||
found_pos = 0;
|
||||
vFoundPositions.clear();
|
||||
|
||||
if (mLibArtists->Empty())
|
||||
{
|
||||
Mpd->GetArtists(vArtists);
|
||||
sort(vArtists.begin(), vArtists.end(), CaseInsensitiveComparison);
|
||||
for (TagList::const_iterator it = vArtists.begin(); it != vArtists.end(); it++)
|
||||
mLibArtists->AddOption(*it);
|
||||
}
|
||||
|
||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||
mLibArtists->HighlightColor(Config.active_column_color);
|
||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||
|
||||
wCurrent->Hide();
|
||||
mPlaylist->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
|
||||
redraw_me = 1;
|
||||
REFRESH_MEDIA_LIBRARY_SCREEN;
|
||||
|
||||
wCurrent = mLibArtists;
|
||||
current_screen = csLibrary;
|
||||
|
||||
if (!vLibSongs.empty())
|
||||
{
|
||||
bool bold = 0;
|
||||
for (int i = 0; i < vLibSongs.size(); i++)
|
||||
{
|
||||
for (SongList::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++)
|
||||
{
|
||||
if ((*it)->GetHash() == vLibSongs[i]->GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mLibSongs->BoldOption(i+1, bold);
|
||||
bold = 0;
|
||||
}
|
||||
mLibSongs->Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.PlaylistEditor))
|
||||
{
|
||||
if (current_screen != csPlaylistEditor)
|
||||
{
|
||||
found_pos = 0;
|
||||
vFoundPositions.clear();
|
||||
|
||||
mPlaylistList->HighlightColor(Config.active_column_color);
|
||||
mPlaylistEditor->HighlightColor(Config.main_highlight_color);
|
||||
|
||||
mPlaylist->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
|
||||
redraw_me = 1;
|
||||
REFRESH_PLAYLIST_EDITOR_SCREEN;
|
||||
|
||||
wCurrent = mPlaylistList;
|
||||
current_screen = csPlaylistEditor;
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.Quit))
|
||||
|
||||
@@ -52,7 +52,7 @@ const bool UNICODE = 0;
|
||||
#include "scrollpad.h"
|
||||
#include "misc.h"
|
||||
|
||||
enum NcmpcppScreen { csHelp, csPlaylist, csBrowser, csTagEditor, csSearcher, csLibrary, csLyrics };
|
||||
enum NcmpcppScreen { csHelp, csPlaylist, csBrowser, csTagEditor, csSearcher, csLibrary, csLyrics, csPlaylistEditor };
|
||||
|
||||
const int ncmpcpp_window_timeout = 500;
|
||||
const int search_engine_static_option = 17;
|
||||
|
||||
@@ -20,6 +20,15 @@
|
||||
|
||||
#include "scrollpad.h"
|
||||
|
||||
Scrollpad::Scrollpad(const Scrollpad &s) : Window(s)
|
||||
{
|
||||
itsContent = s.itsContent;
|
||||
itsRawContent = s.itsRawContent;
|
||||
itsBeginning = s.itsBeginning;
|
||||
itsRealHeight = s.itsRealHeight;
|
||||
itsXPos = s.itsXPos;
|
||||
}
|
||||
|
||||
void Scrollpad::Add(string str)
|
||||
{
|
||||
if (itsXPos > 0 && (str[0] != ' ' || str[0] != '\n'))
|
||||
@@ -220,20 +229,3 @@ Window * Scrollpad::EmptyClone()
|
||||
return new Scrollpad(GetStartX(),GetStartY(),GetWidth(),GetHeight(),itsTitle,itsBaseColor,itsBorder);
|
||||
}
|
||||
|
||||
Scrollpad & Scrollpad::operator=(const Scrollpad &base)
|
||||
{
|
||||
if (this == &base)
|
||||
return *this;
|
||||
itsWindow = base.itsWindow;
|
||||
itsStartX = base.itsStartX;
|
||||
itsStartY = base.itsStartY;
|
||||
itsWidth = base.itsWidth;
|
||||
itsHeight = base.itsHeight;
|
||||
itsTitle = base.itsTitle;
|
||||
itsBorder = base.itsBorder;
|
||||
itsColor = base.itsColor;
|
||||
itsContent = base.itsContent;
|
||||
itsBeginning = base.itsBeginning;
|
||||
itsRealHeight = base.itsRealHeight;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class Scrollpad: public Window
|
||||
{
|
||||
public:
|
||||
Scrollpad(int startx, int starty, int width, int height, string title, COLOR color, BORDER border) : Window(startx, starty, width, height, title, color, border), itsBeginning(0), itsRealHeight(1), itsXPos(0) { delwin(itsWindow); itsWindow = newpad(itsHeight,itsWidth); }
|
||||
Scrollpad(const Scrollpad &);
|
||||
virtual ~Scrollpad() {}
|
||||
virtual void Add(string);
|
||||
virtual void Display(bool = 0);
|
||||
@@ -37,8 +38,8 @@ class Scrollpad: public Window
|
||||
virtual void SetBorder(BORDER);
|
||||
virtual void SetTitle(string);
|
||||
virtual void Clear();
|
||||
virtual Window * Clone() { return new Scrollpad(*this); }
|
||||
virtual Window * EmptyClone();
|
||||
Scrollpad & operator=(const Scrollpad &);
|
||||
protected:
|
||||
void print_content();
|
||||
virtual void recreate_win();
|
||||
|
||||
@@ -44,6 +44,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.Browser[0] = '3';
|
||||
keys.SearchEngine[0] = '4';
|
||||
keys.MediaLibrary[0] = '5';
|
||||
keys.PlaylistEditor[0] = '6';
|
||||
keys.Stop[0] = 's';
|
||||
keys.Pause[0] = 'P';
|
||||
keys.Next[0] = '>';
|
||||
@@ -53,6 +54,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.ToggleRepeat[0] = 'r';
|
||||
keys.ToggleRepeatOne[0] = 'R';
|
||||
keys.ToggleRandom[0] = 'z';
|
||||
keys.ToggleSpaceMode[0] = 't';
|
||||
keys.Shuffle[0] = 'Z';
|
||||
keys.ToggleCrossfade[0] = 'x';
|
||||
keys.SetCrossfade[0] = 'X';
|
||||
@@ -67,6 +69,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.Lyrics[0] = 'l';
|
||||
keys.ReverseSelection[0] = 'v';
|
||||
keys.DeselectAll[0] = 'V';
|
||||
keys.AddSelected[0] = 'A';
|
||||
keys.Clear[0] = 'c';
|
||||
keys.Crop[0] = 'C';
|
||||
keys.MvSongUp[0] = 'm';
|
||||
@@ -90,11 +93,12 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.VolumeUp[1] = '+';
|
||||
keys.VolumeDown[1] = '-';
|
||||
keys.ScreenSwitcher[1] = null_key;
|
||||
keys.Help[1] = null_key;
|
||||
keys.Playlist[1] = null_key;
|
||||
keys.Browser[1] = null_key;
|
||||
keys.SearchEngine[1] = null_key;
|
||||
keys.MediaLibrary[1] = null_key;
|
||||
keys.Help[1] = 265;
|
||||
keys.Playlist[1] = 266;
|
||||
keys.Browser[1] = 267;
|
||||
keys.SearchEngine[1] = 268;
|
||||
keys.MediaLibrary[1] = 269;
|
||||
keys.PlaylistEditor[1] = 270;
|
||||
keys.Stop[1] = null_key;
|
||||
keys.Pause[1] = null_key;
|
||||
keys.Next[1] = null_key;
|
||||
@@ -104,6 +108,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.ToggleRepeat[1] = null_key;
|
||||
keys.ToggleRepeatOne[1] = null_key;
|
||||
keys.ToggleRandom[1] = null_key;
|
||||
keys.ToggleSpaceMode[1] = null_key;
|
||||
keys.Shuffle[1] = null_key;
|
||||
keys.ToggleCrossfade[1] = null_key;
|
||||
keys.SetCrossfade[1] = null_key;
|
||||
@@ -118,6 +123,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.Lyrics[1] = null_key;
|
||||
keys.ReverseSelection[1] = null_key;
|
||||
keys.DeselectAll[1] = null_key;
|
||||
keys.AddSelected[1] = null_key;
|
||||
keys.Clear[1] = null_key;
|
||||
keys.Crop[1] = null_key;
|
||||
keys.MvSongUp[1] = null_key;
|
||||
@@ -149,13 +155,14 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.main_highlight_color = conf.main_color;
|
||||
conf.progressbar_color = clDefault;
|
||||
conf.statusbar_color = clDefault;
|
||||
conf.library_active_column_color = clRed;
|
||||
conf.active_column_color = clRed;
|
||||
conf.colors_enabled = true;
|
||||
conf.header_visibility = true;
|
||||
conf.statusbar_visibility = true;
|
||||
conf.autocenter_mode = false;
|
||||
conf.repeat_one_mode = false;
|
||||
conf.wrapped_search = true;
|
||||
conf.space_selects = false;
|
||||
conf.set_window_title = true;
|
||||
conf.mpd_connection_timeout = 15;
|
||||
conf.crossfade_time = 5;
|
||||
@@ -305,6 +312,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
||||
GetKeys(*it, keys.SearchEngine);
|
||||
else if (it->find("key_media_library ") != string::npos)
|
||||
GetKeys(*it, keys.MediaLibrary);
|
||||
else if (it->find("key_playlist_editor ") != string::npos)
|
||||
GetKeys(*it, keys.PlaylistEditor);
|
||||
else if (it->find("key_stop ") != string::npos)
|
||||
GetKeys(*it, keys.Stop);
|
||||
else if (it->find("key_pause ") != string::npos)
|
||||
@@ -323,6 +332,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
||||
GetKeys(*it, keys.ToggleRepeatOne);
|
||||
else if (it->find("key_toggle_random ") != string::npos)
|
||||
GetKeys(*it, keys.ToggleRandom);
|
||||
else if (it->find("key_toggle_space_mode ") != string::npos)
|
||||
GetKeys(*it, keys.ToggleSpaceMode);
|
||||
else if (it->find("key_shuffle ") != string::npos)
|
||||
GetKeys(*it, keys.Shuffle);
|
||||
else if (it->find("key_toggle_crossfade ") != string::npos)
|
||||
@@ -351,6 +362,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
||||
GetKeys(*it, keys.ReverseSelection);
|
||||
else if (it->find("key_deselect_all ") != string::npos)
|
||||
GetKeys(*it, keys.DeselectAll);
|
||||
else if (it->find("key_add_selected_items ") != string::npos)
|
||||
GetKeys(*it, keys.AddSelected);
|
||||
else if (it->find("key_clear ") != string::npos)
|
||||
GetKeys(*it, keys.Clear);
|
||||
else if (it->find("key_crop ") != string::npos)
|
||||
@@ -460,8 +473,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
conf.autocenter_mode = v == "yes";
|
||||
else if (it->find("repeat_one_mode") != string::npos)
|
||||
conf.repeat_one_mode = v == "yes";
|
||||
else if (it->find("find_mode") != string::npos)
|
||||
else if (it->find("default_find_mode") != string::npos)
|
||||
conf.wrapped_search = v == "wrapped";
|
||||
else if (it->find("default_space_mode") != string::npos)
|
||||
conf.space_selects = v == "select";
|
||||
else if (it->find("enable_window_title") != string::npos)
|
||||
conf.set_window_title = v == "yes";
|
||||
else if (it->find("song_window_title_format") != string::npos)
|
||||
@@ -514,10 +529,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
if (!v.empty())
|
||||
conf.statusbar_color = IntoColor(v);
|
||||
}
|
||||
else if (it->find("library_active_column_color") != string::npos)
|
||||
else if (it->find("active_column_color") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.library_active_column_color = IntoColor(v);
|
||||
conf.active_column_color = IntoColor(v);
|
||||
}
|
||||
}
|
||||
f.close();
|
||||
|
||||
@@ -46,6 +46,7 @@ struct ncmpcpp_keys
|
||||
int Browser[2];
|
||||
int SearchEngine[2];
|
||||
int MediaLibrary[2];
|
||||
int PlaylistEditor[2];
|
||||
int Stop[2];
|
||||
int Pause[2];
|
||||
int Next[2];
|
||||
@@ -55,6 +56,7 @@ struct ncmpcpp_keys
|
||||
int ToggleRepeat[2];
|
||||
int ToggleRepeatOne[2];
|
||||
int ToggleRandom[2];
|
||||
int ToggleSpaceMode[2];
|
||||
int Shuffle[2];
|
||||
int ToggleCrossfade[2];
|
||||
int SetCrossfade[2];
|
||||
@@ -69,6 +71,7 @@ struct ncmpcpp_keys
|
||||
int Lyrics[2];
|
||||
int ReverseSelection[2];
|
||||
int DeselectAll[2];
|
||||
int AddSelected[2];
|
||||
int Clear[2];
|
||||
int Crop[2];
|
||||
int MvSongUp[2];
|
||||
@@ -102,7 +105,7 @@ struct ncmpcpp_config
|
||||
COLOR main_highlight_color;
|
||||
COLOR progressbar_color;
|
||||
COLOR statusbar_color;
|
||||
COLOR library_active_column_color;
|
||||
COLOR active_column_color;
|
||||
|
||||
bool colors_enabled;
|
||||
bool set_window_title;
|
||||
@@ -111,6 +114,7 @@ struct ncmpcpp_config
|
||||
bool autocenter_mode;
|
||||
bool repeat_one_mode;
|
||||
bool wrapped_search;
|
||||
bool space_selects;
|
||||
|
||||
int mpd_connection_timeout;
|
||||
int crossfade_time;
|
||||
|
||||
@@ -38,6 +38,7 @@ extern Window *wFooter;
|
||||
|
||||
extern SongList vPlaylist;
|
||||
extern SongList vSearched;
|
||||
extern SongList vLibSongs;
|
||||
extern ItemList vBrowser;
|
||||
|
||||
extern TagList vArtists;
|
||||
@@ -71,7 +72,6 @@ extern bool allow_statusbar_unblock;
|
||||
extern bool block_progressbar_update;
|
||||
extern bool block_statusbar_update;
|
||||
extern bool block_playlist_update;
|
||||
extern bool block_library_update;
|
||||
|
||||
extern bool redraw_me;
|
||||
|
||||
@@ -243,7 +243,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current_screen == csSearcher)
|
||||
else if (current_screen == csSearcher)
|
||||
{
|
||||
bool bold = 0;
|
||||
int i = search_engine_static_option;
|
||||
@@ -261,28 +261,29 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
|
||||
bold = 0;
|
||||
}
|
||||
}
|
||||
block_library_update = 0;
|
||||
else if (current_screen == csLibrary)
|
||||
{
|
||||
bool bold = 0;
|
||||
for (int i = 0; i < vLibSongs.size(); i++)
|
||||
{
|
||||
for (SongList::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++)
|
||||
{
|
||||
if ((*it)->GetHash() == vLibSongs[i]->GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mLibSongs->BoldOption(i+1, bold);
|
||||
bold = 0;
|
||||
}
|
||||
mLibSongs->Refresh();
|
||||
}
|
||||
}
|
||||
if (changed.Database)
|
||||
{
|
||||
GetDirectory(browsed_dir);
|
||||
if (!mLibArtists->Empty())
|
||||
{
|
||||
ShowMessage("Updating artists' list...");
|
||||
mLibArtists->Clear(0);
|
||||
vArtists.clear();
|
||||
Mpd->GetArtists(vArtists);
|
||||
sort(vArtists.begin(), vArtists.end(), CaseInsensitiveComparison);
|
||||
for (TagList::const_iterator it = vArtists.begin(); it != vArtists.end(); it++)
|
||||
mLibArtists->AddOption(*it);
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
mLibArtists->Hide();
|
||||
mLibArtists->Display();
|
||||
}
|
||||
ShowMessage("List updated!");
|
||||
}
|
||||
block_library_update = 0;
|
||||
}
|
||||
if (changed.PlayerState)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,25 @@ Window::Window(int startx, int starty, int width, int height, string title, COLO
|
||||
SetColor(itsColor);
|
||||
}
|
||||
|
||||
Window::Window(const Window &w)
|
||||
{
|
||||
itsWindow = dupwin(w.itsWindow);
|
||||
itsWinBorder = dupwin(w.itsWinBorder);
|
||||
itsStartX = w.itsStartX;
|
||||
itsStartY = w.itsStartY;
|
||||
itsWidth = w.itsWidth;
|
||||
itsHeight = w.itsHeight;
|
||||
BBEnabled = w.BBEnabled;
|
||||
AutoRefreshEnabled = w.AutoRefreshEnabled;
|
||||
itsTitle = w.itsTitle;
|
||||
itsColors = w.itsColors;
|
||||
itsColor = w.itsColor;
|
||||
itsBaseColor = w.itsBaseColor;
|
||||
itsBgColor = w.itsBgColor;
|
||||
itsBaseBgColor = w.itsBaseBgColor;
|
||||
itsBorder = w.itsBorder;
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
delwin(itsWindow);
|
||||
@@ -193,6 +212,7 @@ void Window::show_border() const
|
||||
attron(COLOR_PAIR(itsBaseColor));
|
||||
mvhline(itsStartY-1, itsStartX, 0, itsWidth);
|
||||
attron(A_BOLD);
|
||||
mvhline(itsStartY-2, itsStartX, 32, itsWidth); // clear title line
|
||||
mvaddstr(itsStartY-2, itsStartX, itsTitle.c_str());
|
||||
attroff(COLOR_PAIR(itsBorder) | A_BOLD);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ class Window
|
||||
{
|
||||
public:
|
||||
Window(int, int, int, int, string, COLOR, BORDER);
|
||||
Window(const Window &);
|
||||
virtual ~Window();
|
||||
virtual WINDOW *RawWin() { return itsWindow; }
|
||||
virtual void SetColor(COLOR, COLOR = clDefault);
|
||||
@@ -107,6 +108,7 @@ class Window
|
||||
virtual COLOR GetColor() const;
|
||||
virtual BORDER GetBorder() const;
|
||||
|
||||
virtual Window * Clone() { return new Window(*this); }
|
||||
virtual Window * EmptyClone();
|
||||
|
||||
virtual void Go(WHERE) { } // for Menu and Scrollpad class
|
||||
|
||||
Reference in New Issue
Block a user