Merge pull request #6043 from TheUbuntuGuy/feature/mf.playnext
Add Play Next Option to Queue
This commit is contained in:
commit
776fb3830e
|
@ -28,11 +28,12 @@ class MimeData : public QMimeData {
|
|||
|
||||
public:
|
||||
MimeData(bool clear = false, bool play_now = false, bool enqueue = false,
|
||||
bool open_in_new_playlist = false)
|
||||
bool enqueue_next_now = false, bool open_in_new_playlist = false)
|
||||
: override_user_settings_(false),
|
||||
clear_first_(clear),
|
||||
play_now_(play_now),
|
||||
enqueue_now_(enqueue),
|
||||
enqueue_next_now_(enqueue_next_now),
|
||||
open_in_new_playlist_(open_in_new_playlist),
|
||||
name_for_new_playlist_(QString()),
|
||||
from_doubleclick_(false) {}
|
||||
|
@ -53,6 +54,10 @@ class MimeData : public QMimeData {
|
|||
// If this is set then the items are added to the queue after being inserted.
|
||||
bool enqueue_now_;
|
||||
|
||||
// If this is set then the items are added to the beginning of the queue after
|
||||
// being inserted.
|
||||
bool enqueue_next_now_;
|
||||
|
||||
// If this is set then the items are inserted into a newly created playlist.
|
||||
bool open_in_new_playlist_;
|
||||
|
||||
|
|
|
@ -392,6 +392,9 @@ void LibraryView::contextMenuEvent(QContextMenuEvent* e) {
|
|||
add_to_playlist_enqueue_ = context_menu_->addAction(
|
||||
IconLoader::Load("go-next", IconLoader::Base), tr("Queue track"), this,
|
||||
SLOT(AddToPlaylistEnqueue()));
|
||||
add_to_playlist_enqueue_next_ = context_menu_->addAction(
|
||||
IconLoader::Load("go-next", IconLoader::Base), tr("Play next"), this,
|
||||
SLOT(AddToPlaylistEnqueueNext()));
|
||||
context_menu_->addSeparator();
|
||||
search_for_this_ = context_menu_->addAction(
|
||||
IconLoader::Load("system-search", IconLoader::Base),
|
||||
|
@ -616,6 +619,14 @@ void LibraryView::AddToPlaylistEnqueue() {
|
|||
emit AddToPlaylistSignal(data);
|
||||
}
|
||||
|
||||
void LibraryView::AddToPlaylistEnqueueNext() {
|
||||
QMimeData* data = model()->mimeData(selectedIndexes());
|
||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||
mime_data->enqueue_next_now_ = true;
|
||||
}
|
||||
emit AddToPlaylistSignal(data);
|
||||
}
|
||||
|
||||
void LibraryView::OpenInNewPlaylist() {
|
||||
QMimeData* data = model()->mimeData(selectedIndexes());
|
||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||
|
|
|
@ -92,6 +92,7 @@ signals:
|
|||
void Load();
|
||||
void AddToPlaylist();
|
||||
void AddToPlaylistEnqueue();
|
||||
void AddToPlaylistEnqueueNext();
|
||||
void OpenInNewPlaylist();
|
||||
void Organise();
|
||||
void CopyToDevice();
|
||||
|
@ -131,6 +132,7 @@ signals:
|
|||
QAction* load_;
|
||||
QAction* add_to_playlist_;
|
||||
QAction* add_to_playlist_enqueue_;
|
||||
QAction* add_to_playlist_enqueue_next_;
|
||||
QAction* open_in_new_playlist_;
|
||||
QAction* organise_;
|
||||
QAction* copy_to_device_;
|
||||
|
|
|
@ -152,14 +152,14 @@ Playlist::~Playlist() {
|
|||
|
||||
template <typename T>
|
||||
void Playlist::InsertSongItems(const SongList& songs, int pos, bool play_now,
|
||||
bool enqueue) {
|
||||
bool enqueue, bool enqueue_next) {
|
||||
PlaylistItemList items;
|
||||
|
||||
for (const Song& song : songs) {
|
||||
items << PlaylistItemPtr(new T(song));
|
||||
}
|
||||
|
||||
InsertItems(items, pos, play_now, enqueue);
|
||||
InsertItems(items, pos, play_now, enqueue, enqueue_next);
|
||||
}
|
||||
|
||||
QVariant Playlist::headerData(int section, Qt::Orientation, int role) const {
|
||||
|
@ -703,7 +703,7 @@ void Playlist::InsertDynamicItems(int count) {
|
|||
connect(inserter, SIGNAL(PlayRequested(QModelIndex)),
|
||||
SIGNAL(PlayRequested(QModelIndex)));
|
||||
|
||||
inserter->Load(this, -1, false, false, dynamic_playlist_, count);
|
||||
inserter->Load(this, -1, false, false, false, dynamic_playlist_, count);
|
||||
}
|
||||
|
||||
Qt::ItemFlags Playlist::flags(const QModelIndex& index) const {
|
||||
|
@ -733,12 +733,14 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||
|
||||
bool play_now = false;
|
||||
bool enqueue_now = false;
|
||||
bool enqueue_next_now = false;
|
||||
if (const MimeData* mime_data = qobject_cast<const MimeData*>(data)) {
|
||||
if (mime_data->clear_first_) {
|
||||
Clear();
|
||||
}
|
||||
play_now = mime_data->play_now_;
|
||||
enqueue_now = mime_data->enqueue_now_;
|
||||
enqueue_next_now = mime_data->enqueue_next_now_;
|
||||
}
|
||||
|
||||
if (const SongMimeData* song_data = qobject_cast<const SongMimeData*>(data)) {
|
||||
|
@ -748,33 +750,35 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||
if (song_data->backend &&
|
||||
song_data->backend->songs_table() == Library::kSongsTable)
|
||||
InsertSongItems<LibraryPlaylistItem>(song_data->songs, row, play_now,
|
||||
enqueue_now);
|
||||
enqueue_now, enqueue_next_now);
|
||||
else if (song_data->backend &&
|
||||
song_data->backend->songs_table() == MagnatuneService::kSongsTable)
|
||||
InsertSongItems<MagnatunePlaylistItem>(song_data->songs, row, play_now,
|
||||
enqueue_now);
|
||||
enqueue_now, enqueue_next_now);
|
||||
else if (song_data->backend &&
|
||||
song_data->backend->songs_table() == JamendoService::kSongsTable)
|
||||
InsertSongItems<JamendoPlaylistItem>(song_data->songs, row, play_now,
|
||||
enqueue_now);
|
||||
enqueue_now, enqueue_next_now);
|
||||
else
|
||||
InsertSongItems<SongPlaylistItem>(song_data->songs, row, play_now,
|
||||
enqueue_now);
|
||||
enqueue_now, enqueue_next_now);
|
||||
} else if (const InternetMimeData* internet_data =
|
||||
qobject_cast<const InternetMimeData*>(data)) {
|
||||
// Dragged from the Internet pane
|
||||
InsertInternetItems(internet_data->model, internet_data->indexes, row,
|
||||
play_now, enqueue_now);
|
||||
play_now, enqueue_now, enqueue_next_now);
|
||||
} else if (const InternetSongMimeData* internet_song_data =
|
||||
qobject_cast<const InternetSongMimeData*>(data)) {
|
||||
InsertInternetItems(internet_song_data->service, internet_song_data->songs,
|
||||
row, play_now, enqueue_now);
|
||||
row, play_now, enqueue_now, enqueue_next_now);
|
||||
} else if (const GeneratorMimeData* generator_data =
|
||||
qobject_cast<const GeneratorMimeData*>(data)) {
|
||||
InsertSmartPlaylist(generator_data->generator_, row, play_now, enqueue_now);
|
||||
InsertSmartPlaylist(generator_data->generator_, row, play_now, enqueue_now,
|
||||
enqueue_next_now);
|
||||
} else if (const PlaylistItemMimeData* item_data =
|
||||
qobject_cast<const PlaylistItemMimeData*>(data)) {
|
||||
InsertItems(item_data->items_, row, play_now, enqueue_now);
|
||||
InsertItems(item_data->items_, row, play_now, enqueue_now,
|
||||
enqueue_next_now);
|
||||
} else if (data->hasFormat(kRowsMimetype)) {
|
||||
// Dragged from the playlist
|
||||
// Rearranging it is tricky...
|
||||
|
@ -809,7 +813,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||
if (items.count() > kUndoItemLimit) {
|
||||
// Too big to keep in the undo stack. Also clear the stack because it
|
||||
// might have been invalidated.
|
||||
InsertItemsWithoutUndo(items, row, false);
|
||||
InsertItemsWithoutUndo(items, row, false, false);
|
||||
undo_stack_->clear();
|
||||
} else {
|
||||
undo_stack_->push(
|
||||
|
@ -828,26 +832,27 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||
SongLoaderInserter* inserter = new SongLoaderInserter(
|
||||
task_manager_, library_, backend_->app()->player());
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
inserter->LoadAudioCD(this, row, play_now, enqueue_now);
|
||||
inserter->LoadAudioCD(this, row, play_now, enqueue_now, enqueue_next_now);
|
||||
} else if (data->hasUrls()) {
|
||||
// URL list dragged from the file list or some other app
|
||||
InsertUrls(data->urls(), row, play_now, enqueue_now);
|
||||
InsertUrls(data->urls(), row, play_now, enqueue_now, enqueue_next_now);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Playlist::InsertUrls(const QList<QUrl>& urls, int pos, bool play_now,
|
||||
bool enqueue) {
|
||||
bool enqueue, bool enqueue_next) {
|
||||
SongLoaderInserter* inserter = new SongLoaderInserter(
|
||||
task_manager_, library_, backend_->app()->player());
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
|
||||
inserter->Load(this, pos, play_now, enqueue, urls);
|
||||
inserter->Load(this, pos, play_now, enqueue, enqueue_next, urls);
|
||||
}
|
||||
|
||||
void Playlist::InsertSmartPlaylist(GeneratorPtr generator, int pos,
|
||||
bool play_now, bool enqueue) {
|
||||
bool play_now, bool enqueue,
|
||||
bool enqueue_next) {
|
||||
// Hack: If the generator hasn't got a library set then use the main one
|
||||
if (!generator->library()) {
|
||||
generator->set_library(library_);
|
||||
|
@ -857,7 +862,7 @@ void Playlist::InsertSmartPlaylist(GeneratorPtr generator, int pos,
|
|||
new GeneratorInserter(task_manager_, library_, this);
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
|
||||
inserter->Load(this, pos, play_now, enqueue, generator);
|
||||
inserter->Load(this, pos, play_now, enqueue, enqueue_next, generator);
|
||||
|
||||
if (generator->is_dynamic()) {
|
||||
TurnOnDynamicPlaylist(generator);
|
||||
|
@ -976,7 +981,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int>& dest_rows) {
|
|||
}
|
||||
|
||||
void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos,
|
||||
bool play_now, bool enqueue) {
|
||||
bool play_now, bool enqueue, bool enqueue_next) {
|
||||
if (itemsIn.isEmpty()) return;
|
||||
|
||||
PlaylistItemList items = itemsIn;
|
||||
|
@ -1026,18 +1031,18 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos,
|
|||
if (items.count() > kUndoItemLimit) {
|
||||
// Too big to keep in the undo stack. Also clear the stack because it
|
||||
// might have been invalidated.
|
||||
InsertItemsWithoutUndo(items, pos, enqueue);
|
||||
InsertItemsWithoutUndo(items, pos, enqueue, enqueue_next);
|
||||
undo_stack_->clear();
|
||||
} else {
|
||||
undo_stack_->push(
|
||||
new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue));
|
||||
undo_stack_->push(new PlaylistUndoCommands::InsertItems(
|
||||
this, items, pos, enqueue, enqueue_next));
|
||||
}
|
||||
|
||||
if (play_now) emit PlayRequested(index(start, 0));
|
||||
}
|
||||
|
||||
void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
|
||||
bool enqueue) {
|
||||
bool enqueue, bool enqueue_next) {
|
||||
if (items.isEmpty()) return;
|
||||
|
||||
const int start = pos == -1 ? items_.count() : pos;
|
||||
|
@ -1072,22 +1077,33 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
|
|||
queue_->ToggleTracks(indexes);
|
||||
}
|
||||
|
||||
if (enqueue_next) {
|
||||
QModelIndexList indexes;
|
||||
for (int i = start; i <= end; ++i) {
|
||||
indexes << index(i, 0);
|
||||
}
|
||||
queue_->InsertFirst(indexes);
|
||||
}
|
||||
|
||||
Save();
|
||||
ReshuffleIndices();
|
||||
}
|
||||
|
||||
void Playlist::InsertLibraryItems(const SongList& songs, int pos, bool play_now,
|
||||
bool enqueue) {
|
||||
InsertSongItems<LibraryPlaylistItem>(songs, pos, play_now, enqueue);
|
||||
bool enqueue, bool enqueue_next) {
|
||||
InsertSongItems<LibraryPlaylistItem>(songs, pos, play_now, enqueue,
|
||||
enqueue_next);
|
||||
}
|
||||
|
||||
void Playlist::InsertSongs(const SongList& songs, int pos, bool play_now,
|
||||
bool enqueue) {
|
||||
InsertSongItems<SongPlaylistItem>(songs, pos, play_now, enqueue);
|
||||
bool enqueue, bool enqueue_next) {
|
||||
InsertSongItems<SongPlaylistItem>(songs, pos, play_now, enqueue,
|
||||
enqueue_next);
|
||||
}
|
||||
|
||||
void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
|
||||
bool play_now, bool enqueue) {
|
||||
bool play_now, bool enqueue,
|
||||
bool enqueue_next) {
|
||||
PlaylistItemList items;
|
||||
for (const Song& song : songs) {
|
||||
if (song.is_library_song()) {
|
||||
|
@ -1096,12 +1112,13 @@ void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
|
|||
items << PlaylistItemPtr(new SongPlaylistItem(song));
|
||||
}
|
||||
}
|
||||
InsertItems(items, pos, play_now, enqueue);
|
||||
InsertItems(items, pos, play_now, enqueue, enqueue_next);
|
||||
}
|
||||
|
||||
void Playlist::InsertInternetItems(const InternetModel* model,
|
||||
const QModelIndexList& items, int pos,
|
||||
bool play_now, bool enqueue) {
|
||||
bool play_now, bool enqueue,
|
||||
bool enqueue_next) {
|
||||
PlaylistItemList playlist_items;
|
||||
QList<QUrl> song_urls;
|
||||
|
||||
|
@ -1120,23 +1137,24 @@ void Playlist::InsertInternetItems(const InternetModel* model,
|
|||
}
|
||||
|
||||
if (!song_urls.isEmpty()) {
|
||||
InsertUrls(song_urls, pos, play_now, enqueue);
|
||||
InsertUrls(song_urls, pos, play_now, enqueue, enqueue_next);
|
||||
play_now = false;
|
||||
}
|
||||
|
||||
InsertItems(playlist_items, pos, play_now, enqueue);
|
||||
InsertItems(playlist_items, pos, play_now, enqueue, enqueue_next);
|
||||
}
|
||||
|
||||
void Playlist::InsertInternetItems(InternetService* service,
|
||||
const SongList& songs, int pos,
|
||||
bool play_now, bool enqueue) {
|
||||
bool play_now, bool enqueue,
|
||||
bool enqueue_next) {
|
||||
PlaylistItemList playlist_items;
|
||||
for (const Song& song : songs) {
|
||||
playlist_items << shared_ptr<PlaylistItem>(
|
||||
new InternetPlaylistItem(service, song));
|
||||
}
|
||||
|
||||
InsertItems(playlist_items, pos, play_now, enqueue);
|
||||
InsertItems(playlist_items, pos, play_now, enqueue, enqueue_next);
|
||||
}
|
||||
|
||||
void Playlist::UpdateItems(const SongList& songs) {
|
||||
|
|
|
@ -235,18 +235,22 @@ class Playlist : public QAbstractListModel {
|
|||
|
||||
// Changing the playlist
|
||||
void InsertItems(const PlaylistItemList& items, int pos = -1,
|
||||
bool play_now = false, bool enqueue = false);
|
||||
bool play_now = false, bool enqueue = false,
|
||||
bool enqueue_next = false);
|
||||
void InsertLibraryItems(const SongList& items, int pos = -1,
|
||||
bool play_now = false, bool enqueue = false);
|
||||
bool play_now = false, bool enqueue = false,
|
||||
bool enqueue_next = false);
|
||||
void InsertSongs(const SongList& items, int pos = -1, bool play_now = false,
|
||||
bool enqueue = false);
|
||||
bool enqueue = false, bool enqueue_next = false);
|
||||
void InsertSongsOrLibraryItems(const SongList& items, int pos = -1,
|
||||
bool play_now = false, bool enqueue = false);
|
||||
bool play_now = false, bool enqueue = false,
|
||||
bool enqueue_next = false);
|
||||
void InsertSmartPlaylist(smart_playlists::GeneratorPtr gen, int pos = -1,
|
||||
bool play_now = false, bool enqueue = false);
|
||||
bool play_now = false, bool enqueue = false,
|
||||
bool enqueue_next = false);
|
||||
void InsertInternetItems(InternetService* service, const SongList& songs,
|
||||
int pos = -1, bool play_now = false,
|
||||
bool enqueue = false);
|
||||
bool enqueue = false, bool enqueue_next = false);
|
||||
void ReshuffleIndices();
|
||||
|
||||
// If this playlist contains the current item, this method will apply the
|
||||
|
@ -335,7 +339,7 @@ class Playlist : public QAbstractListModel {
|
|||
void SetColumnAlignment(const ColumnAlignmentMap& alignment);
|
||||
|
||||
void InsertUrls(const QList<QUrl>& urls, int pos = -1, bool play_now = false,
|
||||
bool enqueue = false);
|
||||
bool enqueue = false, bool enqueue_next = false);
|
||||
// Removes items with given indices from the playlist. This operation is not
|
||||
// undoable.
|
||||
void RemoveItemsWithoutUndo(const QList<int>& indices);
|
||||
|
@ -366,18 +370,18 @@ signals:
|
|||
|
||||
void InsertInternetItems(const InternetModel* model,
|
||||
const QModelIndexList& items, int pos, bool play_now,
|
||||
bool enqueue);
|
||||
bool enqueue, bool enqueue_next = false);
|
||||
|
||||
template <typename T>
|
||||
void InsertSongItems(const SongList& songs, int pos, bool play_now,
|
||||
bool enqueue);
|
||||
bool enqueue, bool enqueue_next = false);
|
||||
|
||||
void InsertDynamicItems(int count);
|
||||
|
||||
// Modify the playlist without changing the undo stack. These are used by
|
||||
// our friends in PlaylistUndoCommands
|
||||
void InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
|
||||
bool enqueue = false);
|
||||
bool enqueue = false, bool enqueue_next = false);
|
||||
PlaylistItemList RemoveItemsWithoutUndo(int pos, int count);
|
||||
void MoveItemsWithoutUndo(const QList<int>& source_rows, int pos);
|
||||
void MoveItemWithoutUndo(int source, int dest);
|
||||
|
|
|
@ -23,13 +23,17 @@ namespace PlaylistUndoCommands {
|
|||
Base::Base(Playlist* playlist) : QUndoCommand(0), playlist_(playlist) {}
|
||||
|
||||
InsertItems::InsertItems(Playlist* playlist, const PlaylistItemList& items,
|
||||
int pos, bool enqueue)
|
||||
: Base(playlist), items_(items), pos_(pos), enqueue_(enqueue) {
|
||||
int pos, bool enqueue, bool enqueue_next)
|
||||
: Base(playlist),
|
||||
items_(items),
|
||||
pos_(pos),
|
||||
enqueue_(enqueue),
|
||||
enqueue_next_(enqueue_next) {
|
||||
setText(tr("add %n songs", "", items_.count()));
|
||||
}
|
||||
|
||||
void InsertItems::redo() {
|
||||
playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_);
|
||||
playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_, enqueue_next_);
|
||||
}
|
||||
|
||||
void InsertItems::undo() {
|
||||
|
|
|
@ -41,7 +41,7 @@ class Base : public QUndoCommand {
|
|||
class InsertItems : public Base {
|
||||
public:
|
||||
InsertItems(Playlist* playlist, const PlaylistItemList& items, int pos,
|
||||
bool enqueue = false);
|
||||
bool enqueue = false, bool enqueue_next = false);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
@ -56,6 +56,7 @@ class InsertItems : public Base {
|
|||
PlaylistItemList items_;
|
||||
int pos_;
|
||||
bool enqueue_;
|
||||
bool enqueue_next_;
|
||||
};
|
||||
|
||||
class RemoveItems : public Base {
|
||||
|
|
|
@ -151,6 +151,29 @@ void Queue::ToggleTracks(const QModelIndexList& source_indexes) {
|
|||
}
|
||||
}
|
||||
|
||||
void Queue::InsertFirst(const QModelIndexList& source_indexes) {
|
||||
for (const QModelIndex& source_index : source_indexes) {
|
||||
QModelIndex proxy_index = mapFromSource(source_index);
|
||||
if (proxy_index.isValid()) {
|
||||
// Already in the queue, so remove it to be reinserted later
|
||||
const int row = proxy_index.row();
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
source_indexes_.removeAt(row);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
const int rows = source_indexes.count();
|
||||
// Enqueue the tracks at the beginning
|
||||
beginInsertRows(QModelIndex(), 0, rows - 1);
|
||||
int offset = 0;
|
||||
for (const QModelIndex& source_index : source_indexes) {
|
||||
source_indexes_.insert(offset, QPersistentModelIndex(source_index));
|
||||
offset++;
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
int Queue::PositionOf(const QModelIndex& source_index) const {
|
||||
return mapFromSource(source_index).row();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ class Queue : public QAbstractProxyModel {
|
|||
// Modify the queue
|
||||
int TakeNext();
|
||||
void ToggleTracks(const QModelIndexList& source_indexes);
|
||||
void InsertFirst(const QModelIndexList& source_indexes);
|
||||
void Clear();
|
||||
void Move(const QList<int>& proxy_rows, int pos);
|
||||
void MoveUp(int row);
|
||||
|
|
|
@ -37,11 +37,13 @@ SongLoaderInserter::SongLoaderInserter(TaskManager* task_manager,
|
|||
SongLoaderInserter::~SongLoaderInserter() { qDeleteAll(pending_); }
|
||||
|
||||
void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now,
|
||||
bool enqueue, const QList<QUrl>& urls) {
|
||||
bool enqueue, bool enqueue_next,
|
||||
const QList<QUrl>& urls) {
|
||||
destination_ = destination;
|
||||
row_ = row;
|
||||
play_now_ = play_now;
|
||||
enqueue_ = enqueue;
|
||||
enqueue_next_ = enqueue_next;
|
||||
|
||||
connect(destination, SIGNAL(destroyed()), SLOT(DestinationDestroyed()));
|
||||
connect(this, SIGNAL(PreloadFinished()), SLOT(InsertSongs()));
|
||||
|
@ -78,11 +80,13 @@ void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now,
|
|||
// In the meantime, MusicBrainz will be queried to get songs' metadata.
|
||||
// AudioCDTagsLoaded will be called next, and playlist's items will be updated.
|
||||
void SongLoaderInserter::LoadAudioCD(Playlist* destination, int row,
|
||||
bool play_now, bool enqueue) {
|
||||
bool play_now, bool enqueue,
|
||||
bool enqueue_next) {
|
||||
destination_ = destination;
|
||||
row_ = row;
|
||||
play_now_ = play_now;
|
||||
enqueue_ = enqueue;
|
||||
enqueue_next_ = enqueue_next;
|
||||
|
||||
SongLoader* loader = new SongLoader(library_, player_, this);
|
||||
NewClosure(loader, SIGNAL(AudioCDTracksLoaded()),
|
||||
|
@ -119,7 +123,8 @@ void SongLoaderInserter::InsertSongs() {
|
|||
// Insert songs (that haven't been completely loaded) to allow user to see
|
||||
// and play them while not loaded completely
|
||||
if (destination_) {
|
||||
destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_);
|
||||
destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_,
|
||||
enqueue_next_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,11 @@ class SongLoaderInserter : public QObject {
|
|||
~SongLoaderInserter();
|
||||
|
||||
void Load(Playlist* destination, int row, bool play_now, bool enqueue,
|
||||
const QList<QUrl>& urls);
|
||||
void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue);
|
||||
bool enqueue_next, const QList<QUrl>& urls);
|
||||
void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue,
|
||||
bool enqueue_now);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void Error(const QString& message);
|
||||
void PreloadFinished();
|
||||
void EffectiveLoadFinished(const SongList& songs);
|
||||
|
@ -64,6 +65,7 @@ signals:
|
|||
int row_;
|
||||
bool play_now_;
|
||||
bool enqueue_;
|
||||
bool enqueue_next_;
|
||||
|
||||
SongList songs_;
|
||||
|
||||
|
|
|
@ -43,14 +43,15 @@ static PlaylistItemList Generate(GeneratorPtr generator, int dynamic_count) {
|
|||
}
|
||||
|
||||
void GeneratorInserter::Load(Playlist* destination, int row, bool play_now,
|
||||
bool enqueue, GeneratorPtr generator,
|
||||
int dynamic_count) {
|
||||
bool enqueue, bool enqueue_next,
|
||||
GeneratorPtr generator, int dynamic_count) {
|
||||
task_id_ = task_manager_->StartTask(tr("Loading smart playlist"));
|
||||
|
||||
destination_ = destination;
|
||||
row_ = row;
|
||||
play_now_ = play_now;
|
||||
enqueue_ = enqueue;
|
||||
enqueue_next_ = enqueue_next;
|
||||
is_dynamic_ = generator->is_dynamic();
|
||||
|
||||
connect(generator.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
|
|
|
@ -41,9 +41,9 @@ class GeneratorInserter : public QObject {
|
|||
QObject* parent);
|
||||
|
||||
void Load(Playlist* destination, int row, bool play_now, bool enqueue,
|
||||
GeneratorPtr generator, int dynamic_count = 0);
|
||||
bool enqueue_next, GeneratorPtr generator, int dynamic_count = 0);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void Error(const QString& message);
|
||||
void PlayRequested(const QModelIndex& index);
|
||||
|
||||
|
@ -59,6 +59,7 @@ signals:
|
|||
int row_;
|
||||
bool play_now_;
|
||||
bool enqueue_;
|
||||
bool enqueue_next_;
|
||||
bool is_dynamic_;
|
||||
};
|
||||
|
||||
|
|
|
@ -677,6 +677,10 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
|||
playlist_queue_ = playlist_menu_->addAction("", this, SLOT(PlaylistQueue()));
|
||||
playlist_queue_->setShortcut(QKeySequence("Ctrl+D"));
|
||||
ui_->playlist->addAction(playlist_queue_);
|
||||
playlist_queue_play_next_ =
|
||||
playlist_menu_->addAction("", this, SLOT(PlaylistQueuePlayNext()));
|
||||
playlist_queue_play_next_->setShortcut(QKeySequence("Ctrl+Shift+D"));
|
||||
ui_->playlist->addAction(playlist_queue_play_next_);
|
||||
playlist_skip_ = playlist_menu_->addAction("", this, SLOT(PlaylistSkip()));
|
||||
ui_->playlist->addAction(playlist_skip_);
|
||||
playlist_menu_->addSeparator();
|
||||
|
@ -1760,6 +1764,11 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
|
|||
else
|
||||
playlist_queue_->setText(tr("Toggle queue status"));
|
||||
|
||||
if (all > 1)
|
||||
playlist_queue_play_next_->setText(tr("Play selected tracks next"));
|
||||
else
|
||||
playlist_queue_play_next_->setText(tr("Play next"));
|
||||
|
||||
if (in_skipped == 1 && not_in_skipped == 0)
|
||||
playlist_skip_->setText(tr("Unskip track"));
|
||||
else if (in_skipped > 1 && not_in_skipped == 0)
|
||||
|
@ -1774,6 +1783,9 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
|
|||
else
|
||||
playlist_queue_->setIcon(IconLoader::Load("go-next", IconLoader::Base));
|
||||
|
||||
playlist_queue_play_next_->setIcon(
|
||||
IconLoader::Load("go-next", IconLoader::Base));
|
||||
|
||||
if (!index.isValid()) {
|
||||
ui_->action_selection_set_value->setVisible(false);
|
||||
ui_->action_edit_value->setVisible(false);
|
||||
|
@ -2500,6 +2512,17 @@ void MainWindow::PlaylistQueue() {
|
|||
app_->playlist_manager()->current()->queue()->ToggleTracks(indexes);
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistQueuePlayNext() {
|
||||
QModelIndexList indexes;
|
||||
for (const QModelIndex& proxy_index :
|
||||
ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(
|
||||
proxy_index);
|
||||
}
|
||||
|
||||
app_->playlist_manager()->current()->queue()->InsertFirst(indexes);
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistSkip() {
|
||||
QModelIndexList indexes;
|
||||
for (const QModelIndex& proxy_index :
|
||||
|
|
|
@ -162,6 +162,7 @@ signals:
|
|||
void PlaylistPlay();
|
||||
void PlaylistStopAfter();
|
||||
void PlaylistQueue();
|
||||
void PlaylistQueuePlayNext();
|
||||
void PlaylistSkip();
|
||||
void PlaylistRemoveCurrent();
|
||||
void PlaylistEditFinished(const QModelIndex& index);
|
||||
|
@ -361,6 +362,7 @@ signals:
|
|||
QAction* playlist_delete_;
|
||||
QAction* playlist_open_in_browser_;
|
||||
QAction* playlist_queue_;
|
||||
QAction* playlist_queue_play_next_;
|
||||
QAction* playlist_skip_;
|
||||
QAction* playlist_add_to_another_;
|
||||
QList<QAction*> playlistitem_actions_;
|
||||
|
|
Loading…
Reference in New Issue