actions: attempt to crop playlists only if their length is > 1
This commit is contained in:
@@ -1728,17 +1728,19 @@ void AddSelectedItems::run()
|
|||||||
|
|
||||||
void CropMainPlaylist::run()
|
void CropMainPlaylist::run()
|
||||||
{
|
{
|
||||||
|
auto &w = myPlaylist->main();
|
||||||
|
// cropping doesn't make sense in this case
|
||||||
|
if (w.size() <= 1)
|
||||||
|
return;
|
||||||
bool yes = true;
|
bool yes = true;
|
||||||
if (Config.ask_before_clearing_playlists)
|
if (Config.ask_before_clearing_playlists)
|
||||||
yes = askYesNoQuestion("Do you really want to crop main playlist?", Status::trace);
|
yes = askYesNoQuestion("Do you really want to crop main playlist?", Status::trace);
|
||||||
if (yes)
|
if (yes)
|
||||||
{
|
{
|
||||||
Statusbar::print("Cropping playlist...");
|
Statusbar::print("Cropping playlist...");
|
||||||
auto &w = myPlaylist->main();
|
selectCurrentIfNoneSelected(w);
|
||||||
// if no item is selected, select the current one
|
|
||||||
if (!w.empty() && !hasSelected(w.begin(), w.end()))
|
|
||||||
w.current().setSelected(true);
|
|
||||||
cropPlaylist(w, boost::bind(&MPD::Connection::Delete, _1, _2));
|
cropPlaylist(w, boost::bind(&MPD::Connection::Delete, _1, _2));
|
||||||
|
Statusbar::print("Playlist cropped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1749,6 +1751,10 @@ bool CropPlaylist::canBeRun() const
|
|||||||
|
|
||||||
void CropPlaylist::run()
|
void CropPlaylist::run()
|
||||||
{
|
{
|
||||||
|
auto &w = myPlaylistEditor->Content;
|
||||||
|
// cropping doesn't make sense in this case
|
||||||
|
if (w.size() <= 1)
|
||||||
|
return;
|
||||||
assert(!myPlaylistEditor->Playlists.empty());
|
assert(!myPlaylistEditor->Playlists.empty());
|
||||||
std::string playlist = myPlaylistEditor->Playlists.current().value();
|
std::string playlist = myPlaylistEditor->Playlists.current().value();
|
||||||
bool yes = true;
|
bool yes = true;
|
||||||
@@ -1759,9 +1765,9 @@ void CropPlaylist::run()
|
|||||||
);
|
);
|
||||||
if (yes)
|
if (yes)
|
||||||
{
|
{
|
||||||
auto delete_fun = boost::bind(&MPD::Connection::PlaylistDelete, _1, playlist, _2);
|
selectCurrentIfNoneSelected(w);
|
||||||
Statusbar::printf("Cropping playlist \"%1%\"...", playlist);
|
Statusbar::printf("Cropping playlist \"%1%\"...", playlist);
|
||||||
cropPlaylist(myPlaylistEditor->Content, delete_fun);
|
cropPlaylist(w, boost::bind(&MPD::Connection::PlaylistDelete, _1, playlist, _2));
|
||||||
Statusbar::printf("Playlist \"%1%\" cropped", playlist);
|
Statusbar::printf("Playlist \"%1%\" cropped", playlist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user