Fix stop after track
Stop after track would cause now playing widget, OSD, and last.fm scrobbler to change to next track after stopping. This patch prevents set_current_row() from firing an event which triggers the track change.
This commit is contained in:
parent
b3ef8b0fe0
commit
416d06bb06
@ -190,15 +190,17 @@ void Player::NextItem(Engine::TrackChangeFlags change) {
|
|||||||
|
|
||||||
bool Player::HandleStopAfter() {
|
bool Player::HandleStopAfter() {
|
||||||
if (app_->playlist_manager()->active()->stop_after_current()) {
|
if (app_->playlist_manager()->active()->stop_after_current()) {
|
||||||
app_->playlist_manager()->active()->StopAfter(-1);
|
|
||||||
|
|
||||||
// Find what the next track would've been, and mark that one as current
|
// Find what the next track would've been, and mark that one as current
|
||||||
// so it plays next time the user presses Play.
|
// so it plays next time the user presses Play.
|
||||||
|
app_->playlist_manager()->active()->StopAfter(-2);
|
||||||
const int next_row = app_->playlist_manager()->active()->next_row();
|
const int next_row = app_->playlist_manager()->active()->next_row();
|
||||||
if (next_row != -1) {
|
if (next_row != -1) {
|
||||||
app_->playlist_manager()->active()->set_current_row(next_row);
|
app_->playlist_manager()->active()->set_current_row(next_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app_->playlist_manager()->active()->StopAfter(-1);
|
||||||
|
|
||||||
Stop();
|
Stop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@ Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager,
|
|||||||
favorite_(favorite),
|
favorite_(favorite),
|
||||||
current_is_paused_(false),
|
current_is_paused_(false),
|
||||||
current_virtual_index_(-1),
|
current_virtual_index_(-1),
|
||||||
|
is_stopping_next_(false),
|
||||||
is_shuffled_(false),
|
is_shuffled_(false),
|
||||||
scrobble_point_(-1),
|
scrobble_point_(-1),
|
||||||
lastfm_status_(LastFM_New),
|
lastfm_status_(LastFM_New),
|
||||||
@ -547,7 +548,6 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const {
|
|||||||
|
|
||||||
int Playlist::next_row(bool ignore_repeat_track) const {
|
int Playlist::next_row(bool ignore_repeat_track) const {
|
||||||
// Did we want to stop after this track?
|
// Did we want to stop after this track?
|
||||||
if (stop_after_.isValid() && current_row() == stop_after_.row()) return -1;
|
|
||||||
|
|
||||||
// Any queued items take priority
|
// Any queued items take priority
|
||||||
if (!queue_->is_empty()) {
|
if (!queue_->is_empty()) {
|
||||||
@ -629,8 +629,8 @@ void Playlist::set_current_row(int i) {
|
|||||||
old_current_item_index.sibling(
|
old_current_item_index.sibling(
|
||||||
old_current_item_index.row(), ColumnCount - 1));
|
old_current_item_index.row(), ColumnCount - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_item_index_.isValid()) {
|
if (current_item_index_.isValid() && !is_stopping_next_) {
|
||||||
InformOfCurrentSongChange();
|
InformOfCurrentSongChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1636,11 +1636,16 @@ PlaylistItemList Playlist::RemoveItemsWithoutUndo(int row, int count) {
|
|||||||
void Playlist::StopAfter(int row) {
|
void Playlist::StopAfter(int row) {
|
||||||
QModelIndex old_stop_after = stop_after_;
|
QModelIndex old_stop_after = stop_after_;
|
||||||
|
|
||||||
if ((stop_after_.isValid() && stop_after_.row() == row) || row == -1)
|
if ((stop_after_.isValid() && stop_after_.row() == row) || row == -1){
|
||||||
stop_after_ = QModelIndex();
|
stop_after_ = QModelIndex();
|
||||||
else
|
is_stopping_next_ = false;
|
||||||
|
} else if (row == -2) {
|
||||||
|
is_stopping_next_ = true;
|
||||||
|
} else{
|
||||||
stop_after_ = index(row, 0);
|
stop_after_ = index(row, 0);
|
||||||
|
is_stopping_next_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (old_stop_after.isValid())
|
if (old_stop_after.isValid())
|
||||||
emit dataChanged(
|
emit dataChanged(
|
||||||
old_stop_after,
|
old_stop_after,
|
||||||
|
@ -402,6 +402,8 @@ signals:
|
|||||||
QPersistentModelIndex stop_after_;
|
QPersistentModelIndex stop_after_;
|
||||||
bool current_is_paused_;
|
bool current_is_paused_;
|
||||||
int current_virtual_index_;
|
int current_virtual_index_;
|
||||||
|
|
||||||
|
bool is_stopping_next_;
|
||||||
|
|
||||||
bool is_shuffled_;
|
bool is_shuffled_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user