From a4160790cf2acc57335e6cf1f4a0d880befdfdb9 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 6 Apr 2013 13:42:43 +0200 Subject: [PATCH] settings: add volume_change_step configuration option --- doc/config | 2 ++ doc/ncmpcpp.1 | 3 +++ src/actions.cpp | 6 ++++-- src/settings.cpp | 6 ++++++ src/settings.h | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/config b/doc/config index 0b3ed85b..79b2a5f1 100644 --- a/doc/config +++ b/doc/config @@ -301,6 +301,8 @@ # #seek_time = "1" # +#volume_change_step = "1" +# #autocenter_mode = "no" # #centered_cursor = "no" diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 07363063..b230b73a 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -108,6 +108,9 @@ If you use encoding other than utf8, set it in order to handle utf8 encoded stri .B seek_time = SECONDS Base seek time to begin with. .TP +.B volume_change_step = NUMBER +Number of percents volume has to be increased/decreased by in volume_up/volume_down. +.TP .B playlist_disable_highlight_delay = SECONDS Delay for highlighting playlist since the last key was pressed. If set to 0, highlighting never fades away. .TP diff --git a/src/actions.cpp b/src/actions.cpp index f5deaabe..e6e4882b 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -615,12 +615,14 @@ void SlaveScreen::run() void VolumeUp::run() { - Mpd.SetVolume(Mpd.GetVolume()+1); + int volume = std::min(Mpd.GetVolume()+Config.volume_change_step, 100); + Mpd.SetVolume(volume); } void VolumeDown::run() { - Mpd.SetVolume(Mpd.GetVolume()-1); + int volume = std::max(Mpd.GetVolume()-Config.volume_change_step, 0); + Mpd.SetVolume(volume); } bool DeletePlaylistItems::canBeRun() const diff --git a/src/settings.cpp b/src/settings.cpp index ad73ed7a..72f2bbea 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -224,6 +224,7 @@ void Configuration::SetDefaults() mpd_connection_timeout = 15; crossfade_time = 5; seek_time = 1; + volume_change_step = 1; playlist_disable_highlight_delay = 5; message_delay_time = 4; lyrics_db = 0; @@ -367,6 +368,11 @@ void Configuration::Read() if (boost::lexical_cast(v) > 0) seek_time = boost::lexical_cast(v); } + else if (name == "volume_change_step") + { + if (boost::lexical_cast(v) > 0) + volume_change_step = boost::lexical_cast(v); + } else if (name == "playlist_disable_highlight_delay") { if (boost::lexical_cast(v) >= 0) diff --git a/src/settings.h b/src/settings.h index 5b67dd75..22f22b54 100644 --- a/src/settings.h +++ b/src/settings.h @@ -189,6 +189,7 @@ struct Configuration int mpd_connection_timeout; int crossfade_time; int seek_time; + int volume_change_step; int playlist_disable_highlight_delay; int message_delay_time; int lyrics_db;