actions: add support for selecting found items
This commit is contained in:
1
NEWS
1
NEWS
@@ -27,6 +27,7 @@ ncmpcpp-0.7 (????-??-??)
|
|||||||
* Monolithic 'press_space' action was split into 'add_item_to_playlist', 'toggle_lyrics_update_on_song_change' and 'toggle_visualization_type'.
|
* Monolithic 'press_space' action was split into 'add_item_to_playlist', 'toggle_lyrics_update_on_song_change' and 'toggle_visualization_type'.
|
||||||
* Sorting actions were rebound to Ctrl-S.
|
* Sorting actions were rebound to Ctrl-S.
|
||||||
* Support for range selection was added (bound to Ctrl-V by default). In addition, sorting, reversing and shuffling items in playlist now works on ranges.
|
* Support for range selection was added (bound to Ctrl-V by default). In addition, sorting, reversing and shuffling items in playlist now works on ranges.
|
||||||
|
* Support for selecting found items was added (bound to Ctrl-_ by default).
|
||||||
|
|
||||||
ncmpcpp-0.6.4 (2015-05-02)
|
ncmpcpp-0.6.4 (2015-05-02)
|
||||||
|
|
||||||
|
|||||||
@@ -364,6 +364,9 @@
|
|||||||
#def_key "ctrl_r"
|
#def_key "ctrl_r"
|
||||||
# reverse_playlist
|
# reverse_playlist
|
||||||
#
|
#
|
||||||
|
#def_key "ctrl__"
|
||||||
|
# select_found_items
|
||||||
|
#
|
||||||
#def_key "/"
|
#def_key "/"
|
||||||
# find
|
# find
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1755,6 +1755,31 @@ void SelectAlbum::run()
|
|||||||
Statusbar::print("Album around cursor position selected");
|
Statusbar::print("Album around cursor position selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SelectFoundItems::canBeRun()
|
||||||
|
{
|
||||||
|
m_list = dynamic_cast<NC::List *>(myScreen->activeWindow());
|
||||||
|
if (m_list == nullptr || m_list->empty())
|
||||||
|
return false;
|
||||||
|
m_searchable = dynamic_cast<Searchable *>(myScreen);
|
||||||
|
return m_searchable != nullptr && m_searchable->allowsSearching();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectFoundItems::run()
|
||||||
|
{
|
||||||
|
auto current_pos = m_list->choice();
|
||||||
|
myScreen->activeWindow()->scroll(NC::Scroll::Home);
|
||||||
|
bool found = m_searchable->find(SearchDirection::Forward, false, false);
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
Statusbar::print("Searching for items...");
|
||||||
|
m_list->currentP()->setSelected(true);
|
||||||
|
while (m_searchable->find(SearchDirection::Forward, false, true))
|
||||||
|
m_list->currentP()->setSelected(true);
|
||||||
|
Statusbar::print("Found items selected");
|
||||||
|
}
|
||||||
|
m_list->highlight(current_pos);
|
||||||
|
}
|
||||||
|
|
||||||
bool AddSelectedItems::canBeRun()
|
bool AddSelectedItems::canBeRun()
|
||||||
{
|
{
|
||||||
return myScreen != mySelectedItemsAdder;
|
return myScreen != mySelectedItemsAdder;
|
||||||
@@ -2617,6 +2642,7 @@ void populateActions()
|
|||||||
insert_action(new Actions::ReverseSelection());
|
insert_action(new Actions::ReverseSelection());
|
||||||
insert_action(new Actions::RemoveSelection());
|
insert_action(new Actions::RemoveSelection());
|
||||||
insert_action(new Actions::SelectAlbum());
|
insert_action(new Actions::SelectAlbum());
|
||||||
|
insert_action(new Actions::SelectFoundItems());
|
||||||
insert_action(new Actions::AddSelectedItems());
|
insert_action(new Actions::AddSelectedItems());
|
||||||
insert_action(new Actions::CropMainPlaylist());
|
insert_action(new Actions::CropMainPlaylist());
|
||||||
insert_action(new Actions::CropPlaylist());
|
insert_action(new Actions::CropPlaylist());
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ enum class Type
|
|||||||
SetCrossfade, SetVolume, EditSong, EditLibraryTag, EditLibraryAlbum, EditDirectoryName,
|
SetCrossfade, SetVolume, EditSong, EditLibraryTag, EditLibraryAlbum, EditDirectoryName,
|
||||||
EditPlaylistName, EditLyrics, JumpToBrowser, JumpToMediaLibrary,
|
EditPlaylistName, EditLyrics, JumpToBrowser, JumpToMediaLibrary,
|
||||||
JumpToPlaylistEditor, ToggleScreenLock, JumpToTagEditor, JumpToPositionInSong,
|
JumpToPlaylistEditor, ToggleScreenLock, JumpToTagEditor, JumpToPositionInSong,
|
||||||
SelectItem, SelectRange, ReverseSelection, RemoveSelection, SelectAlbum, AddSelectedItems,
|
SelectItem, SelectRange, ReverseSelection, RemoveSelection, SelectAlbum, SelectFoundItems,
|
||||||
CropMainPlaylist, CropPlaylist, ClearMainPlaylist, ClearPlaylist, SortPlaylist,
|
AddSelectedItems, CropMainPlaylist, CropPlaylist, ClearMainPlaylist, ClearPlaylist,
|
||||||
ReversePlaylist, Find, FindItemForward, FindItemBackward,
|
SortPlaylist, ReversePlaylist, Find, FindItemForward, FindItemBackward,
|
||||||
NextFoundItem, PreviousFoundItem, ToggleFindMode, ToggleReplayGainMode,
|
NextFoundItem, PreviousFoundItem, ToggleFindMode, ToggleReplayGainMode,
|
||||||
ToggleAddMode, ToggleMouse, ToggleBitrateVisibility,
|
ToggleAddMode, ToggleMouse, ToggleBitrateVisibility,
|
||||||
AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType,
|
AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType,
|
||||||
@@ -827,6 +827,18 @@ private:
|
|||||||
SongList *m_songs;
|
SongList *m_songs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SelectFoundItems: BaseAction
|
||||||
|
{
|
||||||
|
SelectFoundItems(): BaseAction(Type::SelectFoundItems, "select_found_items") { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual bool canBeRun() OVERRIDE;
|
||||||
|
virtual void run() OVERRIDE;
|
||||||
|
|
||||||
|
NC::List *m_list;
|
||||||
|
Searchable *m_searchable;
|
||||||
|
};
|
||||||
|
|
||||||
struct AddSelectedItems: BaseAction
|
struct AddSelectedItems: BaseAction
|
||||||
{
|
{
|
||||||
AddSelectedItems(): BaseAction(Type::AddSelectedItems, "add_selected_items") { }
|
AddSelectedItems(): BaseAction(Type::AddSelectedItems, "add_selected_items") { }
|
||||||
|
|||||||
@@ -597,6 +597,8 @@ void BindingsConfiguration::generateDefaults()
|
|||||||
}
|
}
|
||||||
if (notBound(k = stringToKey("ctrl_r")))
|
if (notBound(k = stringToKey("ctrl_r")))
|
||||||
bind(k, Actions::Type::ReversePlaylist);
|
bind(k, Actions::Type::ReversePlaylist);
|
||||||
|
if (notBound(k = stringToKey("ctrl__")))
|
||||||
|
bind(k, Actions::Type::SelectFoundItems);
|
||||||
if (notBound(k = stringToKey("/")))
|
if (notBound(k = stringToKey("/")))
|
||||||
{
|
{
|
||||||
bind(k, Actions::Type::Find);
|
bind(k, Actions::Type::Find);
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
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::SelectItem, "Select current item");
|
||||||
|
key(w, Type::SelectFoundItems, "Select found items");
|
||||||
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");
|
||||||
|
|||||||
Reference in New Issue
Block a user