actions: move item selection to its own action and bind it to insert

This commit is contained in:
Andrzej Rybczak
2015-05-09 21:37:40 +02:00
parent ccb468592d
commit 38b1064f1f
25 changed files with 260 additions and 290 deletions

1
NEWS
View File

@@ -20,6 +20,7 @@ ncmpcpp-0.7 (????-??-??)
* BOOST_LIB_SUFFIX configure variable is now empty by default. * BOOST_LIB_SUFFIX configure variable is now empty by default.
* Shuffle function now shuffles only selected range if selection in playlist is active. * Shuffle function now shuffles only selected range if selection in playlist is active.
* NCurses terminal sequence escaping is no longer used as it's not accurate enough. * NCurses terminal sequence escaping is no longer used as it's not accurate enough.
* Selecting items no longer depends on space mode and is bound by default to Insert key.
ncmpcpp-0.6.4 (2015-05-02) ncmpcpp-0.6.4 (2015-05-02)

View File

@@ -177,6 +177,9 @@
#def_key "end" #def_key "end"
# move_end # move_end
# #
#def_key "insert"
# select_item
#
#def_key "space" #def_key "space"
# press_space # press_space
# #
@@ -324,9 +327,6 @@
#def_key "Y" #def_key "Y"
# toggle_replay_gain_mode # toggle_replay_gain_mode
# #
#def_key "t"
# toggle_space_mode
#
#def_key "T" #def_key "T"
# toggle_add_mode # toggle_add_mode
# #

View File

@@ -343,10 +343,6 @@
## ##
#default_find_mode = wrapped #default_find_mode = wrapped
# #
## Available values: add, select.
##
#default_space_mode = add
#
#default_tag_editor_pattern = %n - %t #default_tag_editor_pattern = %n - %t
# #
#header_visibility = yes #header_visibility = yes

View File

@@ -206,9 +206,6 @@ Default tag type for leftmost column in media library.
.B default_find_mode = wrapped/normal .B default_find_mode = wrapped/normal
If set to "wrapped", going from last found position to next will take you to the first one (same goes for the first position and going to previous one), otherwise no actions will be performed. If set to "wrapped", going from last found position to next will take you to the first one (same goes for the first position and going to previous one), otherwise no actions will be performed.
.TP .TP
.B default_space_mode = select/add
If set to "select", space will select items instead of adding them to playlist (although selecting by space is default and the only one action for space in Playlist).
.TP
.B default_tag_editor_pattern = TEXT .B default_tag_editor_pattern = TEXT
Default pattern used by Tag editor's parser. Default pattern used by Tag editor's parser.
.TP .TP

View File

