When pressing the Previous button in Repeat Track mode, go to the previous track instead of repeating the current one. Fixes issue 2897
This commit is contained in:
parent
75a057a47d
commit
1aec4a4c7f
@ -248,14 +248,20 @@ void Player::Stop() {
|
||||
}
|
||||
|
||||
void Player::Previous() {
|
||||
int i = app_->playlist_manager()->active()->previous_row();
|
||||
PreviousItem(Engine::Manual);
|
||||
}
|
||||
|
||||
void Player::PreviousItem(Engine::TrackChangeFlags change) {
|
||||
const bool ignore_repeat_track = change & Engine::Manual;
|
||||
|
||||
int i = app_->playlist_manager()->active()->previous_row(ignore_repeat_track);
|
||||
app_->playlist_manager()->active()->set_current_row(i);
|
||||
if (i == -1) {
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
PlayAt(i, Engine::Manual, false);
|
||||
PlayAt(i, change, false);
|
||||
}
|
||||
|
||||
void Player::EngineStateChanged(Engine::State state) {
|
||||
|
@ -152,6 +152,7 @@ public slots:
|
||||
// Play the next item on the playlist - disregarding radio stations like
|
||||
// last.fm that might have more tracks.
|
||||
void NextItem(Engine::TrackChangeFlags change);
|
||||
void PreviousItem(Engine::TrackChangeFlags change);
|
||||
|
||||
void NextInternal(Engine::TrackChangeFlags);
|
||||
|
||||
|
@ -443,14 +443,14 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const {
|
||||
return virtual_items_.count();
|
||||
}
|
||||
|
||||
int Playlist::PreviousVirtualIndex(int i) const {
|
||||
int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const {
|
||||
PlaylistSequence::RepeatMode repeat_mode = playlist_sequence_->repeat_mode();
|
||||
PlaylistSequence::ShuffleMode shuffle_mode = playlist_sequence_->shuffle_mode();
|
||||
bool album_only = repeat_mode == PlaylistSequence::Repeat_Album ||
|
||||
shuffle_mode == PlaylistSequence::Shuffle_InsideAlbum;
|
||||
|
||||
// This one's easy - if we have to repeat the current track then just return i
|
||||
if (repeat_mode == PlaylistSequence::Repeat_Track) {
|
||||
if (repeat_mode == PlaylistSequence::Repeat_Track && !ignore_repeat_track) {
|
||||
if (!FilterContainsVirtualIndex(i))
|
||||
return -1;
|
||||
return i;
|
||||
@ -517,8 +517,8 @@ int Playlist::next_row(bool ignore_repeat_track) const {
|
||||
return virtual_items_[next_virtual_index];
|
||||
}
|
||||
|
||||
int Playlist::previous_row() const {
|
||||
int prev_virtual_index = PreviousVirtualIndex(current_virtual_index_);
|
||||
int Playlist::previous_row(bool ignore_repeat_track) const {
|
||||
int prev_virtual_index = PreviousVirtualIndex(current_virtual_index_,ignore_repeat_track);
|
||||
if (prev_virtual_index < 0) {
|
||||
// We've gone off the beginning of the playlist.
|
||||
|
||||
@ -530,7 +530,7 @@ int Playlist::previous_row() const {
|
||||
break;
|
||||
|
||||
default:
|
||||
prev_virtual_index = PreviousVirtualIndex(virtual_items_.count());
|
||||
prev_virtual_index = PreviousVirtualIndex(virtual_items_.count(),ignore_repeat_track);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ class Playlist : public QAbstractListModel {
|
||||
int current_row() const;
|
||||
int last_played_row() const;
|
||||
int next_row(bool ignore_repeat_track = false) const;
|
||||
int previous_row() const;
|
||||
int previous_row(bool ignore_repeat_track = false) const;
|
||||
|
||||
const QModelIndex current_index() const;
|
||||
|
||||
@ -308,7 +308,7 @@ class Playlist : public QAbstractListModel {
|
||||
void SetCurrentIsPaused(bool paused);
|
||||
void UpdateScrobblePoint();
|
||||
int NextVirtualIndex(int i, bool ignore_repeat_track) const;
|
||||
int PreviousVirtualIndex(int i) const;
|
||||
int PreviousVirtualIndex(int i, bool ignore_repeat_track) const;
|
||||
bool FilterContainsVirtualIndex(int i) const;
|
||||
void TurnOnDynamicPlaylist(smart_playlists::GeneratorPtr gen);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user