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.
* 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.
* Selecting items no longer depends on space mode and is bound by default to Insert key.
ncmpcpp-0.6.4 (2015-05-02)

View File

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

View File

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

View File

@@ -206,9 +206,6 @@ Default tag type for leftmost column in media library.
.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.
.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
Default pattern used by Tag editor's parser.
.TP

View File

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

View File

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

View File

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

View File

@@ -192,15 +192,6 @@ void Browser::spacePressed()
if (w.empty())
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();
// ignore parent directory
if (isParentDirectory(item))
@@ -316,7 +307,14 @@ ProxySongList Browser::proxySongList()
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()

View File

@@ -56,6 +56,7 @@ struct Browser: Screen<NC::Menu<MPD::Item>>, HasSongs, Searchable, Tabbable
virtual ProxySongList proxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() 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
);
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::ToggleMouse, "Toggle mouse support");
key(w, Type::ReverseSelection, "Reverse 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::AddSelectedItems, "Add selected 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(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
key(w, Type::EditSong, "Edit song");
# endif // HAVE_TAGLIB_H
@@ -334,7 +334,7 @@ void write_bindings(NC::Scrollpad &w)
key(w, Type::PreviousColumn, "Previous column");
key(w, Type::NextColumn, "Next column");
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
key(w, Type::EditSong, "Edit song");
# endif // HAVE_TAGLIB_H
@@ -359,8 +359,6 @@ void write_bindings(NC::Scrollpad &w)
key_section(w, "Tag editor");
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::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::NextColumn, "Next column");
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 void reverseSelection() = 0;
virtual void selectCurrent() = 0;
virtual std::vector<MPD::Song> getSelectedSongs() = 0;
};

View File

@@ -29,12 +29,12 @@ void PushCharacters::run()
(*m_window)->pushChar(*it);
}
bool RequireRunnable::canBeRun() const
bool RequireRunnable::canBeRun()
{
return m_action->canBeRun();
}
bool RequireScreen::canBeRun() const
bool RequireScreen::canBeRun()
{
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); }
protected:
virtual bool canBeRun() const;
virtual bool canBeRun();
virtual void run() { }
private:
@@ -59,7 +59,7 @@ struct RequireScreen : public BaseAction
: BaseAction(Type::MacroUtility, ""), m_screen_type(screen_type) { }
protected:
virtual bool canBeRun() const;
virtual bool canBeRun();
virtual void run() { }
private:

View File

@@ -448,34 +448,6 @@ void MediaLibrary::enterPressed()
void MediaLibrary::spacePressed()
{
if (Config.space_selects)
{
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);
}
@@ -638,7 +610,28 @@ ProxySongList MediaLibrary::proxySongList()
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()

View File

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

View File

@@ -134,15 +134,6 @@ void Playlist::enterPressed()
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)
{
if (!w.empty() && w.hasCoords(me.x, me.y))
@@ -193,7 +184,12 @@ ProxySongList Playlist::proxySongList()
bool Playlist::allowsSelection()
{
return true;
return !w.empty();
}
void Playlist::selectCurrent()
{
w.current()->setSelected(!w.current()->isSelected());
}
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 enterPressed() OVERRIDE;
virtual void spacePressed() OVERRIDE;
virtual void spacePressed() OVERRIDE { }
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
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 bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() OVERRIDE;
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;

View File

@@ -250,26 +250,6 @@ void PlaylistEditor::enterPressed()
void PlaylistEditor::spacePressed()
{
if (Config.space_selects)
{
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);
}
@@ -381,7 +361,16 @@ ProxySongList PlaylistEditor::proxySongList()
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()

View File

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

View File

@@ -213,19 +213,12 @@ void SearchEngine::enterPressed()
void SearchEngine::spacePressed()
{
if (!w.current()->value().isSong())
return;
if (Config.space_selects)
if (w.current()->value().isSong())
{
w.current()->setSelected(!w.current()->isSelected());
w.scroll(NC::Scroll::Down);
return;
}
addSongToPlaylist(w.current()->value().song(), false);
w.scroll(NC::Scroll::Down);
}
}
void SearchEngine::mouseButtonPressed(MEVENT me)
{
@@ -297,6 +290,11 @@ bool SearchEngine::allowsSelection()
return w.current()->value().isSong();
}
void SearchEngine::selectCurrent()
{
w.current()->setSelected(!w.current()->isSelected());
}
void SearchEngine::reverseSelection()
{
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 bool allowsSelection() OVERRIDE;
virtual void selectCurrent() OVERRIDE;
virtual void reverseSelection() 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);
}, 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(
pattern, "%n - %t"
));

View File

@@ -137,7 +137,6 @@ struct Configuration
bool screen_switcher_previous;
bool autocenter_mode;
bool wrapped_search;
bool space_selects;
bool incremental_seeking;
bool now_playing_lyrics;
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)
{
auto tryPreviousColumn = [this]() -> bool {
@@ -772,12 +763,16 @@ ProxySongList TagEditor::proxySongList()
bool TagEditor::allowsSelection()
{
return w == Tags;
return w == Tags && !Tags->empty();
}
void TagEditor::selectCurrent()
{
Tags->current()->setSelected(!Tags->current()->isSelected());
}
void TagEditor::reverseSelection()
{
if (w == Tags)
reverseSelectionHelper(Tags->begin(), Tags->end());
}

View File

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