@@ -296,7 +296,7 @@ BaseAction *get(const std::string &name)
return result; return result;
} }
bool MouseEvent::canBeRun() const bool MouseEvent::canBeRun()
{ {
return Config.mouse_support; return Config.mouse_support;
} }
@@ -355,7 +355,7 @@ void ScrollDown::run()
listsChangeFinisher(); listsChangeFinisher();
} }
bool ScrollUpArtist::canBeRun() const bool ScrollUpArtist::canBeRun()
{ {
return proxySongList(myScreen); return proxySongList(myScreen);
} }
@@ -380,7 +380,7 @@ void ScrollUpArtist::run()
} }
} }
bool ScrollUpAlbum::canBeRun() const bool ScrollUpAlbum::canBeRun()
{ {
return proxySongList(myScreen); return proxySongList(myScreen);
} }
@@ -405,7 +405,7 @@ void ScrollUpAlbum::run()
} }
} }
bool ScrollDownArtist::canBeRun() const bool ScrollDownArtist::canBeRun()
{ {
return proxySongList(myScreen); return proxySongList(myScreen);
} }
@@ -430,7 +430,7 @@ void ScrollDownArtist::run()
} }
} }
bool ScrollDownAlbum::canBeRun() const bool ScrollDownAlbum::canBeRun()
{ {
return proxySongList(myScreen); return proxySongList(myScreen);
} }
@@ -501,7 +501,7 @@ void ToggleInterface::run()
Statusbar::printf("User interface: %1%", Config.design); Statusbar::printf("User interface: %1%", Config.design);
} }
bool JumpToParentDirectory::canBeRun() const bool JumpToParentDirectory::canBeRun()
{ {
return (myScreen == myBrowser) return (myScreen == myBrowser)
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
@@ -542,7 +542,20 @@ void PressSpace::run()
myScreen->spacePressed(); myScreen->spacePressed();
} }
bool PreviousColumn::canBeRun() const bool SelectItem::canBeRun()
{
hs = hasSongs(myScreen);
return hs != nullptr && hs->allowsSelection();
}
void SelectItem::run()
{
hs->selectCurrent();
myScreen->scroll(NC::Scroll::Down);
listsChangeFinisher();
}
bool PreviousColumn::canBeRun()
{ {
auto hc = hasColumns(myScreen); auto hc = hasColumns(myScreen);
return hc && hc->previousColumnAvailable(); return hc && hc->previousColumnAvailable();
@@ -553,7 +566,7 @@ void PreviousColumn::run()
hasColumns(myScreen)->previousColumn(); hasColumns(myScreen)->previousColumn();
} }
bool NextColumn::canBeRun() const bool NextColumn::canBeRun()
{ {
auto hc = hasColumns(myScreen); auto hc = hasColumns(myScreen);
return hc && hc->nextColumnAvailable(); return hc && hc->nextColumnAvailable();
@@ -564,7 +577,7 @@ void NextColumn::run()
hasColumns(myScreen)->nextColumn(); hasColumns(myScreen)->nextColumn();
} }
bool MasterScreen::canBeRun() const bool MasterScreen::canBeRun()
{ {
using Global::myLockedScreen; using Global::myLockedScreen;
using Global::myInactiveScreen; using Global::myInactiveScreen;
@@ -585,7 +598,7 @@ void MasterScreen::run()
drawHeader(); drawHeader();
} }
bool SlaveScreen::canBeRun() const bool SlaveScreen::canBeRun()
{ {
using Global::myLockedScreen; using Global::myLockedScreen;
using Global::myInactiveScreen; using Global::myInactiveScreen;
@@ -618,7 +631,7 @@ void VolumeDown::run()
Mpd.SetVolume(volume); Mpd.SetVolume(volume);
} }
bool DeletePlaylistItems::canBeRun() const bool DeletePlaylistItems::canBeRun()
{ {
return (myScreen == myPlaylist && !myPlaylist->main().empty()) return (myScreen == myPlaylist && !myPlaylist->main().empty())
|| (myScreen->isActiveWindow(myPlaylistEditor->Content) && !myPlaylistEditor->Content.empty()); || (myScreen->isActiveWindow(myPlaylistEditor->Content) && !myPlaylistEditor->Content.empty());
@@ -643,7 +656,7 @@ void DeletePlaylistItems::run()
} }
} }
bool DeleteBrowserItems::canBeRun() const bool DeleteBrowserItems::canBeRun()
{ {
auto check_if_deletion_allowed = []() { auto check_if_deletion_allowed = []() {
if (Config.allow_for_physical_item_deletion) if (Config.allow_for_physical_item_deletion)
@@ -716,7 +729,7 @@ void DeleteBrowserItems::run()
myBrowser->requestUpdate(); myBrowser->requestUpdate();
} }
bool DeleteStoredPlaylist::canBeRun() const bool DeleteStoredPlaylist::canBeRun()
{ {
return myScreen->isActiveWindow(myPlaylistEditor->Playlists); return myScreen->isActiveWindow(myPlaylistEditor->Playlists);
} }
@@ -830,7 +843,7 @@ void ExecuteCommand::run()
Statusbar::printf("No command named \"%1%\"", cmd_name); Statusbar::printf("No command named \"%1%\"", cmd_name);
} }
bool MoveSortOrderUp::canBeRun() const bool MoveSortOrderUp::canBeRun()
{ {
return myScreen == mySortPlaylistDialog; return myScreen == mySortPlaylistDialog;
} }
@@ -840,7 +853,7 @@ void MoveSortOrderUp::run()
mySortPlaylistDialog->moveSortOrderUp(); mySortPlaylistDialog->moveSortOrderUp();
} }
bool MoveSortOrderDown::canBeRun() const bool MoveSortOrderDown::canBeRun()
{ {
return myScreen == mySortPlaylistDialog; return myScreen == mySortPlaylistDialog;
} }
@@ -850,7 +863,7 @@ void MoveSortOrderDown::run()
mySortPlaylistDialog->moveSortOrderDown(); mySortPlaylistDialog->moveSortOrderDown();
} }
bool MoveSelectedItemsUp::canBeRun() const bool MoveSelectedItemsUp::canBeRun()
{ {
return ((myScreen == myPlaylist return ((myScreen == myPlaylist
&& !myPlaylist->main().empty()) && !myPlaylist->main().empty())
@@ -873,7 +886,7 @@ void MoveSelectedItemsUp::run()
} }
} }
bool MoveSelectedItemsDown::canBeRun() const bool MoveSelectedItemsDown::canBeRun()
{ {
return ((myScreen == myPlaylist return ((myScreen == myPlaylist
&& !myPlaylist->main().empty()) && !myPlaylist->main().empty())
@@ -896,7 +909,7 @@ void MoveSelectedItemsDown::run()
} }
} }
bool MoveSelectedItemsTo::canBeRun() const bool MoveSelectedItemsTo::canBeRun()
{ {
return myScreen == myPlaylist return myScreen == myPlaylist
|| myScreen->isActiveWindow(myPlaylistEditor->Content); || myScreen->isActiveWindow(myPlaylistEditor->Content);
@@ -918,7 +931,7 @@ void MoveSelectedItemsTo::run()
} }
} }
bool Add::canBeRun() const bool Add::canBeRun()
{ {
return myScreen != myPlaylistEditor return myScreen != myPlaylistEditor
|| !myPlaylistEditor->Playlists.empty(); || !myPlaylistEditor->Playlists.empty();
@@ -960,7 +973,7 @@ void Add::run()
} }
} }
bool SeekForward::canBeRun() const bool SeekForward::canBeRun()
{ {
return Status::State::player() != MPD::psStop && Status::State::totalTime() > 0; return Status::State::player() != MPD::psStop && Status::State::totalTime() > 0;
} }
@@ -970,7 +983,7 @@ void SeekForward::run()
seek(); seek();
} }
bool SeekBackward::canBeRun() const bool SeekBackward::canBeRun()
{ {
return Status::State::player() != MPD::psStop && Status::State::totalTime() > 0; return Status::State::player() != MPD::psStop && Status::State::totalTime() > 0;
} }
@@ -980,7 +993,7 @@ void SeekBackward::run()
seek(); seek();
} }
bool ToggleDisplayMode::canBeRun() const bool ToggleDisplayMode::canBeRun()
{ {
return myScreen == myPlaylist return myScreen == myPlaylist
|| myScreen == myBrowser || myScreen == myBrowser
@@ -1072,7 +1085,7 @@ void ToggleDisplayMode::run()
} }
} }
bool ToggleSeparatorsBetweenAlbums::canBeRun() const bool ToggleSeparatorsBetweenAlbums::canBeRun()
{ {
return true; return true;
} }
@@ -1086,7 +1099,7 @@ void ToggleSeparatorsBetweenAlbums::run()
} }
#ifndef HAVE_CURL_CURL_H #ifndef HAVE_CURL_CURL_H
bool ToggleLyricsFetcher::canBeRun() const bool ToggleLyricsFetcher::canBeRun()
{ {
return false; return false;
} }
@@ -1100,7 +1113,7 @@ void ToggleLyricsFetcher::run()
} }
#ifndef HAVE_CURL_CURL_H #ifndef HAVE_CURL_CURL_H
bool ToggleFetchingLyricsInBackground::canBeRun() const bool ToggleFetchingLyricsInBackground::canBeRun()
{ {
return false; return false;
} }
@@ -1142,7 +1155,7 @@ void UpdateDatabase::run()
Mpd.UpdateDirectory("/"); Mpd.UpdateDirectory("/");
} }
bool JumpToPlayingSong::canBeRun() const bool JumpToPlayingSong::canBeRun()
{ {
return myScreen == myPlaylist return myScreen == myPlaylist
|| myScreen == myBrowser || myScreen == myBrowser
@@ -1186,7 +1199,7 @@ void ToggleRandom::run()
Mpd.SetRandom(!Status::State::random()); Mpd.SetRandom(!Status::State::random());
} }
bool StartSearching::canBeRun() const bool StartSearching::canBeRun()
{ {
return myScreen == mySearcher && !mySearcher->main()[0].isInactive(); return myScreen == mySearcher && !mySearcher->main()[0].isInactive();
} }
@@ -1200,7 +1213,7 @@ void StartSearching::run()
mySearcher->enterPressed(); mySearcher->enterPressed();
} }
bool SaveTagChanges::canBeRun() const bool SaveTagChanges::canBeRun()
{ {
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
return myScreen == myTinyTagEditor return myScreen == myTinyTagEditor
@@ -1268,7 +1281,7 @@ void SetVolume::run()
Statusbar::printf("Volume set to %1%%%", volume); Statusbar::printf("Volume set to %1%%%", volume);
} }
bool EditSong::canBeRun() const bool EditSong::canBeRun()
{ {
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
return currentSong(myScreen) return currentSong(myScreen)
@@ -1287,7 +1300,7 @@ void EditSong::run()
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
} }
bool EditLibraryTag::canBeRun() const bool EditLibraryTag::canBeRun()
{ {
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
return myScreen->isActiveWindow(myLibrary->Tags) return myScreen->isActiveWindow(myLibrary->Tags)
@@ -1346,7 +1359,7 @@ void EditLibraryTag::run()
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
} }
bool EditLibraryAlbum::canBeRun() const bool EditLibraryAlbum::canBeRun()
{ {
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
return myScreen->isActiveWindow(myLibrary->Albums) return myScreen->isActiveWindow(myLibrary->Albums)
@@ -1402,7 +1415,7 @@ void EditLibraryAlbum::run()
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
} }
bool EditDirectoryName::canBeRun() const bool EditDirectoryName::canBeRun()
{ {
return ((myScreen == myBrowser return ((myScreen == myBrowser
&& !myBrowser->main().empty() && !myBrowser->main().empty()
@@ -1474,7 +1487,7 @@ void EditDirectoryName::run()
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
} }
bool EditPlaylistName::canBeRun() const bool EditPlaylistName::canBeRun()
{ {
return (myScreen->isActiveWindow(myPlaylistEditor->Playlists) return (myScreen->isActiveWindow(myPlaylistEditor->Playlists)
&& !myPlaylistEditor->Playlists.empty()) && !myPlaylistEditor->Playlists.empty())
@@ -1504,7 +1517,7 @@ void EditPlaylistName::run()
} }
} }
bool EditLyrics::canBeRun() const bool EditLyrics::canBeRun()
{ {
return myScreen == myLyrics; return myScreen == myLyrics;
} }
@@ -1514,7 +1527,7 @@ void EditLyrics::run()
myLyrics->Edit(); myLyrics->Edit();
} }
bool JumpToBrowser::canBeRun() const bool JumpToBrowser::canBeRun()
{ {
return currentSong(myScreen); return currentSong(myScreen);
} }
@@ -1525,7 +1538,7 @@ void JumpToBrowser::run()
myBrowser->locateSong(*s); myBrowser->locateSong(*s);
} }
bool JumpToMediaLibrary::canBeRun() const bool JumpToMediaLibrary::canBeRun()
{ {
return currentSong(myScreen); return currentSong(myScreen);
} }
@@ -1536,7 +1549,7 @@ void JumpToMediaLibrary::run()
myLibrary->LocateSong(*s); myLibrary->LocateSong(*s);
} }
bool JumpToPlaylistEditor::canBeRun() const bool JumpToPlaylistEditor::canBeRun()
{ {
return myScreen == myBrowser return myScreen == myBrowser
&& myBrowser->main().current()->value().type() == MPD::Item::Type::Playlist; && myBrowser->main().current()->value().type() == MPD::Item::Type::Playlist;
@@ -1581,7 +1594,7 @@ void ToggleScreenLock::run()
} }
} }
bool JumpToTagEditor::canBeRun() const bool JumpToTagEditor::canBeRun()
{ {
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
return currentSong(myScreen) return currentSong(myScreen)
@@ -1599,7 +1612,7 @@ void JumpToTagEditor::run()
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
} }
bool JumpToPositionInSong::canBeRun() const bool JumpToPositionInSong::canBeRun()
{ {
return Status::State::player() != MPD::psStop && Status::State::totalTime() > 0; return Status::State::player() != MPD::psStop && Status::State::totalTime() > 0;
} }
@@ -1642,7 +1655,7 @@ void JumpToPositionInSong::run()
Statusbar::print("Invalid format ([m]:[ss], [s]s, [%]%, [%] accepted)"); Statusbar::print("Invalid format ([m]:[ss], [s]s, [%]%, [%] accepted)");
} }
bool ReverseSelection::canBeRun() const bool ReverseSelection::canBeRun()
{ {
auto w = hasSongs(myScreen); auto w = hasSongs(myScreen);
return w && w->allowsSelection(); return w && w->allowsSelection();
@@ -1655,7 +1668,7 @@ void ReverseSelection::run()
Statusbar::print("Selection reversed"); Statusbar::print("Selection reversed");
} }
bool RemoveSelection::canBeRun() const bool RemoveSelection::canBeRun()
{ {
return proxySongList(myScreen); return proxySongList(myScreen);
} }
@@ -1668,7 +1681,7 @@ void RemoveSelection::run()
Statusbar::print("Selection removed"); Statusbar::print("Selection removed");
} }
bool SelectAlbum::canBeRun() const bool SelectAlbum::canBeRun()
{ {
auto w = hasSongs(myScreen); auto w = hasSongs(myScreen);
return w && w->allowsSelection() && w->proxySongList(); return w && w->allowsSelection() && w->proxySongList();
@@ -1709,7 +1722,7 @@ void SelectAlbum::run()
} }
} }
bool AddSelectedItems::canBeRun() const bool AddSelectedItems::canBeRun()
{ {
return myScreen != mySelectedItemsAdder; return myScreen != mySelectedItemsAdder;
} }
@@ -1733,7 +1746,7 @@ void CropMainPlaylist::run()
Statusbar::print("Playlist cropped"); Statusbar::print("Playlist cropped");
} }
bool CropPlaylist::canBeRun() const bool CropPlaylist::canBeRun()
{ {
return myScreen == myPlaylistEditor; return myScreen == myPlaylistEditor;
} }
@@ -1763,7 +1776,7 @@ void ClearMainPlaylist::run()
myPlaylist->main().reset(); myPlaylist->main().reset();
} }
bool ClearPlaylist::canBeRun() const bool ClearPlaylist::canBeRun()
{ {
return myScreen == myPlaylistEditor; return myScreen == myPlaylistEditor;
} }
@@ -1779,7 +1792,7 @@ void ClearPlaylist::run()
Statusbar::printf("Playlist \"%1%\" cleared", playlist); Statusbar::printf("Playlist \"%1%\" cleared", playlist);
} }
bool SortPlaylist::canBeRun() const bool SortPlaylist::canBeRun()
{ {
return myScreen == myPlaylist; return myScreen == myPlaylist;
} }
@@ -1789,7 +1802,7 @@ void SortPlaylist::run()
mySortPlaylistDialog->switchTo(); mySortPlaylistDialog->switchTo();
} }
bool ReversePlaylist::canBeRun() const bool ReversePlaylist::canBeRun()
{ {
return myScreen == myPlaylist; return myScreen == myPlaylist;
} }
@@ -1799,7 +1812,7 @@ void ReversePlaylist::run()
myPlaylist->Reverse(); myPlaylist->Reverse();
} }
bool Find::canBeRun() const bool Find::canBeRun()
{ {
return myScreen == myHelp return myScreen == myHelp
|| myScreen == myLyrics || myScreen == myLyrics
@@ -1830,7 +1843,7 @@ void Find::run()
s->main().flush(); s->main().flush();
} }
bool FindItemBackward::canBeRun() const bool FindItemBackward::canBeRun()
{ {
auto w = dynamic_cast<Searchable *>(myScreen); auto w = dynamic_cast<Searchable *>(myScreen);
return w && w->allowsSearching(); return w && w->allowsSearching();
@@ -1842,7 +1855,7 @@ void FindItemForward::run()
listsChangeFinisher(); listsChangeFinisher();
} }
bool FindItemForward::canBeRun() const bool FindItemForward::canBeRun()
{ {
auto w = dynamic_cast<Searchable *>(myScreen); auto w = dynamic_cast<Searchable *>(myScreen);
return w && w->allowsSearching(); return w && w->allowsSearching();
@@ -1854,7 +1867,7 @@ void FindItemBackward::run()
listsChangeFinisher(); listsChangeFinisher();
} }
bool NextFoundItem::canBeRun() const bool NextFoundItem::canBeRun()
{ {
return dynamic_cast<Searchable *>(myScreen); return dynamic_cast<Searchable *>(myScreen);
} }
@@ -1867,7 +1880,7 @@ void NextFoundItem::run()
listsChangeFinisher(); listsChangeFinisher();
} }
bool PreviousFoundItem::canBeRun() const bool PreviousFoundItem::canBeRun()
{ {
return dynamic_cast<Searchable *>(myScreen); return dynamic_cast<Searchable *>(myScreen);
} }
@@ -1921,12 +1934,6 @@ void ToggleReplayGainMode::run()
Statusbar::printf("Replay gain mode: %1%", Mpd.GetReplayGainMode()); Statusbar::printf("Replay gain mode: %1%", Mpd.GetReplayGainMode());
} }
void ToggleSpaceMode::run()
{
Config.space_selects = !Config.space_selects;
Statusbar::printf("Space mode: %1% item", Config.space_selects ? "select" : "add");
}
void ToggleAddMode::run() void ToggleAddMode::run()
{ {
std::string mode_desc; std::string mode_desc;
@@ -2003,7 +2010,7 @@ void AddRandomItems::run()
} }
} }
bool ToggleBrowserSortMode::canBeRun() const bool ToggleBrowserSortMode::canBeRun()
{ {
return myScreen == myBrowser; return myScreen == myBrowser;
} }
@@ -2037,7 +2044,7 @@ void ToggleBrowserSortMode::run()
} }
} }
bool ToggleLibraryTagType::canBeRun() const bool ToggleLibraryTagType::canBeRun()
{ {
return (myScreen->isActiveWindow(myLibrary->Tags)) return (myScreen->isActiveWindow(myLibrary->Tags))
|| (myLibrary->Columns() == 2 && myScreen->isActiveWindow(myLibrary->Albums)); || (myLibrary->Columns() == 2 && myScreen->isActiveWindow(myLibrary->Albums));
@@ -2088,7 +2095,7 @@ void ToggleLibraryTagType::run()
} }
} }
bool ToggleMediaLibrarySortMode::canBeRun() const bool ToggleMediaLibrarySortMode::canBeRun()
{ {
return myScreen == myLibrary; return myScreen == myLibrary;
} }
@@ -2098,7 +2105,7 @@ void ToggleMediaLibrarySortMode::run()
myLibrary->toggleSortMode(); myLibrary->toggleSortMode();
} }
bool RefetchLyrics::canBeRun() const bool RefetchLyrics::canBeRun()
{ {
# ifdef HAVE_CURL_CURL_H # ifdef HAVE_CURL_CURL_H
return myScreen == myLyrics; return myScreen == myLyrics;
@@ -2114,7 +2121,7 @@ void RefetchLyrics::run()
# endif // HAVE_CURL_CURL_H # endif // HAVE_CURL_CURL_H
} }
bool SetSelectedItemsPriority::canBeRun() const bool SetSelectedItemsPriority::canBeRun()
{ {
if (Mpd.Version() < 17) if (Mpd.Version() < 17)
{ {
@@ -2138,7 +2145,7 @@ void SetSelectedItemsPriority::run()
myPlaylist->SetSelectedItemsPriority(prio); myPlaylist->SetSelectedItemsPriority(prio);
} }
bool SetVisualizerSampleMultiplier::canBeRun() const bool SetVisualizerSampleMultiplier::canBeRun()
{ {
# ifdef ENABLE_VISUALIZER # ifdef ENABLE_VISUALIZER
return myScreen == myVisualizer; return myScreen == myVisualizer;
@@ -2169,7 +2176,7 @@ void ShowSongInfo::run()
mySongInfo->switchTo(); mySongInfo->switchTo();
} }
bool ShowArtistInfo::canBeRun() const bool ShowArtistInfo::canBeRun()
{ {
#ifdef HAVE_CURL_CURL_H #ifdef HAVE_CURL_CURL_H
return myScreen == myLastfm return myScreen == myLastfm
@@ -2259,7 +2266,7 @@ void PreviousScreen::run()
} }
} }
bool ShowHelp::canBeRun() const bool ShowHelp::canBeRun()
{ {
return myScreen != myHelp return myScreen != myHelp
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
@@ -2273,7 +2280,7 @@ void ShowHelp::run()
myHelp->switchTo(); myHelp->switchTo();
} }
bool ShowPlaylist::canBeRun() const bool ShowPlaylist::canBeRun()
{ {
return myScreen != myPlaylist return myScreen != myPlaylist
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
@@ -2287,7 +2294,7 @@ void ShowPlaylist::run()
myPlaylist->switchTo(); myPlaylist->switchTo();
} }
bool ShowBrowser::canBeRun() const bool ShowBrowser::canBeRun()
{ {
return myScreen != myBrowser return myScreen != myBrowser
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
@@ -2301,7 +2308,7 @@ void ShowBrowser::run()
myBrowser->switchTo(); myBrowser->switchTo();
} }
bool ChangeBrowseMode::canBeRun() const bool ChangeBrowseMode::canBeRun()
{ {
return myScreen == myBrowser; return myScreen == myBrowser;
} }
@@ -2311,7 +2318,7 @@ void ChangeBrowseMode::run()
myBrowser->changeBrowseMode(); myBrowser->changeBrowseMode();
} }
bool ShowSearchEngine::canBeRun() const bool ShowSearchEngine::canBeRun()
{ {
return myScreen != mySearcher return myScreen != mySearcher
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
@@ -2325,7 +2332,7 @@ void ShowSearchEngine::run()
mySearcher->switchTo(); mySearcher->switchTo();
} }
bool ResetSearchEngine::canBeRun() const bool ResetSearchEngine::canBeRun()
{ {
return myScreen == mySearcher; return myScreen == mySearcher;
} }
@@ -2335,7 +2342,7 @@ void ResetSearchEngine::run()
mySearcher->reset(); mySearcher->reset();
} }
bool ShowMediaLibrary::canBeRun() const bool ShowMediaLibrary::canBeRun()
{ {
return myScreen != myLibrary return myScreen != myLibrary
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
@@ -2349,7 +2356,7 @@ void ShowMediaLibrary::run()
myLibrary->switchTo(); myLibrary->switchTo();
} }
bool ToggleMediaLibraryColumnsMode::canBeRun() const bool ToggleMediaLibraryColumnsMode::canBeRun()
{ {
return myScreen == myLibrary; return myScreen == myLibrary;
} }
@@ -2360,7 +2367,7 @@ void ToggleMediaLibraryColumnsMode::run()
myLibrary->refresh(); myLibrary->refresh();
} }
bool ShowPlaylistEditor::canBeRun() const bool ShowPlaylistEditor::canBeRun()
{ {
return myScreen != myPlaylistEditor return myScreen != myPlaylistEditor
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
@@ -2374,7 +2381,7 @@ void ShowPlaylistEditor::run()
myPlaylistEditor->switchTo(); myPlaylistEditor->switchTo();
} }
bool ShowTagEditor::canBeRun() const bool ShowTagEditor::canBeRun()
{ {
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
return myScreen != myTagEditor return myScreen != myTagEditor
@@ -2392,7 +2399,7 @@ void ShowTagEditor::run()
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
} }
bool ShowOutputs::canBeRun() const bool ShowOutputs::canBeRun()
{ {
# ifdef ENABLE_OUTPUTS # ifdef ENABLE_OUTPUTS
return myScreen != myOutputs return myScreen != myOutputs
@@ -2412,7 +2419,7 @@ void ShowOutputs::run()
# endif // ENABLE_OUTPUTS # endif // ENABLE_OUTPUTS
} }
bool ShowVisualizer::canBeRun() const bool ShowVisualizer::canBeRun()
{ {
# ifdef ENABLE_VISUALIZER # ifdef ENABLE_VISUALIZER
return myScreen != myVisualizer return myScreen != myVisualizer
@@ -2432,7 +2439,7 @@ void ShowVisualizer::run()
# endif // ENABLE_VISUALIZER # endif // ENABLE_VISUALIZER
} }
bool ShowClock::canBeRun() const bool ShowClock::canBeRun()
{ {
# ifdef ENABLE_CLOCK # ifdef ENABLE_CLOCK
return myScreen != myClock return myScreen != myClock
@@ -2453,7 +2460,7 @@ void ShowClock::run()
} }
#ifdef HAVE_TAGLIB_H #ifdef HAVE_TAGLIB_H
bool ShowServerInfo::canBeRun() const bool ShowServerInfo::canBeRun()
{ {
return myScreen != myTinyTagEditor; return myScreen != myTinyTagEditor;
} }
@@ -2489,6 +2496,7 @@ void populateActions()
insert_action(new Actions::JumpToParentDirectory()); insert_action(new Actions::JumpToParentDirectory());
insert_action(new Actions::PressEnter()); insert_action(new Actions::PressEnter());
insert_action(new Actions::PressSpace()); insert_action(new Actions::PressSpace());
insert_action(new Actions::SelectItem());
insert_action(new Actions::PreviousColumn()); insert_action(new Actions::PreviousColumn());
insert_action(new Actions::NextColumn()); insert_action(new Actions::NextColumn());
insert_action(new Actions::MasterScreen()); insert_action(new Actions::MasterScreen());
@@ -2559,7 +2567,6 @@ void populateActions()
insert_action(new Actions::PreviousFoundItem()); insert_action(new Actions::PreviousFoundItem());
insert_action(new Actions::ToggleFindMode()); insert_action(new Actions::ToggleFindMode());
insert_action(new Actions::ToggleReplayGainMode()); insert_action(new Actions::ToggleReplayGainMode());
insert_action(new Actions::ToggleSpaceMode());
insert_action(new Actions::ToggleAddMode()); insert_action(new Actions::ToggleAddMode());
insert_action(new Actions::ToggleMouse()); insert_action(new Actions::ToggleMouse());
insert_action(new Actions::ToggleBitrateVisibility()); insert_action(new Actions::ToggleBitrateVisibility());

