From 8e70046e4b4ebb527115289ace3d1317cd6b81c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Tronsgaard=20Rasmussen?= Date: Fri, 18 Mar 2016 20:21:34 +0100 Subject: [PATCH] Add -q,--stop-after-current commandline flag --- src/core/commandlineoptions.cpp | 56 ++++++++++++++++++--------------- src/core/commandlineoptions.h | 1 + src/ui/mainwindow.cpp | 3 ++ 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/core/commandlineoptions.cpp b/src/core/commandlineoptions.cpp index 58d4a89cc..bd8f7ceff 100644 --- a/src/core/commandlineoptions.cpp +++ b/src/core/commandlineoptions.cpp @@ -42,30 +42,31 @@ const char* CommandlineOptions::kHelpText = " -t, --play-pause %6\n" " -u, --pause %7\n" " -s, --stop %8\n" - " -r, --previous %9\n" - " -f, --next %10\n" - " -v, --volume %11\n" - " --volume-up %12\n" - " --volume-down %13\n" - " --volume-increase-by %14\n" - " --volume-decrease-by %15\n" - " --seek-to %16\n" - " --seek-by %17\n" - " --restart-or-previous %18\n" + " -q, --stop-after-current %9\n" + " -r, --previous %10\n" + " -f, --next %11\n" + " -v, --volume %12\n" + " --volume-up %13\n" + " --volume-down %14\n" + " --volume-increase-by %15\n" + " --volume-decrease-by %16\n" + " --seek-to %17\n" + " --seek-by %18\n" + " --restart-or-previous %19\n" "\n" - "%19:\n" - " -a, --append %20\n" - " -l, --load %21\n" - " -k, --play-track %22\n" + "%20:\n" + " -a, --append %21\n" + " -l, --load %22\n" + " -k, --play-track %23\n" "\n" - "%23:\n" - " -o, --show-osd %24\n" - " -y, --toggle-pretty-osd %25\n" - " -g, --language %26\n" - " --quiet %27\n" - " --verbose %28\n" - " --log-levels %29\n" - " --version %30\n"; + "%24:\n" + " -o, --show-osd %25\n" + " -y, --toggle-pretty-osd %26\n" + " -g, --language %27\n" + " --quiet %28\n" + " --verbose %29\n" + " --log-levels %30\n" + " --version %31\n"; const char* CommandlineOptions::kVersionText = "Clementine %1"; @@ -111,6 +112,7 @@ bool CommandlineOptions::Parse() { {"play-pause", no_argument, 0, 't'}, {"pause", no_argument, 0, 'u'}, {"stop", no_argument, 0, 's'}, + {"stop-after-current", no_argument, 0, 'q'}, {"previous", no_argument, 0, 'r'}, {"next", no_argument, 0, 'f'}, {"volume", required_argument, 0, 'v'}, @@ -136,7 +138,7 @@ bool CommandlineOptions::Parse() { // Parse the arguments bool ok = false; 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 if (c == -1) break; @@ -150,8 +152,9 @@ bool CommandlineOptions::Parse() { tr("Start the playlist currently playing"), tr("Play if stopped, pause if playing"), tr("Pause playback"), tr("Stop playback"), - tr("Skip backwards in playlist")) - .arg(tr("Skip forwards in playlist"), + tr("Stop playback after current track")) + .arg(tr("Skip backwards in playlist"), + tr("Skip forwards in playlist"), tr("Set the volume to percent"), tr("Increase the volume by 4%"), tr("Decrease the volume by 4%"), @@ -191,6 +194,9 @@ bool CommandlineOptions::Parse() { case 's': player_action_ = Player_Stop; break; + case 'q': + player_action_ = Player_StopAfterCurrent; + break; case 'r': player_action_ = Player_Previous; break; diff --git a/src/core/commandlineoptions.h b/src/core/commandlineoptions.h index 7b807dfc3..a2202c1f4 100644 --- a/src/core/commandlineoptions.h +++ b/src/core/commandlineoptions.h @@ -54,6 +54,7 @@ class CommandlineOptions { Player_Previous = 5, Player_Next = 6, Player_RestartOrPrevious = 7, + Player_StopAfterCurrent = 8, }; bool Parse(); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 3fedf678a..a1d74d859 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -2116,6 +2116,9 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions& options) { case CommandlineOptions::Player_Stop: app_->player()->Stop(); break; + case CommandlineOptions::Player_StopAfterCurrent: + app_->player()->StopAfterCurrent(); + break; case CommandlineOptions::Player_Previous: app_->player()->Previous(); break;