void PlayQueueOverlays::ShowAlbumDividerOverlay( IMessageQueue& messageQueue, PlaybackService& playback, ILibraryPtr library, TrackPtr firstTrack) { std::shared_ptr<Adapter> adapter(new Adapter()); adapter->AddEntry(_TSTR("playqueue_overlay_album_jump_to")); adapter->AddEntry(_TSTR("playqueue_overlay_artist_jump_to")); adapter->AddEntry(_TSTR("playqueue_overlay_genre_jump_to")); adapter->AddEntry(_TSTR("playqueue_overlay_album_play")); adapter->AddEntry(_TSTR("playqueue_overlay_add_to_playlist")); adapter->AddEntry(_TSTR("playqueue_overlay_add_to_start_of_queue")); adapter->AddEntry(_TSTR("playqueue_overlay_add_to_end_in_queue")); adapter->AddEntry(_TSTR("playqueue_overlay_add_as_next_in_queue")); adapter->SetSelectable(true); std::shared_ptr<ListOverlay> dialog(new ListOverlay()); dialog->SetAdapter(adapter) .SetTitle(_TSTR("playqueue_overlay_album_header_actions_title")) .SetWidth(_DIMEN("playqueue_album_header_overlay_width", DEFAULT_OVERLAY_WIDTH)) .SetSelectedIndex(0) .SetItemSelectedCallback( [&playback, library, &messageQueue, firstTrack] (ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) { if (index == ListWindow::NO_SELECTION) { return; } auto albumColumn = library::constants::Track::ALBUM; auto albumId = firstTrack->GetInt64(library::constants::Track::ALBUM_ID); /* items 0, 1, and 2 jump to category */ if (index <= 2) { handleJumpTo(index, messageQueue, firstTrack); } else if (index == 3) { /* replace play queue */ std::shared_ptr<CategoryTrackListQuery> query( new CategoryTrackListQuery(library, albumColumn, albumId)); library->Enqueue(query, ILibrary::QuerySynchronous); if (query->GetStatus() == IQuery::Finished) { playback.Play(*query->GetResult().get(), 0); } } /* add to playlist */ else if (index == 4) { showAddCategorySelectionToPlaylistOverlay( messageQueue, library, albumColumn, albumId); } /* the other are our standard play queue operations */ else { handleAddCategorySelectionToPlayQueue( playback, library, albumColumn, albumId, index - 5); } }); cursespp::App::Overlays().Push(dialog); }
static void handleJumpTo( size_t index, IMessageQueue& messageQueue, TrackPtr track) { int64_t type; int64_t id; if (index == 0) { type = cube::message::category::Album; id = track->GetInt64(library::constants::Track::ALBUM_ID); } else if (index == 1) { type = cube::message::category::Artist; id = track->GetInt64(library::constants::Track::ARTIST_ID); } else if (index == 2) { type = cube::message::category::Genre; id = track->GetInt64(library::constants::Track::GENRE_ID); } messageQueue.Broadcast(runtime::Message::Create( nullptr, cube::message::JumpToCategory, type, id)); }