View File

@@ -24,6 +24,7 @@
#include <boost/format.hpp> #include <boost/format.hpp>
#include <map> #include <map>
#include <string> #include <string>
#include "interfaces.h"
#include "window.h" #include "window.h"
namespace Actions { namespace Actions {
@@ -33,7 +34,7 @@ enum class Type
MacroUtility = 0, MacroUtility = 0,
Dummy, MouseEvent, ScrollUp, ScrollDown, ScrollUpArtist, ScrollUpAlbum, Dummy, MouseEvent, ScrollUp, ScrollDown, ScrollUpArtist, ScrollUpAlbum,
ScrollDownArtist, ScrollDownAlbum, PageUp, PageDown, MoveHome, MoveEnd, ScrollDownArtist, ScrollDownAlbum, PageUp, PageDown, MoveHome, MoveEnd,
ToggleInterface, JumpToParentDirectory, PressEnter, PressSpace, PreviousColumn, ToggleInterface, JumpToParentDirectory, PressEnter, PressSpace, SelectItem, PreviousColumn,
NextColumn, MasterScreen, SlaveScreen, VolumeUp, VolumeDown, DeletePlaylistItems, NextColumn, MasterScreen, SlaveScreen, VolumeUp, VolumeDown, DeletePlaylistItems,
DeleteStoredPlaylist, DeleteBrowserItems, ReplaySong, Previous, Next, Pause, DeleteStoredPlaylist, DeleteBrowserItems, ReplaySong, Previous, Next, Pause,
Stop, ExecuteCommand, SavePlaylist, MoveSortOrderUp, MoveSortOrderDown, Stop, ExecuteCommand, SavePlaylist, MoveSortOrderUp, MoveSortOrderDown,
@@ -49,7 +50,7 @@ enum class Type
CropMainPlaylist, CropPlaylist, ClearMainPlaylist, ClearPlaylist, SortPlaylist, CropMainPlaylist, CropPlaylist, ClearMainPlaylist, ClearPlaylist, SortPlaylist,
ReversePlaylist, Find, FindItemForward, FindItemBackward, ReversePlaylist, Find, FindItemForward, FindItemBackward,
NextFoundItem, PreviousFoundItem, ToggleFindMode, ToggleReplayGainMode, NextFoundItem, PreviousFoundItem, ToggleFindMode, ToggleReplayGainMode,
ToggleSpaceMode, ToggleAddMode, ToggleMouse, ToggleBitrateVisibility, ToggleAddMode, ToggleMouse, ToggleBitrateVisibility,
AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType, AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType,
ToggleMediaLibrarySortMode, RefetchLyrics, ToggleMediaLibrarySortMode, RefetchLyrics,
SetSelectedItemsPriority, SetVisualizerSampleMultiplier, SetSelectedItemsPriority, SetVisualizerSampleMultiplier,
@@ -89,7 +90,7 @@ struct BaseAction
const char *name() const { return m_name; } const char *name() const { return m_name; }
Type type() const { return m_type; } Type type() const { return m_type; }
virtual bool canBeRun() const { return true; } virtual bool canBeRun() { return true; }
bool execute() bool execute()
{ {
@@ -129,7 +130,7 @@ struct MouseEvent : public BaseAction
} }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
private: private:
@@ -158,7 +159,7 @@ struct ScrollUpArtist : public BaseAction
ScrollUpArtist() : BaseAction(Type::ScrollUpArtist, "scroll_up_artist") { } ScrollUpArtist() : BaseAction(Type::ScrollUpArtist, "scroll_up_artist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -167,7 +168,7 @@ struct ScrollUpAlbum : public BaseAction
ScrollUpAlbum() : BaseAction(Type::ScrollUpAlbum, "scroll_up_album") { } ScrollUpAlbum() : BaseAction(Type::ScrollUpAlbum, "scroll_up_album") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -176,7 +177,7 @@ struct ScrollDownArtist : public BaseAction
ScrollDownArtist() : BaseAction(Type::ScrollDownArtist, "scroll_down_artist") { } ScrollDownArtist() : BaseAction(Type::ScrollDownArtist, "scroll_down_artist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -185,7 +186,7 @@ struct ScrollDownAlbum : public BaseAction
ScrollDownAlbum() : BaseAction(Type::ScrollDownAlbum, "scroll_down_album") { } ScrollDownAlbum() : BaseAction(Type::ScrollDownAlbum, "scroll_down_album") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -234,7 +235,7 @@ struct JumpToParentDirectory : public BaseAction
JumpToParentDirectory() : BaseAction(Type::JumpToParentDirectory, "jump_to_parent_directory") { } JumpToParentDirectory() : BaseAction(Type::JumpToParentDirectory, "jump_to_parent_directory") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -254,12 +255,24 @@ protected:
virtual void run(); virtual void run();
}; };
struct SelectItem : public BaseAction
{
SelectItem() : BaseAction(Type::SelectItem, "select_item") { }
protected:
virtual bool canBeRun();
virtual void run();
private:
HasSongs *hs;
};
struct PreviousColumn : public BaseAction struct PreviousColumn : public BaseAction
{ {
PreviousColumn() : BaseAction(Type::PreviousColumn, "previous_column") { } PreviousColumn() : BaseAction(Type::PreviousColumn, "previous_column") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -268,7 +281,7 @@ struct NextColumn : public BaseAction
NextColumn() : BaseAction(Type::NextColumn, "next_column") { } NextColumn() : BaseAction(Type::NextColumn, "next_column") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -277,7 +290,7 @@ struct MasterScreen : public BaseAction
MasterScreen() : BaseAction(Type::MasterScreen, "master_screen") { } MasterScreen() : BaseAction(Type::MasterScreen, "master_screen") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -286,7 +299,7 @@ struct SlaveScreen : public BaseAction
SlaveScreen() : BaseAction(Type::SlaveScreen, "slave_screen") { } SlaveScreen() : BaseAction(Type::SlaveScreen, "slave_screen") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -311,7 +324,7 @@ struct DeletePlaylistItems : public BaseAction
DeletePlaylistItems() : BaseAction(Type::DeletePlaylistItems, "delete_playlist_items") { } DeletePlaylistItems() : BaseAction(Type::DeletePlaylistItems, "delete_playlist_items") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -320,7 +333,7 @@ struct DeleteStoredPlaylist : public BaseAction
DeleteStoredPlaylist() : BaseAction(Type::DeleteStoredPlaylist, "delete_stored_playlist") { } DeleteStoredPlaylist() : BaseAction(Type::DeleteStoredPlaylist, "delete_stored_playlist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -329,7 +342,7 @@ struct DeleteBrowserItems : public BaseAction
DeleteBrowserItems() : BaseAction(Type::DeleteBrowserItems, "delete_browser_items") { } DeleteBrowserItems() : BaseAction(Type::DeleteBrowserItems, "delete_browser_items") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -394,7 +407,7 @@ struct MoveSortOrderUp : public BaseAction
MoveSortOrderUp() : BaseAction(Type::MoveSortOrderUp, "move_sort_order_up") { } MoveSortOrderUp() : BaseAction(Type::MoveSortOrderUp, "move_sort_order_up") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -403,7 +416,7 @@ struct MoveSortOrderDown : public BaseAction
MoveSortOrderDown() : BaseAction(Type::MoveSortOrderDown, "move_sort_order_down") { } MoveSortOrderDown() : BaseAction(Type::MoveSortOrderDown, "move_sort_order_down") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -412,7 +425,7 @@ struct MoveSelectedItemsUp : public BaseAction
MoveSelectedItemsUp() : BaseAction(Type::MoveSelectedItemsUp, "move_selected_items_up") { } MoveSelectedItemsUp() : BaseAction(Type::MoveSelectedItemsUp, "move_selected_items_up") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -421,7 +434,7 @@ struct MoveSelectedItemsDown : public BaseAction
MoveSelectedItemsDown() : BaseAction(Type::MoveSelectedItemsDown, "move_selected_items_down") { } MoveSelectedItemsDown() : BaseAction(Type::MoveSelectedItemsDown, "move_selected_items_down") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -430,7 +443,7 @@ struct MoveSelectedItemsTo : public BaseAction
MoveSelectedItemsTo() : BaseAction(Type::MoveSelectedItemsTo, "move_selected_items_to") { } MoveSelectedItemsTo() : BaseAction(Type::MoveSelectedItemsTo, "move_selected_items_to") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -439,7 +452,7 @@ struct Add : public BaseAction
Add() : BaseAction(Type::Add, "add") { } Add() : BaseAction(Type::Add, "add") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -448,7 +461,7 @@ struct SeekForward : public BaseAction
SeekForward() : BaseAction(Type::SeekForward, "seek_forward") { } SeekForward() : BaseAction(Type::SeekForward, "seek_forward") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -457,7 +470,7 @@ struct SeekBackward : public BaseAction
SeekBackward() : BaseAction(Type::SeekBackward, "seek_backward") { } SeekBackward() : BaseAction(Type::SeekBackward, "seek_backward") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -466,7 +479,7 @@ struct ToggleDisplayMode : public BaseAction
ToggleDisplayMode() : BaseAction(Type::ToggleDisplayMode, "toggle_display_mode") { } ToggleDisplayMode() : BaseAction(Type::ToggleDisplayMode, "toggle_display_mode") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -476,7 +489,7 @@ struct ToggleSeparatorsBetweenAlbums : public BaseAction
: BaseAction(Type::ToggleSeparatorsBetweenAlbums, "toggle_separators_between_albums") { } : BaseAction(Type::ToggleSeparatorsBetweenAlbums, "toggle_separators_between_albums") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -486,7 +499,7 @@ struct ToggleLyricsFetcher : public BaseAction
protected: protected:
# ifndef HAVE_CURL_CURL_H # ifndef HAVE_CURL_CURL_H
virtual bool canBeRun() const; virtual bool canBeRun();
# endif // NOT HAVE_CURL_CURL_H # endif // NOT HAVE_CURL_CURL_H
virtual void run(); virtual void run();
}; };
@@ -498,7 +511,7 @@ struct ToggleFetchingLyricsInBackground : public BaseAction
protected: protected:
# ifndef HAVE_CURL_CURL_H # ifndef HAVE_CURL_CURL_H
virtual bool canBeRun() const; virtual bool canBeRun();
# endif // NOT HAVE_CURL_CURL_H # endif // NOT HAVE_CURL_CURL_H
virtual void run(); virtual void run();
}; };
@@ -525,7 +538,7 @@ struct JumpToPlayingSong : public BaseAction
JumpToPlayingSong() : BaseAction(Type::JumpToPlayingSong, "jump_to_playing_song") { } JumpToPlayingSong() : BaseAction(Type::JumpToPlayingSong, "jump_to_playing_song") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -558,7 +571,7 @@ struct StartSearching : public BaseAction
StartSearching() : BaseAction(Type::StartSearching, "start_searching") { } StartSearching() : BaseAction(Type::StartSearching, "start_searching") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -567,7 +580,7 @@ struct SaveTagChanges : public BaseAction
SaveTagChanges() : BaseAction(Type::SaveTagChanges, "save_tag_changes") { } SaveTagChanges() : BaseAction(Type::SaveTagChanges, "save_tag_changes") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -616,7 +629,7 @@ struct EditSong : public BaseAction
EditSong() : BaseAction(Type::EditSong, "edit_song") { } EditSong() : BaseAction(Type::EditSong, "edit_song") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -625,7 +638,7 @@ struct EditLibraryTag : public BaseAction
EditLibraryTag() : BaseAction(Type::EditLibraryTag, "edit_library_tag") { } EditLibraryTag() : BaseAction(Type::EditLibraryTag, "edit_library_tag") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -634,7 +647,7 @@ struct EditLibraryAlbum : public BaseAction
EditLibraryAlbum() : BaseAction(Type::EditLibraryAlbum, "edit_library_album") { } EditLibraryAlbum() : BaseAction(Type::EditLibraryAlbum, "edit_library_album") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -643,7 +656,7 @@ struct EditDirectoryName : public BaseAction
EditDirectoryName() : BaseAction(Type::EditDirectoryName, "edit_directory_name") { } EditDirectoryName() : BaseAction(Type::EditDirectoryName, "edit_directory_name") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -652,7 +665,7 @@ struct EditPlaylistName : public BaseAction
EditPlaylistName() : BaseAction(Type::EditPlaylistName, "edit_playlist_name") { } EditPlaylistName() : BaseAction(Type::EditPlaylistName, "edit_playlist_name") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -661,7 +674,7 @@ struct EditLyrics : public BaseAction
EditLyrics() : BaseAction(Type::EditLyrics, "edit_lyrics") { } EditLyrics() : BaseAction(Type::EditLyrics, "edit_lyrics") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -670,7 +683,7 @@ struct JumpToBrowser : public BaseAction
JumpToBrowser() : BaseAction(Type::JumpToBrowser, "jump_to_browser") { } JumpToBrowser() : BaseAction(Type::JumpToBrowser, "jump_to_browser") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -679,7 +692,7 @@ struct JumpToMediaLibrary : public BaseAction
JumpToMediaLibrary() : BaseAction(Type::JumpToMediaLibrary, "jump_to_media_library") { } JumpToMediaLibrary() : BaseAction(Type::JumpToMediaLibrary, "jump_to_media_library") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -688,7 +701,7 @@ struct JumpToPlaylistEditor : public BaseAction
JumpToPlaylistEditor() : BaseAction(Type::JumpToPlaylistEditor, "jump_to_playlist_editor") { } JumpToPlaylistEditor() : BaseAction(Type::JumpToPlaylistEditor, "jump_to_playlist_editor") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -705,7 +718,7 @@ struct JumpToTagEditor : public BaseAction
JumpToTagEditor() : BaseAction(Type::JumpToTagEditor, "jump_to_tag_editor") { } JumpToTagEditor() : BaseAction(Type::JumpToTagEditor, "jump_to_tag_editor") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -714,7 +727,7 @@ struct JumpToPositionInSong : public BaseAction
JumpToPositionInSong() : BaseAction(Type::JumpToPositionInSong, "jump_to_position_in_song") { } JumpToPositionInSong() : BaseAction(Type::JumpToPositionInSong, "jump_to_position_in_song") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -723,7 +736,7 @@ struct ReverseSelection : public BaseAction
ReverseSelection() : BaseAction(Type::ReverseSelection, "reverse_selection") { } ReverseSelection() : BaseAction(Type::ReverseSelection, "reverse_selection") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -732,7 +745,7 @@ struct RemoveSelection : public BaseAction
RemoveSelection() : BaseAction(Type::RemoveSelection, "remove_selection") { } RemoveSelection() : BaseAction(Type::RemoveSelection, "remove_selection") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -741,7 +754,7 @@ struct SelectAlbum : public BaseAction
SelectAlbum() : BaseAction(Type::SelectAlbum, "select_album") { } SelectAlbum() : BaseAction(Type::SelectAlbum, "select_album") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -750,7 +763,7 @@ struct AddSelectedItems : public BaseAction
AddSelectedItems() : BaseAction(Type::AddSelectedItems, "add_selected_items") { } AddSelectedItems() : BaseAction(Type::AddSelectedItems, "add_selected_items") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -767,7 +780,7 @@ struct CropPlaylist : public BaseAction
CropPlaylist() : BaseAction(Type::CropPlaylist, "crop_playlist") { } CropPlaylist() : BaseAction(Type::CropPlaylist, "crop_playlist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -784,7 +797,7 @@ struct ClearPlaylist : public BaseAction
ClearPlaylist() : BaseAction(Type::ClearPlaylist, "clear_playlist") { } ClearPlaylist() : BaseAction(Type::ClearPlaylist, "clear_playlist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -793,7 +806,7 @@ struct SortPlaylist : public BaseAction
SortPlaylist() : BaseAction(Type::SortPlaylist, "sort_playlist") { } SortPlaylist() : BaseAction(Type::SortPlaylist, "sort_playlist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -802,7 +815,7 @@ struct ReversePlaylist : public BaseAction
ReversePlaylist() : BaseAction(Type::ReversePlaylist, "reverse_playlist") { } ReversePlaylist() : BaseAction(Type::ReversePlaylist, "reverse_playlist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -811,7 +824,7 @@ struct Find : public BaseAction
Find() : BaseAction(Type::Find, "find") { } Find() : BaseAction(Type::Find, "find") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -820,7 +833,7 @@ struct FindItemForward : public BaseAction
FindItemForward() : BaseAction(Type::FindItemForward, "find_item_forward") { } FindItemForward() : BaseAction(Type::FindItemForward, "find_item_forward") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -829,7 +842,7 @@ struct FindItemBackward : public BaseAction
FindItemBackward() : BaseAction(Type::FindItemBackward, "find_item_backward") { } FindItemBackward() : BaseAction(Type::FindItemBackward, "find_item_backward") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -838,7 +851,7 @@ struct NextFoundItem : public BaseAction
NextFoundItem() : BaseAction(Type::NextFoundItem, "next_found_item") { } NextFoundItem() : BaseAction(Type::NextFoundItem, "next_found_item") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -847,7 +860,7 @@ struct PreviousFoundItem : public BaseAction
PreviousFoundItem() : BaseAction(Type::PreviousFoundItem, "previous_found_item") { } PreviousFoundItem() : BaseAction(Type::PreviousFoundItem, "previous_found_item") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -867,14 +880,6 @@ protected:
virtual void run(); virtual void run();
}; };
struct ToggleSpaceMode : public BaseAction
{
ToggleSpaceMode() : BaseAction(Type::ToggleSpaceMode, "toggle_space_mode") { }
protected:
virtual void run();
};
struct ToggleAddMode : public BaseAction struct ToggleAddMode : public BaseAction
{ {
ToggleAddMode() : BaseAction(Type::ToggleAddMode, "toggle_add_mode") { } ToggleAddMode() : BaseAction(Type::ToggleAddMode, "toggle_add_mode") { }
@@ -912,7 +917,7 @@ struct ToggleBrowserSortMode : public BaseAction
ToggleBrowserSortMode() : BaseAction(Type::ToggleBrowserSortMode, "toggle_browser_sort_mode") { } ToggleBrowserSortMode() : BaseAction(Type::ToggleBrowserSortMode, "toggle_browser_sort_mode") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -921,7 +926,7 @@ struct ToggleLibraryTagType : public BaseAction
ToggleLibraryTagType() : BaseAction(Type::ToggleLibraryTagType, "toggle_library_tag_type") { } ToggleLibraryTagType() : BaseAction(Type::ToggleLibraryTagType, "toggle_library_tag_type") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -931,7 +936,7 @@ struct ToggleMediaLibrarySortMode : public BaseAction
: BaseAction(Type::ToggleMediaLibrarySortMode, "toggle_media_library_sort_mode") { } : BaseAction(Type::ToggleMediaLibrarySortMode, "toggle_media_library_sort_mode") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -940,7 +945,7 @@ struct RefetchLyrics : public BaseAction
RefetchLyrics() : BaseAction(Type::RefetchLyrics, "refetch_lyrics") { } RefetchLyrics() : BaseAction(Type::RefetchLyrics, "refetch_lyrics") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -950,7 +955,7 @@ struct SetSelectedItemsPriority : public BaseAction
: BaseAction(Type::SetSelectedItemsPriority, "set_selected_items_priority") { } : BaseAction(Type::SetSelectedItemsPriority, "set_selected_items_priority") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -960,7 +965,7 @@ struct SetVisualizerSampleMultiplier : public BaseAction
: BaseAction(Type::SetVisualizerSampleMultiplier, "set_visualizer_sample_multiplier") { } : BaseAction(Type::SetVisualizerSampleMultiplier, "set_visualizer_sample_multiplier") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -977,7 +982,7 @@ struct ShowArtistInfo : public BaseAction
ShowArtistInfo() : BaseAction(Type::ShowArtistInfo, "show_artist_info") { } ShowArtistInfo() : BaseAction(Type::ShowArtistInfo, "show_artist_info") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1018,7 +1023,7 @@ struct ShowHelp : public BaseAction
ShowHelp() : BaseAction(Type::ShowHelp, "show_help") { } ShowHelp() : BaseAction(Type::ShowHelp, "show_help") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1027,7 +1032,7 @@ struct ShowPlaylist : public BaseAction
ShowPlaylist() : BaseAction(Type::ShowPlaylist, "show_playlist") { } ShowPlaylist() : BaseAction(Type::ShowPlaylist, "show_playlist") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1036,7 +1041,7 @@ struct ShowBrowser : public BaseAction
ShowBrowser() : BaseAction(Type::ShowBrowser, "show_browser") { } ShowBrowser() : BaseAction(Type::ShowBrowser, "show_browser") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1045,7 +1050,7 @@ struct ChangeBrowseMode : public BaseAction
ChangeBrowseMode() : BaseAction(Type::ChangeBrowseMode, "change_browse_mode") { } ChangeBrowseMode() : BaseAction(Type::ChangeBrowseMode, "change_browse_mode") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1054,7 +1059,7 @@ struct ShowSearchEngine : public BaseAction
ShowSearchEngine() : BaseAction(Type::ShowSearchEngine, "show_search_engine") { } ShowSearchEngine() : BaseAction(Type::ShowSearchEngine, "show_search_engine") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1063,7 +1068,7 @@ struct ResetSearchEngine : public BaseAction
ResetSearchEngine() : BaseAction(Type::ResetSearchEngine, "reset_search_engine") { } ResetSearchEngine() : BaseAction(Type::ResetSearchEngine, "reset_search_engine") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1072,7 +1077,7 @@ struct ShowMediaLibrary : public BaseAction
ShowMediaLibrary() : BaseAction(Type::ShowMediaLibrary, "show_media_library") { } ShowMediaLibrary() : BaseAction(Type::ShowMediaLibrary, "show_media_library") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1082,7 +1087,7 @@ struct ToggleMediaLibraryColumnsMode : public BaseAction
: BaseAction(Type::ToggleMediaLibraryColumnsMode, "toggle_media_library_columns_mode") { } : BaseAction(Type::ToggleMediaLibraryColumnsMode, "toggle_media_library_columns_mode") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1091,7 +1096,7 @@ struct ShowPlaylistEditor : public BaseAction
ShowPlaylistEditor() : BaseAction(Type::ShowPlaylistEditor, "show_playlist_editor") { } ShowPlaylistEditor() : BaseAction(Type::ShowPlaylistEditor, "show_playlist_editor") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1100,7 +1105,7 @@ struct ShowTagEditor : public BaseAction
ShowTagEditor() : BaseAction(Type::ShowTagEditor, "show_tag_editor") { } ShowTagEditor() : BaseAction(Type::ShowTagEditor, "show_tag_editor") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1109,7 +1114,7 @@ struct ShowOutputs : public BaseAction
ShowOutputs() : BaseAction(Type::ShowOutputs, "show_outputs") { } ShowOutputs() : BaseAction(Type::ShowOutputs, "show_outputs") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1118,7 +1123,7 @@ struct ShowVisualizer : public BaseAction
ShowVisualizer() : BaseAction(Type::ShowVisualizer, "show_visualizer") { } ShowVisualizer() : BaseAction(Type::ShowVisualizer, "show_visualizer") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1127,7 +1132,7 @@ struct ShowClock : public BaseAction
ShowClock() : BaseAction(Type::ShowClock, "show_clock") { } ShowClock() : BaseAction(Type::ShowClock, "show_clock") { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run(); virtual void run();
}; };
@@ -1137,7 +1142,7 @@ struct ShowServerInfo : public BaseAction
protected: protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun();
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
virtual void run(); virtual void run();
}; };

View File

@@ -359,6 +359,8 @@ void BindingsConfiguration::generateDefaults()
bind(k, Actions::Type::MoveHome); bind(k, Actions::Type::MoveHome);
if (notBound(k = stringToKey("end"))) if (notBound(k = stringToKey("end")))
bind(k, Actions::Type::MoveEnd); bind(k, Actions::Type::MoveEnd);
if (notBound(k = stringToKey("insert")))
bind(k, Actions::Type::SelectItem);
if (notBound(k = stringToKey("space"))) if (notBound(k = stringToKey("space")))
bind(k, Actions::Type::PressSpace); bind(k, Actions::Type::PressSpace);
if (notBound(k = stringToKey("enter"))) if (notBound(k = stringToKey("enter")))
@@ -463,8 +465,6 @@ void BindingsConfiguration::generateDefaults()
bind(k, Actions::Type::ToggleConsume); bind(k, Actions::Type::ToggleConsume);
if (notBound(k = stringToKey("Y"))) if (notBound(k = stringToKey("Y")))
bind(k, Actions::Type::ToggleReplayGainMode); bind(k, Actions::Type::ToggleReplayGainMode);
if (notBound(k = stringToKey("t")))
bind(k, Actions::Type::ToggleSpaceMode);
if (notBound(k = stringToKey("T"))) if (notBound(k = stringToKey("T")))
bind(k, Actions::Type::ToggleAddMode); bind(k, Actions::Type::ToggleAddMode);
if (notBound(k = stringToKey("|"))) if (notBound(k = stringToKey("|")))

View File

@@ -192,15 +192,6 @@ void Browser::spacePressed()
if (w.empty()) if (w.empty())
return; return;
size_t i = inRootDirectory() ? 0 : 1;
if (Config.space_selects && w.choice() >= i)
{
i = w.choice();
w[i].setSelected(!w[i].isSelected());
w.scroll(NC::Scroll::Down);
return;
}
const MPD::Item &item = w.current()->value(); const MPD::Item &item = w.current()->value();
// ignore parent directory // ignore parent directory
if (isParentDirectory(item)) if (isParentDirectory(item))
@@ -316,7 +307,14 @@ ProxySongList Browser::proxySongList()
bool Browser::allowsSelection() bool Browser::allowsSelection()
{ {
return true; size_t root = inRootDirectory() ? 0 : 1;
return !w.empty() && w.choice() >= root;
}
void Browser::selectCurrent()
{
size_t current = w.choice();
w[current].setSelected(!w[current].isSelected());
} }
void Browser::reverseSelection() void Browser::reverseSelection()

View File

@@ -56,6 +56,7 @@ struct Browser: Screen<NC::Menu<MPD::Item>>, HasSongs, Searchable, Tabbable
virtual ProxySongList proxySongList() OVERRIDE; virtual ProxySongList proxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE; virtual bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() OVERRIDE; virtual void reverseSelection() OVERRIDE;
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE; virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;

View File

@@ -225,11 +225,11 @@ void write_bindings(NC::Scrollpad &w)
boost::format("Increase volume by %1%%%") % Config.volume_change_step boost::format("Increase volume by %1%%%") % Config.volume_change_step
); );
w << '\n'; w << '\n';
key(w, Type::ToggleSpaceMode, "Toggle space mode (select/add)");
key(w, Type::ToggleAddMode, "Toggle add mode (add or remove/always add)"); key(w, Type::ToggleAddMode, "Toggle add mode (add or remove/always add)");
key(w, Type::ToggleMouse, "Toggle mouse support"); key(w, Type::ToggleMouse, "Toggle mouse support");
key(w, Type::ReverseSelection, "Reverse selection"); key(w, Type::ReverseSelection, "Reverse selection");
key(w, Type::RemoveSelection, "Remove selection"); key(w, Type::RemoveSelection, "Remove selection");
key(w, Type::SelectItem, "Select current item");
key(w, Type::SelectAlbum, "Select songs of album around the cursor"); key(w, Type::SelectAlbum, "Select songs of album around the cursor");
key(w, Type::AddSelectedItems, "Add selected items to playlist"); key(w, Type::AddSelectedItems, "Add selected items to playlist");
key(w, Type::AddRandomItems, "Add random items to playlist"); key(w, Type::AddRandomItems, "Add random items to playlist");
@@ -295,7 +295,7 @@ void write_bindings(NC::Scrollpad &w)
key_section(w, "Browser"); key_section(w, "Browser");
key(w, Type::PressEnter, "Enter directory/Add item to playlist and play it"); key(w, Type::PressEnter, "Enter directory/Add item to playlist and play it");
key(w, Type::PressSpace, "Add item to playlist/select it"); key(w, Type::PressSpace, "Add item to playlist");
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
key(w, Type::EditSong, "Edit song"); key(w, Type::EditSong, "Edit song");
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -334,7 +334,7 @@ void write_bindings(NC::Scrollpad &w)
key(w, Type::PreviousColumn, "Previous column"); key(w, Type::PreviousColumn, "Previous column");
key(w, Type::NextColumn, "Next column"); key(w, Type::NextColumn, "Next column");
key(w, Type::PressEnter, "Add item to playlist and play it"); key(w, Type::PressEnter, "Add item to playlist and play it");
key(w, Type::PressSpace, "Add item to playlist/select it"); key(w, Type::PressSpace, "Add item to playlist");
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
key(w, Type::EditSong, "Edit song"); key(w, Type::EditSong, "Edit song");
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -359,8 +359,6 @@ void write_bindings(NC::Scrollpad &w)
key_section(w, "Tag editor"); key_section(w, "Tag editor");
key(w, Type::PressEnter, "Edit tag/filename of selected item (left column)"); key(w, Type::PressEnter, "Edit tag/filename of selected item (left column)");
key(w, Type::PressEnter, "Perform operation on all/selected items (middle column)"); key(w, Type::PressEnter, "Perform operation on all/selected items (middle column)");
key(w, Type::PressSpace, "Switch to albums/directories view (left column)");
key(w, Type::PressSpace, "Select item (right column)");
key(w, Type::PreviousColumn, "Previous column"); key(w, Type::PreviousColumn, "Previous column");
key(w, Type::NextColumn, "Next column"); key(w, Type::NextColumn, "Next column");
key(w, Type::JumpToParentDirectory, "Jump to parent directory (left column, directories view)"); key(w, Type::JumpToParentDirectory, "Jump to parent directory (left column, directories view)");

