mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
parent
bcaeac7a02
commit
7381f381e6
@ -46,8 +46,9 @@ const char* CommandlineOptions::kHelpText =
|
||||
" --volume-decrease-by %15\n"
|
||||
" --seek-to <seconds> %16\n"
|
||||
" --seek-by <seconds> %17\n"
|
||||
" --restart-or-previous %18\n"
|
||||
"\n"
|
||||
"%18:\n"
|
||||
"%19:\n"
|
||||
" -a, --append %20\n"
|
||||
" -l, --load %21\n"
|
||||
" -k, --play-track <n> %22\n"
|
||||
@ -118,6 +119,7 @@ bool CommandlineOptions::Parse() {
|
||||
{"volume-decrease-by", required_argument, 0, VolumeDecreaseBy},
|
||||
{"seek-to", required_argument, 0, SeekTo},
|
||||
{"seek-by", required_argument, 0, SeekBy},
|
||||
{"restart-or-previous", no_argument, 0, RestartOrPrevious},
|
||||
|
||||
{"append", no_argument, 0, 'a'},
|
||||
{"load", no_argument, 0, 'l'},
|
||||
@ -159,6 +161,7 @@ bool CommandlineOptions::Parse() {
|
||||
tr("Decrease the volume by <value> percent")).arg(
|
||||
tr("Seek the currently playing track to an absolute position"),
|
||||
tr("Seek the currently playing track by a relative amount"),
|
||||
tr("Restart the track, or play the previous track if within 8 seconds of start."),
|
||||
tr("Playlist options"),
|
||||
tr("Append files/URLs to the playlist"),
|
||||
tr("Loads files/URLs, replacing current playlist"),
|
||||
@ -222,6 +225,10 @@ bool CommandlineOptions::Parse() {
|
||||
if (!ok) seek_by_ = 0;
|
||||
break;
|
||||
|
||||
case RestartOrPrevious:
|
||||
player_action_ = Player_RestartOrPrevious;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
play_track_at_ = QString(optarg).toInt(&ok);
|
||||
if (!ok) play_track_at_ = -1;
|
||||
|
@ -46,6 +46,7 @@ class CommandlineOptions {
|
||||
Player_Stop = 4,
|
||||
Player_Previous = 5,
|
||||
Player_Next = 6,
|
||||
Player_RestartOrPrevious = 7,
|
||||
};
|
||||
|
||||
bool Parse();
|
||||
@ -81,7 +82,8 @@ class CommandlineOptions {
|
||||
LogLevels,
|
||||
Version,
|
||||
VolumeIncreaseBy,
|
||||
VolumeDecreaseBy
|
||||
VolumeDecreaseBy,
|
||||
RestartOrPrevious
|
||||
};
|
||||
|
||||
QString tr(const char* source_text);
|
||||
|
@ -241,6 +241,13 @@ void Player::PlayPause() {
|
||||
}
|
||||
}
|
||||
|
||||
void Player::RestartOrPrevious() {
|
||||
if (engine_->position_nanosec() < (qint64)8*1000*1000*1000)
|
||||
return Previous();
|
||||
|
||||
SeekTo(0);
|
||||
}
|
||||
|
||||
void Player::Stop() {
|
||||
engine_->Stop();
|
||||
app_->playlist_manager()->active()->set_current_row(-1);
|
||||
|
@ -59,6 +59,7 @@ public slots:
|
||||
// If there's currently a song playing, pause it, otherwise play the track
|
||||
// that was playing last, or the first one on the playlist
|
||||
virtual void PlayPause() = 0;
|
||||
virtual void RestartOrPrevious() = 0;
|
||||
|
||||
// Skips this track. Might load more of the current radio station.
|
||||
virtual void Next() = 0;
|
||||
@ -126,6 +127,7 @@ public slots:
|
||||
|
||||
void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle);
|
||||
void PlayPause();
|
||||
void RestartOrPrevious();
|
||||
void Next();
|
||||
void Previous();
|
||||
void SetVolume(int value);
|
||||
|
@ -1709,6 +1709,9 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
case CommandlineOptions::Player_Next:
|
||||
app_->player()->Next();
|
||||
break;
|
||||
case CommandlineOptions::Player_RestartOrPrevious:
|
||||
app_->player()->RestartOrPrevious();
|
||||
break;
|
||||
|
||||
case CommandlineOptions::Player_None:
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user