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