View File

@@ -42,6 +42,7 @@ struct HasSongs
virtual bool allowsSelection() = 0; virtual bool allowsSelection() = 0;
virtual void reverseSelection() = 0; virtual void reverseSelection() = 0;
virtual void selectCurrent() = 0;
virtual std::vector<MPD::Song> getSelectedSongs() = 0; virtual std::vector<MPD::Song> getSelectedSongs() = 0;
}; };

View File

@@ -29,12 +29,12 @@ void PushCharacters::run()
(*m_window)->pushChar(*it); (*m_window)->pushChar(*it);
} }
bool RequireRunnable::canBeRun() const bool RequireRunnable::canBeRun()
{ {
return m_action->canBeRun(); return m_action->canBeRun();
} }
bool RequireScreen::canBeRun() const bool RequireScreen::canBeRun()
{ {
return Global::myScreen->type() == m_screen_type; return Global::myScreen->type() == m_screen_type;
} }

View File

@@ -46,7 +46,7 @@ struct RequireRunnable : public BaseAction
: BaseAction(Type::MacroUtility, ""), m_action(action) { assert(action); } : BaseAction(Type::MacroUtility, ""), m_action(action) { assert(action); }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run() { } virtual void run() { }
private: private:
@@ -59,7 +59,7 @@ struct RequireScreen : public BaseAction
: BaseAction(Type::MacroUtility, ""), m_screen_type(screen_type) { } : BaseAction(Type::MacroUtility, ""), m_screen_type(screen_type) { }
protected: protected:
virtual bool canBeRun() const; virtual bool canBeRun();
virtual void run() { } virtual void run() { }
private: private:

