@@ -580,7 +580,7 @@ int Playlist::previous_row(const bool ignore_repeat_track) const {
|
||||
|
||||
}
|
||||
|
||||
void Playlist::set_current_row(const int i, const bool is_stopping) {
|
||||
void Playlist::set_current_row(const int i, const AutoScroll autoscroll, const bool is_stopping) {
|
||||
|
||||
QModelIndex old_current_item_index = current_item_index_;
|
||||
|
||||
@@ -631,7 +631,7 @@ void Playlist::set_current_row(const int i, const bool is_stopping) {
|
||||
}
|
||||
|
||||
if (current_item_index_.isValid() && !is_stopping) {
|
||||
InformOfCurrentSongChange();
|
||||
InformOfCurrentSongChange(autoscroll);
|
||||
}
|
||||
|
||||
if (current_item_index_.isValid()) {
|
||||
@@ -927,7 +927,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const
|
||||
undo_stack_->push(new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue, enqueue_next));
|
||||
}
|
||||
|
||||
if (play_now) emit PlayRequested(index(start, 0));
|
||||
if (play_now) emit PlayRequested(index(start, 0), AutoScroll_Maybe);
|
||||
|
||||
}
|
||||
|
||||
@@ -1507,7 +1507,7 @@ void Playlist::SetStreamMetadata(const QUrl &url, const Song &song, const bool m
|
||||
}
|
||||
else {
|
||||
update_scrobble_point = true;
|
||||
InformOfCurrentSongChange();
|
||||
InformOfCurrentSongChange(AutoScroll_Never);
|
||||
}
|
||||
|
||||
if (update_scrobble_point) UpdateScrobblePoint();
|
||||
@@ -1613,7 +1613,7 @@ void Playlist::ReloadItems(const QList<int> &rows) {
|
||||
item->Reload();
|
||||
|
||||
if (row == current_row()) {
|
||||
InformOfCurrentSongChange();
|
||||
InformOfCurrentSongChange(AutoScroll_Never);
|
||||
}
|
||||
else {
|
||||
emit dataChanged(index(row, 0), index(row, ColumnCount - 1));
|
||||
@@ -1829,7 +1829,7 @@ void Playlist::ItemChanged(PlaylistItemPtr item) {
|
||||
|
||||
}
|
||||
|
||||
void Playlist::InformOfCurrentSongChange() {
|
||||
void Playlist::InformOfCurrentSongChange(const AutoScroll autoscroll) {
|
||||
|
||||
emit dataChanged(index(current_item_index_.row(), 0), index(current_item_index_.row(), ColumnCount - 1));
|
||||
|
||||
@@ -1837,6 +1837,7 @@ void Playlist::InformOfCurrentSongChange() {
|
||||
const Song metadata(current_item_metadata());
|
||||
if (metadata.is_valid()) {
|
||||
emit CurrentSongChanged(metadata);
|
||||
emit MaybeAutoscroll(autoscroll);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -145,6 +145,12 @@ class Playlist : public QAbstractListModel {
|
||||
Path_Ask_User, // Only used in preferences: to ask user which of the previous values he wants to use.
|
||||
};
|
||||
|
||||
enum AutoScroll {
|
||||
AutoScroll_Never,
|
||||
AutoScroll_Maybe,
|
||||
AutoScroll_Always
|
||||
};
|
||||
|
||||
static const char *kCddaMimeType;
|
||||
static const char *kRowsMimetype;
|
||||
static const char *kPlayNowMimetype;
|
||||
@@ -250,7 +256,7 @@ class Playlist : public QAbstractListModel {
|
||||
|
||||
void StopAfter(const int row);
|
||||
void ReloadItems(const QList<int> &rows);
|
||||
void InformOfCurrentSongChange();
|
||||
void InformOfCurrentSongChange(const AutoScroll autoscroll);
|
||||
|
||||
// Registers an object which will get notifications when new songs are about to be inserted into this playlist.
|
||||
void AddSongInsertVetoListener(SongInsertVetoListener *listener);
|
||||
@@ -279,7 +285,7 @@ class Playlist : public QAbstractListModel {
|
||||
static bool ComparePathDepths(Qt::SortOrder, PlaylistItemPtr, PlaylistItemPtr);
|
||||
|
||||
public slots:
|
||||
void set_current_row(const int i, const bool is_stopping = false);
|
||||
void set_current_row(const int i, const AutoScroll autoscroll = AutoScroll_Maybe, const bool is_stopping = false);
|
||||
void Paused();
|
||||
void Playing();
|
||||
void Stopped();
|
||||
@@ -309,7 +315,8 @@ class Playlist : public QAbstractListModel {
|
||||
void CurrentSongChanged(Song metadata);
|
||||
void SongMetadataChanged(Song metadata);
|
||||
void EditingFinished(QModelIndex idx);
|
||||
void PlayRequested(QModelIndex idx);
|
||||
void PlayRequested(QModelIndex idx, Playlist::AutoScroll autoscroll);
|
||||
void MaybeAutoscroll(Playlist::AutoScroll autoscroll);
|
||||
|
||||
// Signals that the underlying list of items was changed, meaning that something was added to it, removed from it or the ordering changed.
|
||||
void PlaylistChanged();
|
||||
|
||||
@@ -149,7 +149,7 @@ Playlist *PlaylistManager::AddPlaylist(const int id, const QString &name, const
|
||||
connect(ret, SIGNAL(PlaylistChanged()), SLOT(UpdateSummaryText()));
|
||||
connect(ret, SIGNAL(EditingFinished(QModelIndex)), SIGNAL(EditingFinished(QModelIndex)));
|
||||
connect(ret, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
connect(ret, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex)));
|
||||
connect(ret, SIGNAL(PlayRequested(QModelIndex, Playlist::AutoScroll)), SIGNAL(PlayRequested(QModelIndex, Playlist::AutoScroll)));
|
||||
connect(playlist_container_->view(), SIGNAL(ColumnAlignmentChanged(ColumnAlignmentMap)), ret, SLOT(SetColumnAlignment(ColumnAlignmentMap)));
|
||||
connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)), ret, SLOT(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)));
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class PlaylistManagerInterface : public QObject {
|
||||
// Signals that one of manager's playlists has changed (new items, new ordering etc.) - the argument shows which.
|
||||
void PlaylistChanged(Playlist *playlist);
|
||||
void EditingFinished(QModelIndex idx);
|
||||
void PlayRequested(QModelIndex idx);
|
||||
void PlayRequested(QModelIndex idx, Playlist::AutoScroll autoscroll);
|
||||
};
|
||||
|
||||
class PlaylistManager : public PlaylistManagerInterface {
|
||||
|
||||
@@ -266,7 +266,7 @@ void PlaylistView::SetItemDelegates() {
|
||||
void PlaylistView::SetPlaylist(Playlist *playlist) {
|
||||
|
||||
if (playlist_) {
|
||||
disconnect(playlist_, SIGNAL(CurrentSongChanged(Song)), this, SLOT(MaybeAutoscroll()));
|
||||
disconnect(playlist_, SIGNAL(MaybeAutoscroll(Playlist::AutoScroll)), this, SLOT(MaybeAutoscroll(Playlist::AutoScroll)));
|
||||
disconnect(playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed()));
|
||||
disconnect(playlist_, SIGNAL(QueueChanged()), this, SLOT(update()));
|
||||
}
|
||||
@@ -279,7 +279,7 @@ void PlaylistView::SetPlaylist(Playlist *playlist) {
|
||||
JumpToLastPlayedTrack();
|
||||
|
||||
connect(playlist_, SIGNAL(RestoreFinished()), SLOT(JumpToLastPlayedTrack()));
|
||||
connect(playlist_, SIGNAL(CurrentSongChanged(Song)), SLOT(MaybeAutoscroll()));
|
||||
connect(playlist_, SIGNAL(MaybeAutoscroll(Playlist::AutoScroll)), SLOT(MaybeAutoscroll(Playlist::AutoScroll)));
|
||||
connect(playlist_, SIGNAL(destroyed()), SLOT(PlaylistDestroyed()));
|
||||
connect(playlist_, SIGNAL(QueueChanged()), SLOT(update()));
|
||||
|
||||
@@ -530,7 +530,7 @@ void PlaylistView::showEvent(QShowEvent *) {
|
||||
if (currently_glowing_ && glow_enabled_)
|
||||
glow_timer_.start(1500 / kGlowIntensitySteps, this);
|
||||
|
||||
MaybeAutoscroll();
|
||||
MaybeAutoscroll(Playlist::AutoScroll_Maybe);
|
||||
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ void PlaylistView::keyPressEvent(QKeyEvent *event) {
|
||||
CopyCurrentSongToClipboard();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
if (currentIndex().isValid()) emit PlayItem(currentIndex());
|
||||
if (currentIndex().isValid()) emit PlayItem(currentIndex(), Playlist::AutoScroll_Never);
|
||||
event->accept();
|
||||
}
|
||||
else if (event->modifiers() != Qt::ControlModifier && event->key() == Qt::Key_Space) {
|
||||
@@ -767,25 +767,26 @@ void PlaylistView::InhibitAutoscrollTimeout() {
|
||||
inhibit_autoscroll_ = false;
|
||||
}
|
||||
|
||||
void PlaylistView::MaybeAutoscroll() {
|
||||
if (!inhibit_autoscroll_) JumpToCurrentlyPlayingTrack();
|
||||
void PlaylistView::MaybeAutoscroll(const Playlist::AutoScroll autoscroll) {
|
||||
if (autoscroll == Playlist::AutoScroll_Always || (autoscroll == Playlist::AutoScroll_Maybe && !inhibit_autoscroll_)) JumpToCurrentlyPlayingTrack();
|
||||
}
|
||||
|
||||
void PlaylistView::JumpToCurrentlyPlayingTrack() {
|
||||
|
||||
Q_ASSERT(playlist_);
|
||||
|
||||
// Usage of the "Jump to the currently playing track" action shall enable autoscroll
|
||||
inhibit_autoscroll_ = false;
|
||||
|
||||
if (playlist_->current_row() == -1) return;
|
||||
|
||||
QModelIndex current = playlist_->proxy()->mapFromSource(playlist_->index(playlist_->current_row(), 0));
|
||||
if (!current.isValid()) return;
|
||||
|
||||
currently_autoscrolling_ = true;
|
||||
if (visibleRegion().boundingRect().contains(visualRect(current))) return;
|
||||
|
||||
// Usage of the "Jump to the currently playing track" action shall enable autoscroll
|
||||
inhibit_autoscroll_ = false;
|
||||
|
||||
// Scroll to the item
|
||||
currently_autoscrolling_ = true;
|
||||
scrollTo(current, QAbstractItemView::PositionAtCenter);
|
||||
currently_autoscrolling_ = false;
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ class PlaylistView : public QTreeView {
|
||||
void edit(const QModelIndex &idx) { return QAbstractItemView::edit(idx); }
|
||||
|
||||
signals:
|
||||
void PlayItem(QModelIndex idx);
|
||||
void PlayPause();
|
||||
void PlayItem(QModelIndex idx, Playlist::AutoScroll autoscroll);
|
||||
void PlayPause(Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Never);
|
||||
void RightClicked(QPoint global_pos, QModelIndex idx);
|
||||
void SeekForward();
|
||||
void SeekBackward();
|
||||
@@ -164,7 +164,7 @@ class PlaylistView : public QTreeView {
|
||||
|
||||
private slots:
|
||||
void InhibitAutoscrollTimeout();
|
||||
void MaybeAutoscroll();
|
||||
void MaybeAutoscroll(const Playlist::AutoScroll autoscroll);
|
||||
void InvalidateCachedCurrentPixmap();
|
||||
void PlaylistDestroyed();
|
||||
void StretchChanged(const bool stretch);
|
||||
|
||||
Reference in New Issue
Block a user