Add -q,--stop-after-current commandline flag

This commit is contained in:
René Tronsgaard Rasmussen 2016-03-18 20:21:34 +01:00
parent 25326b4f4a
commit 8e70046e4b
3 changed files with 35 additions and 25 deletions

View File

@ -42,30 +42,31 @@ const char* CommandlineOptions::kHelpText =
" -t, --play-pause %6\n" " -t, --play-pause %6\n"
" -u, --pause %7\n" " -u, --pause %7\n"
" -s, --stop %8\n" " -s, --stop %8\n"
" -r, --previous %9\n" " -q, --stop-after-current %9\n"
" -f, --next %10\n" " -r, --previous %10\n"
" -v, --volume <value> %11\n" " -f, --next %11\n"
" --volume-up %12\n" " -v, --volume <value> %12\n"
" --volume-down %13\n" " --volume-up %13\n"
" --volume-increase-by %14\n" " --volume-down %14\n"
" --volume-decrease-by %15\n" " --volume-increase-by %15\n"
" --seek-to <seconds> %16\n" " --volume-decrease-by %16\n"
" --seek-by <seconds> %17\n" " --seek-to <seconds> %17\n"
" --restart-or-previous %18\n" " --seek-by <seconds> %18\n"
" --restart-or-previous %19\n"
"\n" "\n"
"%19:\n" "%20:\n"
" -a, --append %20\n" " -a, --append %21\n"
" -l, --load %21\n" " -l, --load %22\n"
" -k, --play-track <n> %22\n" " -k, --play-track <n> %23\n"
"\n" "\n"
"%23:\n" "%24:\n"
" -o, --show-osd %24\n" " -o, --show-osd %25\n"
" -y, --toggle-pretty-osd %25\n" " -y, --toggle-pretty-osd %26\n"
" -g, --language <lang> %26\n" " -g, --language <lang> %27\n"
" --quiet %27\n" " --quiet %28\n"
" --verbose %28\n" " --verbose %29\n"
" --log-levels <levels> %29\n" " --log-levels <levels> %30\n"
" --version %30\n"; " --version %31\n";
const char* CommandlineOptions::kVersionText = "Clementine %1"; const char* CommandlineOptions::kVersionText = "Clementine %1";
@ -111,6 +112,7 @@ bool CommandlineOptions::Parse() {
{"play-pause", no_argument, 0, 't'}, {"play-pause", no_argument, 0, 't'},
{"pause", no_argument, 0, 'u'}, {"pause", no_argument, 0, 'u'},
{"stop", no_argument, 0, 's'}, {"stop", no_argument, 0, 's'},
{"stop-after-current", no_argument, 0, 'q'},
{"previous", no_argument, 0, 'r'}, {"previous", no_argument, 0, 'r'},
{"next", no_argument, 0, 'f'}, {"next", no_argument, 0, 'f'},
{"volume", required_argument, 0, 'v'}, {"volume", required_argument, 0, 'v'},
@ -136,7 +138,7 @@ bool CommandlineOptions::Parse() {
// Parse the arguments // Parse the arguments
bool ok = false; bool ok = false;
forever { forever {
int c = getopt_long(argc_, argv_, "hptusrfv:alk:oyg:", kOptions, nullptr); int c = getopt_long(argc_, argv_, "hptusqrfv:alk:oyg:", kOptions, nullptr);
// End of the options // End of the options
if (c == -1) break; if (c == -1) break;
@ -150,8 +152,9 @@ bool CommandlineOptions::Parse() {
tr("Start the playlist currently playing"), tr("Start the playlist currently playing"),
tr("Play if stopped, pause if playing"), tr("Play if stopped, pause if playing"),
tr("Pause playback"), tr("Stop playback"), tr("Pause playback"), tr("Stop playback"),
tr("Skip backwards in playlist")) tr("Stop playback after current track"))
.arg(tr("Skip forwards in playlist"), .arg(tr("Skip backwards in playlist"),
tr("Skip forwards in playlist"),
tr("Set the volume to <value> percent"), tr("Set the volume to <value> percent"),
tr("Increase the volume by 4%"), tr("Increase the volume by 4%"),
tr("Decrease the volume by 4%"), tr("Decrease the volume by 4%"),
@ -191,6 +194,9 @@ bool CommandlineOptions::Parse() {
case 's': case 's':
player_action_ = Player_Stop; player_action_ = Player_Stop;
break; break;
case 'q':
player_action_ = Player_StopAfterCurrent;
break;
case 'r': case 'r':
player_action_ = Player_Previous; player_action_ = Player_Previous;
break; break;

View File

@ -54,6 +54,7 @@ class CommandlineOptions {
Player_Previous = 5, Player_Previous = 5,
Player_Next = 6, Player_Next = 6,
Player_RestartOrPrevious = 7, Player_RestartOrPrevious = 7,
Player_StopAfterCurrent = 8,
}; };
bool Parse(); bool Parse();

View File

@ -2116,6 +2116,9 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions& options) {
case CommandlineOptions::Player_Stop: case CommandlineOptions::Player_Stop:
app_->player()->Stop(); app_->player()->Stop();
break; break;
case CommandlineOptions::Player_StopAfterCurrent:
app_->player()->StopAfterCurrent();
break;
case CommandlineOptions::Player_Previous: case CommandlineOptions::Player_Previous:
app_->player()->Previous(); app_->player()->Previous();
break; break;