View File

@@ -448,35 +448,7 @@ void MediaLibrary::enterPressed()
void MediaLibrary::spacePressed() void MediaLibrary::spacePressed()
{ {
if (Config.space_selects) AddToPlaylist(false);
{
if (isActiveWindow(Tags))
{
size_t idx = Tags.choice();
Tags[idx].setSelected(!Tags[idx].isSelected());
Tags.scroll(NC::Scroll::Down);
Albums.clear();
Songs.clear();
}
else if (isActiveWindow(Albums))
{
if (!Albums.current()->value().isAllTracksEntry())
{
size_t idx = Albums.choice();
Albums[idx].setSelected(!Albums[idx].isSelected());
Albums.scroll(NC::Scroll::Down);
Songs.clear();
}
}
else if (isActiveWindow(Songs))
{
size_t idx = Songs.choice();
Songs[idx].setSelected(!Songs[idx].isSelected());
Songs.scroll(NC::Scroll::Down);
}
}
else
AddToPlaylist(false);
} }
void MediaLibrary::mouseButtonPressed(MEVENT me) void MediaLibrary::mouseButtonPressed(MEVENT me)
@@ -638,7 +610,28 @@ ProxySongList MediaLibrary::proxySongList()
bool MediaLibrary::allowsSelection() bool MediaLibrary::allowsSelection()
{ {
return true; return (isActiveWindow(Tags) && !Tags.empty())
|| (isActiveWindow(Albums) && !Albums.empty() && !Albums.current()->value().isAllTracksEntry())
|| (isActiveWindow(Songs) && !Songs.empty());
}
void MediaLibrary::selectCurrent()
{
if (isActiveWindow(Tags))
{
size_t idx = Tags.choice();
Tags[idx].setSelected(!Tags[idx].isSelected());
}
else if (isActiveWindow(Albums))
{
size_t idx = Albums.choice();
Albums[idx].setSelected(!Albums[idx].isSelected());
}
else if (isActiveWindow(Songs))
{
size_t idx = Songs.choice();
Songs[idx].setSelected(!Songs[idx].isSelected());
}
} }
void MediaLibrary::reverseSelection() void MediaLibrary::reverseSelection()

