New shortcut: remove current playing song from playlist (#5723)

This commit is contained in:
Alex Bikadorov 2017-05-31 18:59:36 +02:00 committed by John Maguire
parent 583eb25cfc
commit 8953227c65
5 changed files with 12 additions and 0 deletions

View File

@ -79,6 +79,9 @@ GlobalShortcuts::GlobalShortcuts(QWidget* parent)
SIGNAL(Love())); SIGNAL(Love()));
AddShortcut("ban_last_fm_scrobbling", tr("Ban (Last.fm scrobbling)"), AddShortcut("ban_last_fm_scrobbling", tr("Ban (Last.fm scrobbling)"),
SIGNAL(Ban())); SIGNAL(Ban()));
AddShortcut("remove_current_song_from_playlist",
tr("Remove current song from playlist"),
SIGNAL(RemoveCurrentSong()));
AddRatingShortcut("rate_zero_star", tr("Rate the current song 0 stars"), AddRatingShortcut("rate_zero_star", tr("Rate the current song 0 stars"),
rating_signals_mapper_, 0); rating_signals_mapper_, 0);

View File

@ -82,6 +82,7 @@ signals:
void ToggleScrobbling(); void ToggleScrobbling();
void Love(); void Love();
void Ban(); void Ban();
void RemoveCurrentSong();
private: private:
void AddShortcut(const QString& id, const QString& name, const char* signal, void AddShortcut(const QString& id, const QString& name, const char* signal,

View File

@ -494,6 +494,10 @@ void PlaylistManager::RemoveItemsWithoutUndo(int id,
playlists_[id].p->RemoveItemsWithoutUndo(indices); playlists_[id].p->RemoveItemsWithoutUndo(indices);
} }
void PlaylistManager::RemoveCurrentSong() {
active()->removeRows(active()->current_index().row(), 1);
}
void PlaylistManager::InvalidateDeletedSongs() { void PlaylistManager::InvalidateDeletedSongs() {
for (Playlist* playlist : GetAllPlaylists()) { for (Playlist* playlist : GetAllPlaylists()) {
playlist->InvalidateDeletedSongs(); playlist->InvalidateDeletedSongs();

View File

@ -225,6 +225,8 @@ class PlaylistManager : public PlaylistManagerInterface {
// Removes items with given indices from the playlist. This operation is not // Removes items with given indices from the playlist. This operation is not
// undoable. // undoable.
void RemoveItemsWithoutUndo(int id, const QList<int>& indices); void RemoveItemsWithoutUndo(int id, const QList<int>& indices);
// Remove the current playing song
void RemoveCurrentSong();
private slots: private slots:
void SetActivePlaying(); void SetActivePlaying();

View File

@ -848,6 +848,8 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
connect(global_shortcuts_, SIGNAL(RateCurrentSong(int)), connect(global_shortcuts_, SIGNAL(RateCurrentSong(int)),
app_->playlist_manager(), SLOT(RateCurrentSong(int))); app_->playlist_manager(), SLOT(RateCurrentSong(int)));
connect(global_shortcuts_, SIGNAL(RemoveCurrentSong()),
app_->playlist_manager(), SLOT(RemoveCurrentSong()));
// Fancy tabs // Fancy tabs
connect(ui_->tabs, SIGNAL(ModeChanged(FancyTabWidget::Mode)), connect(ui_->tabs, SIGNAL(ModeChanged(FancyTabWidget::Mode)),