ask if one really wants to clear main playlist (disabled by default)

This commit is contained in:
Andrzej Rybczak
2009-08-24 00:36:37 +02:00
parent f1389103c2
commit 195d8b4e34
5 changed files with 43 additions and 25 deletions

View File

@@ -197,6 +197,8 @@
# #
#display_screens_numbers_on_start = "yes" #display_screens_numbers_on_start = "yes"
# #
#ask_before_clearing_main_playlist = "no"
#
#clock_display_seconds = "no" #clock_display_seconds = "no"
# #
#regular_expressions = "basic" (basic/extended) #regular_expressions = "basic" (basic/extended)

View File

@@ -186,6 +186,9 @@ If set to "playlist", Search engine will perform searching in current MPD playli
.B display_screens_numbers_on_start = yes/no .B display_screens_numbers_on_start = yes/no
If enabled, screens' names and their keybindings will be shown in header window until key is pressed, otherwise they won't be displayed at all. If enabled, screens' names and their keybindings will be shown in header window until key is pressed, otherwise they won't be displayed at all.
.TP .TP
.B ask_before_clearing_main_playlist = yes/no
If enabled, user will be asked if he really wants to clear the main playlist after pressing key responsible for that.
.TP
.B clock_display_seconds = yes/no .B clock_display_seconds = yes/no
If enabled, clock will display time in format hh:mm:ss, otherwise hh:mm. If enabled, clock will display time in format hh:mm:ss, otherwise hh:mm.
.TP .TP

View File

@@ -1694,6 +1694,35 @@ int main(int argc, char *argv[])
} }
else if (Keypressed(input, Key.Clear)) else if (Keypressed(input, Key.Clear))
{ {
if (myScreen == myPlaylistEditor && myPlaylistEditor->Playlists->Empty())
continue;
if (myScreen->ActiveWindow() == myPlaylistEditor->Content
|| Config.ask_before_clearing_main_playlist)
{
int in = 0;
LockStatusbar();
Statusbar() << "Do you really want to clear playlist";
if (myScreen->ActiveWindow() == myPlaylistEditor->Content)
*wFooter << " \"" << myPlaylistEditor->Playlists->Current() << "\"";
*wFooter << " ? [y/n] ";
curs_set(1);
do
{
TraceMpdStatus();
wFooter->ReadKey(in);
}
while (in != 'y' && in != 'n');
curs_set(0);
UnlockStatusbar();
if (in != 'y')
{
ShowMessage("Aborted!");
continue;
}
}
if (myPlaylist->Main()->isFiltered()) if (myPlaylist->Main()->isFiltered())
{ {
ShowMessage("Deleting filtered items..."); ShowMessage("Deleting filtered items...");
@@ -1705,38 +1734,16 @@ int main(int argc, char *argv[])
} }
else else
{ {
if (myScreen == myPlaylistEditor && myPlaylistEditor->Playlists->Empty()) if (myScreen->ActiveWindow() == myPlaylistEditor->Content)
continue;
int in = 0;
if (myScreen == myPlaylistEditor)
{ {
LockStatusbar(); Mpd.ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current()));
Statusbar() << "Do you really want to clear playlist \"" << myPlaylistEditor->Playlists->Current() << "\" ? [y/n] "; myPlaylistEditor->Content->Clear(0);
curs_set(1);
do
{
TraceMpdStatus();
wFooter->ReadKey(in);
}
while (in != 'y' && in != 'n');
curs_set(0);
UnlockStatusbar();
if (in == 'y')
{
Mpd.ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current()));
myPlaylistEditor->Content->Clear(0);
}
else
ShowMessage("Aborted!");
} }
else else
{ {
ShowMessage("Clearing playlist..."); ShowMessage("Clearing playlist...");
Mpd.ClearPlaylist(); Mpd.ClearPlaylist();
} }
if (myScreen != myPlaylistEditor || in == 'y')
ShowMessage("Playlist cleared!");
} }
// if playlist is cleared, items list have to be updated, but this // if playlist is cleared, items list have to be updated, but this
// can be blocked if new song was added to playlist less than one // can be blocked if new song was added to playlist less than one

View File

@@ -295,6 +295,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.use_cyclic_scrolling = false; conf.use_cyclic_scrolling = false;
conf.allow_physical_files_deletion = false; conf.allow_physical_files_deletion = false;
conf.allow_physical_directories_deletion = false; conf.allow_physical_directories_deletion = false;
conf.ask_before_clearing_main_playlist = false;
conf.mouse_support = true; conf.mouse_support = true;
conf.new_design = false; conf.new_design = false;
conf.set_window_title = true; conf.set_window_title = true;
@@ -742,6 +743,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
{ {
conf.allow_physical_directories_deletion = v == "yes"; conf.allow_physical_directories_deletion = v == "yes";
} }
else if (cl.find("ask_before_clearing_main_playlist") != std::string::npos)
{
conf.ask_before_clearing_main_playlist = v == "yes";
}
else if (cl.find("mouse_support") != std::string::npos) else if (cl.find("mouse_support") != std::string::npos)
{ {
conf.mouse_support = v == "yes"; conf.mouse_support = v == "yes";

View File

@@ -190,6 +190,7 @@ struct ncmpcpp_config
bool use_cyclic_scrolling; bool use_cyclic_scrolling;
bool allow_physical_files_deletion; bool allow_physical_files_deletion;
bool allow_physical_directories_deletion; bool allow_physical_directories_deletion;
bool ask_before_clearing_main_playlist;
bool mouse_support; bool mouse_support;
bool new_design; bool new_design;