View File

@@ -59,6 +59,7 @@ struct MediaLibrary: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tab
virtual ProxySongList proxySongList() OVERRIDE; virtual ProxySongList proxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE; virtual bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() OVERRIDE; virtual void reverseSelection() OVERRIDE;
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE; virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;

View File

@@ -134,15 +134,6 @@ void Playlist::enterPressed()
Mpd.PlayID(w.current()->value().getID()); Mpd.PlayID(w.current()->value().getID());
} }
void Playlist::spacePressed()
{
if (!w.empty())
{
w.current()->setSelected(!w.current()->isSelected());
w.scroll(NC::Scroll::Down);
}
}
void Playlist::mouseButtonPressed(MEVENT me) void Playlist::mouseButtonPressed(MEVENT me)
{ {
if (!w.empty() && w.hasCoords(me.x, me.y)) if (!w.empty() && w.hasCoords(me.x, me.y))
@@ -193,7 +184,12 @@ ProxySongList Playlist::proxySongList()
bool Playlist::allowsSelection() bool Playlist::allowsSelection()
{ {
return true; return !w.empty();
}
void Playlist::selectCurrent()
{
w.current()->setSelected(!w.current()->isSelected());
} }
void Playlist::reverseSelection() void Playlist::reverseSelection()

View File

@@ -43,7 +43,7 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, HasSongs, Searchable, Tabbable
virtual void update() OVERRIDE; virtual void update() OVERRIDE;
virtual void enterPressed() OVERRIDE; virtual void enterPressed() OVERRIDE;
virtual void spacePressed() OVERRIDE; virtual void spacePressed() OVERRIDE { }
virtual void mouseButtonPressed(MEVENT me) OVERRIDE; virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
virtual bool isLockable() OVERRIDE { return true; } virtual bool isLockable() OVERRIDE { return true; }
@@ -59,6 +59,7 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, HasSongs, Searchable, Tabbable
virtual ProxySongList proxySongList() OVERRIDE; virtual ProxySongList proxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE; virtual bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() OVERRIDE; virtual void reverseSelection() OVERRIDE;
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE; virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;

View File

@@ -250,27 +250,7 @@ void PlaylistEditor::enterPressed()
void PlaylistEditor::spacePressed() void PlaylistEditor::spacePressed()
{ {
if (Config.space_selects) AddToPlaylist(false);
{
if (isActiveWindow(Playlists))
{
if (!Playlists.empty())
{
Playlists.current()->setSelected(!Playlists.current()->isSelected());
Playlists.scroll(NC::Scroll::Down);
}
}
else if (isActiveWindow(Content))
{
if (!Content.empty())
{
Content.current()->setSelected(!Content.current()->isSelected());
Content.scroll(NC::Scroll::Down);
}
}
}
else
AddToPlaylist(false);
} }
void PlaylistEditor::mouseButtonPressed(MEVENT me) void PlaylistEditor::mouseButtonPressed(MEVENT me)
@@ -381,7 +361,16 @@ ProxySongList PlaylistEditor::proxySongList()
bool PlaylistEditor::allowsSelection() bool PlaylistEditor::allowsSelection()
{ {
return true; return (isActiveWindow(Playlists) && !Playlists.empty())
|| (isActiveWindow(Content) && !Content.empty());
}
void PlaylistEditor::selectCurrent()
{
if (isActiveWindow(Playlists))
Playlists.current()->setSelected(!Playlists.current()->isSelected());
else if (isActiveWindow(Content))
Content.current()->setSelected(!Content.current()->isSelected());
} }
void PlaylistEditor::reverseSelection() void PlaylistEditor::reverseSelection()

View File

@@ -59,6 +59,7 @@ struct PlaylistEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, T
virtual ProxySongList proxySongList() OVERRIDE; virtual ProxySongList proxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE; virtual bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() OVERRIDE; virtual void reverseSelection() OVERRIDE;
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE; virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;

View File

@@ -213,18 +213,11 @@ void SearchEngine::enterPressed()
void SearchEngine::spacePressed() void SearchEngine::spacePressed()
{ {
if (!w.current()->value().isSong()) if (w.current()->value().isSong())
return;
if (Config.space_selects)
{ {
w.current()->setSelected(!w.current()->isSelected()); addSongToPlaylist(w.current()->value().song(), false);
w.scroll(NC::Scroll::Down); w.scroll(NC::Scroll::Down);
return;
} }
addSongToPlaylist(w.current()->value().song(), false);
w.scroll(NC::Scroll::Down);
} }
void SearchEngine::mouseButtonPressed(MEVENT me) void SearchEngine::mouseButtonPressed(MEVENT me)
@@ -297,6 +290,11 @@ bool SearchEngine::allowsSelection()
return w.current()->value().isSong(); return w.current()->value().isSong();
} }
void SearchEngine::selectCurrent()
{
w.current()->setSelected(!w.current()->isSelected());
}
void SearchEngine::reverseSelection() void SearchEngine::reverseSelection()
{ {
reverseSelectionHelper(w.begin()+std::min(StaticOptions, w.size()), w.end()); reverseSelectionHelper(w.begin()+std::min(StaticOptions, w.size()), w.end());

View File

@@ -104,6 +104,7 @@ struct SearchEngine: Screen<NC::Menu<SEItem>>, HasSongs, Searchable, Tabbable
virtual ProxySongList proxySongList() OVERRIDE; virtual ProxySongList proxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE; virtual bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() OVERRIDE; virtual void reverseSelection() OVERRIDE;
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE; virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;

View File

@@ -457,15 +457,6 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
throw std::runtime_error("invalid argument: " + v); throw std::runtime_error("invalid argument: " + v);
}, defaults_to(wrapped_search, true) }, defaults_to(wrapped_search, true)
)); ));
p.add("default_space_mode", option_parser::worker([this](std::string v) {
if (v == "add")
space_selects = false;
else if (v == "select")
space_selects = true;
else
throw std::runtime_error("invalid argument: " + v);
}, defaults_to(wrapped_search, true)
));
p.add("default_tag_editor_pattern", assign_default( p.add("default_tag_editor_pattern", assign_default(
pattern, "%n - %t" pattern, "%n - %t"
)); ));

