From 8953227c65e870ae36a108c7f27f4d6ef19fae50 Mon Sep 17 00:00:00 2001 From: Alex Bikadorov Date: Wed, 31 May 2017 18:59:36 +0200 Subject: [PATCH] New shortcut: remove current playing song from playlist (#5723) --- src/core/globalshortcuts.cpp | 3 +++ src/core/globalshortcuts.h | 1 + src/playlist/playlistmanager.cpp | 4 ++++ src/playlist/playlistmanager.h | 2 ++ src/ui/mainwindow.cpp | 2 ++ 5 files changed, 12 insertions(+) diff --git a/src/core/globalshortcuts.cpp b/src/core/globalshortcuts.cpp index 3a6ebc390..0f0749443 100644 --- a/src/core/globalshortcuts.cpp +++ b/src/core/globalshortcuts.cpp @@ -79,6 +79,9 @@ GlobalShortcuts::GlobalShortcuts(QWidget* parent) SIGNAL(Love())); AddShortcut("ban_last_fm_scrobbling", tr("Ban (Last.fm scrobbling)"), 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"), rating_signals_mapper_, 0); diff --git a/src/core/globalshortcuts.h b/src/core/globalshortcuts.h index a80d89549..2738cac98 100644 --- a/src/core/globalshortcuts.h +++ b/src/core/globalshortcuts.h @@ -82,6 +82,7 @@ signals: void ToggleScrobbling(); void Love(); void Ban(); + void RemoveCurrentSong(); private: void AddShortcut(const QString& id, const QString& name, const char* signal, diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 7f6b87600..efd3917d5 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -494,6 +494,10 @@ void PlaylistManager::RemoveItemsWithoutUndo(int id, playlists_[id].p->RemoveItemsWithoutUndo(indices); } +void PlaylistManager::RemoveCurrentSong() { + active()->removeRows(active()->current_index().row(), 1); +} + void PlaylistManager::InvalidateDeletedSongs() { for (Playlist* playlist : GetAllPlaylists()) { playlist->InvalidateDeletedSongs(); diff --git a/src/playlist/playlistmanager.h b/src/playlist/playlistmanager.h index 5d678e959..8c8f66d10 100644 --- a/src/playlist/playlistmanager.h +++ b/src/playlist/playlistmanager.h @@ -225,6 +225,8 @@ class PlaylistManager : public PlaylistManagerInterface { // Removes items with given indices from the playlist. This operation is not // undoable. void RemoveItemsWithoutUndo(int id, const QList& indices); + // Remove the current playing song + void RemoveCurrentSong(); private slots: void SetActivePlaying(); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 295ef66cb..83db85979 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -848,6 +848,8 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd, connect(global_shortcuts_, SIGNAL(RateCurrentSong(int)), app_->playlist_manager(), SLOT(RateCurrentSong(int))); + connect(global_shortcuts_, SIGNAL(RemoveCurrentSong()), + app_->playlist_manager(), SLOT(RemoveCurrentSong())); // Fancy tabs connect(ui_->tabs, SIGNAL(ModeChanged(FancyTabWidget::Mode)),