diff --git a/doc/bindings b/doc/bindings index ca4d09b6..196e7eed 100644 --- a/doc/bindings +++ b/doc/bindings @@ -193,6 +193,9 @@ # select_item # #def_key "enter" +# play +# +#def_key "enter" # toggle_output # #def_key "enter" diff --git a/src/actions.cpp b/src/actions.cpp index 16496cdd..3ed8e505 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -957,6 +957,17 @@ void Add::run() } } +bool Play::canBeRun() +{ + return myScreen == myPlaylist + && !myPlaylist->main().empty(); +} + +void Play::run() +{ + Mpd.PlayID(myPlaylist->main().current()->value().getID()); +} + bool SeekForward::canBeRun() { return Status::State::player() != MPD::psStop && Status::State::totalTime() > 0; @@ -2618,6 +2629,7 @@ void populateActions() insert_action(new Actions::MoveSelectedItemsDown()); insert_action(new Actions::MoveSelectedItemsTo()); insert_action(new Actions::Add()); + insert_action(new Actions::Play()); insert_action(new Actions::SeekForward()); insert_action(new Actions::SeekBackward()); insert_action(new Actions::ToggleDisplayMode()); diff --git a/src/actions.h b/src/actions.h index 515b5e66..f37f7148 100644 --- a/src/actions.h +++ b/src/actions.h @@ -41,7 +41,7 @@ enum class Type NextColumn, MasterScreen, SlaveScreen, VolumeUp, VolumeDown, AddItemToPlaylist, DeletePlaylistItems, DeleteStoredPlaylist, DeleteBrowserItems, ReplaySong, Previous, Next, Pause, Stop, ExecuteCommand, SavePlaylist, MoveSortOrderUp, MoveSortOrderDown, - MoveSelectedItemsUp, MoveSelectedItemsDown, MoveSelectedItemsTo, Add, + MoveSelectedItemsUp, MoveSelectedItemsDown, MoveSelectedItemsTo, Add, Play, SeekForward, SeekBackward, ToggleDisplayMode, ToggleSeparatorsBetweenAlbums, ToggleLyricsUpdateOnSongChange, ToggleLyricsFetcher, ToggleFetchingLyricsInBackground, TogglePlayingSongCentering, UpdateDatabase, JumpToPlayingSong, ToggleRepeat, Shuffle, @@ -474,6 +474,15 @@ private: virtual void run() OVERRIDE; }; +struct Play: BaseAction +{ + Play(): BaseAction(Type::Play, "play") { } + +private: + virtual bool canBeRun() OVERRIDE; + virtual void run() OVERRIDE; +}; + struct SeekForward: BaseAction { SeekForward(): BaseAction(Type::SeekForward, "seek_forward") { } diff --git a/src/bindings.cpp b/src/bindings.cpp index 557994be..ebd26fe1 100644 --- a/src/bindings.cpp +++ b/src/bindings.cpp @@ -497,6 +497,7 @@ void BindingsConfiguration::generateDefaults() bind(k, Actions::Type::SelectItem); if (notBound(k = stringToKey("enter"))) { + bind(k, Actions::Type::Play); bind(k, Actions::Type::ToggleOutput); bind(k, Actions::Type::PressEnter); } diff --git a/src/help.cpp b/src/help.cpp index be7ed3ea..d14f7d96 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -238,7 +238,7 @@ void write_bindings(NC::Scrollpad &w) key(w, Type::Quit, "Quit"); key_section(w, "Playlist"); - key(w, Type::PressEnter, "Play selected item"); + key(w, Type::Play, "Play selected item"); key(w, Type::DeletePlaylistItems, "Delete selected item(s) from playlist"); key(w, Type::ClearMainPlaylist, "Clear playlist"); key(w, Type::CropMainPlaylist, "Clear playlist except selected item(s)"); diff --git a/src/playlist.cpp b/src/playlist.cpp index b0d991fc..a8e2f775 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -131,12 +131,6 @@ void Playlist::update() } } -void Playlist::enterPressed() -{ - if (!w.empty()) - Mpd.PlayID(w.current()->value().getID()); -} - void Playlist::mouseButtonPressed(MEVENT me) { if (!w.empty() && w.hasCoords(me.x, me.y)) diff --git a/src/playlist.h b/src/playlist.h index 1733d9d2..65f32568 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -43,7 +43,7 @@ struct Playlist: Screen, HasSongs, Searchable, Tabbable virtual void update() OVERRIDE; - virtual void enterPressed() OVERRIDE; + virtual void enterPressed() OVERRIDE { } virtual void mouseButtonPressed(MEVENT me) OVERRIDE; virtual bool isLockable() OVERRIDE { return true; }