View File

@@ -137,7 +137,6 @@ struct Configuration
bool screen_switcher_previous; bool screen_switcher_previous;
bool autocenter_mode; bool autocenter_mode;
bool wrapped_search; bool wrapped_search;
bool space_selects;
bool incremental_seeking; bool incremental_seeking;
bool now_playing_lyrics; bool now_playing_lyrics;
bool fetch_lyrics_in_background; bool fetch_lyrics_in_background;

View File

@@ -580,15 +580,6 @@ void TagEditor::enterPressed()
} }
} }
void TagEditor::spacePressed()
{
if (w == Tags && !Tags->empty())
{
Tags->current()->setSelected(!Tags->current()->isSelected());
w->scroll(NC::Scroll::Down);
}
}
void TagEditor::mouseButtonPressed(MEVENT me) void TagEditor::mouseButtonPressed(MEVENT me)
{ {
auto tryPreviousColumn = [this]() -> bool { auto tryPreviousColumn = [this]() -> bool {
@@ -772,13 +763,17 @@ ProxySongList TagEditor::proxySongList()
bool TagEditor::allowsSelection() bool TagEditor::allowsSelection()
{ {
return w == Tags; return w == Tags && !Tags->empty();
}
void TagEditor::selectCurrent()
{
Tags->current()->setSelected(!Tags->current()->isSelected());
} }
void TagEditor::reverseSelection() void TagEditor::reverseSelection()
{ {
if (w == Tags) reverseSelectionHelper(Tags->begin(), Tags->end());
reverseSelectionHelper(Tags->begin(), Tags->end());
} }
std::vector<MPD::Song> TagEditor::getSelectedSongs() std::vector<MPD::Song> TagEditor::getSelectedSongs()

View File

@@ -46,7 +46,7 @@ struct TagEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tabbab
virtual void update() OVERRIDE; virtual void update() OVERRIDE;
virtual void enterPressed() OVERRIDE; virtual void enterPressed() OVERRIDE;
virtual void spacePressed() OVERRIDE; virtual void spacePressed() OVERRIDE { }
virtual void mouseButtonPressed(MEVENT) OVERRIDE; virtual void mouseButtonPressed(MEVENT) OVERRIDE;
virtual bool isLockable() OVERRIDE { return true; } virtual bool isLockable() OVERRIDE { return true; }
@@ -62,6 +62,7 @@ struct TagEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tabbab
virtual ProxySongList proxySongList() OVERRIDE; virtual ProxySongList proxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE; virtual bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() OVERRIDE; virtual void reverseSelection() OVERRIDE;
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE; virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;