diff --git a/src/musikbox/app/layout/LibraryLayout.cpp b/src/musikbox/app/layout/LibraryLayout.cpp index 4c81f8077..d7683e8c3 100755 --- a/src/musikbox/app/layout/LibraryLayout.cpp +++ b/src/musikbox/app/layout/LibraryLayout.cpp @@ -268,8 +268,17 @@ bool LibraryLayout::SetFocus(cursespp::IWindowPtr window) { } void LibraryLayout::ProcessMessage(musik::core::runtime::IMessage &message) { - if (message.Type() == message::JumpToAlbum) { - this->OnSearchResultSelected(nullptr, constants::Track::ALBUM, message.UserData1()); + if (message.Type() == message::JumpToCategory) { + static std::map JUMP_TYPE_TO_COLUMN = { + { message::category::Album, constants::Track::ALBUM }, + { message::category::Artist, constants::Track::ARTIST }, + { message::category::AlbumArtist, constants::Track::ALBUM_ARTIST }, + { message::category::Genre, constants::Track::GENRE } + }; + + auto type = JUMP_TYPE_TO_COLUMN[(int) message.UserData1()]; + auto id = message.UserData2(); + this->OnSearchResultSelected(nullptr, type, id); } LayoutBase::ProcessMessage(message); diff --git a/src/musikbox/app/overlay/PlayQueueOverlays.cpp b/src/musikbox/app/overlay/PlayQueueOverlays.cpp index 4dc124ba4..da32431b0 100644 --- a/src/musikbox/app/overlay/PlayQueueOverlays.cpp +++ b/src/musikbox/app/overlay/PlayQueueOverlays.cpp @@ -76,14 +76,6 @@ static std::string stringWithFormat(const std::string& key, const std::string& v return message; } -static std::shared_ptr createAddToAdapter() { - std::shared_ptr adapter(new Adapter()); - adapter->AddEntry(_TSTR("playqueue_overlay_add_to_end")); - adapter->AddEntry(_TSTR("playqueue_overlay_add_as_next")); - adapter->SetSelectable(true); - return adapter; -} - static std::shared_ptr queryPlaylists(musik::core::ILibraryPtr library) { std::shared_ptr query( new CategoryListQuery(Playlists::TABLE_NAME, "")); @@ -254,34 +246,70 @@ static void handleAddCategorySelection( } } +static void handleJumpTo( + size_t index, + musik::core::runtime::IMessageQueue& messageQueue, + musik::core::TrackPtr track) +{ + unsigned long long type; + unsigned long long id; + + if (index == 0) { + type = message::category::Album; + id = track->GetUint64(library::constants::Track::ALBUM_ID); + } + else if (index == 1) { + type = message::category::Artist; + id = track->GetUint64(library::constants::Track::ARTIST_ID); + } + else if (index == 2) { + type = message::category::Genre; + id = track->GetUint64(library::constants::Track::GENRE_ID); + } + + messageQueue.Broadcast(runtime::Message::Create( + nullptr, message::JumpToCategory, type, id)); +} + PlayQueueOverlays::PlayQueueOverlays() { } void PlayQueueOverlays::ShowAddTrackOverlay( + runtime::IMessageQueue& messageQueue, PlaybackService& playback, - unsigned long long trackId) + musik::core::TrackPtr track) { - auto adapter = createAddToAdapter(); + std::shared_ptr 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_add_to_end_in_queue")); + adapter->AddEntry(_TSTR("playqueue_overlay_add_as_next_in_queue")); + adapter->SetSelectable(true); std::shared_ptr dialog(new ListOverlay()); dialog->SetAdapter(adapter) - .SetTitle(_TSTR("playqueue_overlay_add_to_queue_title")) + .SetTitle(_TSTR("playqueue_overlay_track_actions_title")) .SetWidth(_DIMEN("playqueue_playlist_add_to_queue_overlay", DEFAULT_OVERLAY_WIDTH)) .SetSelectedIndex(0) .SetItemSelectedCallback( - [trackId, &playback](ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) { + [track, &messageQueue, &playback] + (ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) { auto editor = playback.Edit(); - if (index == 0) { /* end */ - editor.Add(trackId); + if (index >= 0 && index <= 2) { + handleJumpTo(index, messageQueue, track); + } + else if (index == 3) { /* end */ + editor.Add(track->GetId()); } else { /* next */ size_t position = playback.GetIndex(); if (position == ListWindow::NO_SELECTION) { - editor.Add(trackId); + editor.Add(track->GetId()); } else { - editor.Insert(trackId, position + 1); + editor.Insert(track->GetId(), position + 1); } } }); @@ -295,7 +323,10 @@ void PlayQueueOverlays::ShowAddCategoryOverlay( const std::string& fieldColumn, DBID fieldId) { - auto adapter = createAddToAdapter(); + std::shared_ptr adapter(new Adapter()); + adapter->AddEntry(_TSTR("playqueue_overlay_add_to_end")); + adapter->AddEntry(_TSTR("playqueue_overlay_add_as_next")); + adapter->SetSelectable(true); std::shared_ptr dialog(new ListOverlay()); @@ -324,6 +355,8 @@ void PlayQueueOverlays::ShowAlbumDividerOverlay( { std::shared_ptr 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_add_to_end_in_queue")); adapter->AddEntry(_TSTR("playqueue_overlay_add_as_next_in_queue")); adapter->SetSelectable(true); @@ -341,16 +374,15 @@ void PlayQueueOverlays::ShowAlbumDividerOverlay( return; } - auto albumIdColumn = library::constants::Track::ALBUM_ID; - auto albumColumn = library::constants::Track::ALBUM; - auto albumId = firstTrack->GetUint64(albumIdColumn); - - if (index == 0) { - messageQueue.Broadcast(runtime::Message::Create( - nullptr, message::JumpToAlbum, albumId)); + /* items 0, 1, and 2 jump to category */ + if (index >= 0 && index <= 2) { + handleJumpTo(index, messageQueue, firstTrack); } + /* the other are our standard play queue operations */ else { - handleAddCategorySelection(playback, library, albumColumn, albumId, index - 1); + auto albumColumn = library::constants::Track::ALBUM; + auto albumId = firstTrack->GetUint64(library::constants::Track::ALBUM_ID); + handleAddCategorySelection(playback, library, albumColumn, albumId, index - 3); } }); diff --git a/src/musikbox/app/overlay/PlayQueueOverlays.h b/src/musikbox/app/overlay/PlayQueueOverlays.h index 996d33b6e..3123f903b 100644 --- a/src/musikbox/app/overlay/PlayQueueOverlays.h +++ b/src/musikbox/app/overlay/PlayQueueOverlays.h @@ -46,8 +46,9 @@ namespace musik { using PlaylistSelectedCallback = std::function; static void ShowAddTrackOverlay( + musik::core::runtime::IMessageQueue& messageQueue, musik::core::audio::PlaybackService& playback, - unsigned long long trackId); + musik::core::TrackPtr track); static void ShowAddCategoryOverlay( musik::core::audio::PlaybackService& playback, diff --git a/src/musikbox/app/util/Messages.h b/src/musikbox/app/util/Messages.h index 310a5b248..2b66f5d5d 100644 --- a/src/musikbox/app/util/Messages.h +++ b/src/musikbox/app/util/Messages.h @@ -42,7 +42,14 @@ namespace musik { namespace box { namespace message { - static const int JumpToAlbum = 1024; + static const int JumpToCategory = 1024; + + namespace category { /* User1 */ + static const int Album = 0; + static const int AlbumArtist = 1; + static const int Artist = 2; + static const int Genre = 3; + } static const int IndexerStarted = 1025; static const int IndexerProgress = 1026; diff --git a/src/musikbox/app/window/TrackListView.cpp b/src/musikbox/app/window/TrackListView.cpp index fe2dce40a..2b81fa139 100755 --- a/src/musikbox/app/window/TrackListView.cpp +++ b/src/musikbox/app/window/TrackListView.cpp @@ -227,7 +227,7 @@ bool TrackListView::KeyPress(const std::string& key) { if (!headers.HeaderAt(this->GetSelectedIndex())) { TrackPtr track = this->GetSelectedTrack(); if (track) { - PlayQueueOverlays::ShowAddTrackOverlay(this->playback, track->GetId()); + PlayQueueOverlays::ShowAddTrackOverlay(MessageQueue(), this->playback, track); handled = true; } } diff --git a/src/musikbox/data/locales/en_US.json b/src/musikbox/data/locales/en_US.json index a011aee36..af933d5e5 100644 --- a/src/musikbox/data/locales/en_US.json +++ b/src/musikbox/data/locales/en_US.json @@ -57,8 +57,11 @@ "playqueue_overlay_new_playlist_name_title": "new playlist name", "playqueue_overlay_confirm_delete_message": "are you sure you want to delete '%s'?", "playqueue_overlay_load_playlists_none_message": "you haven't saved any playlists yet!", - "playqueue_overlay_album_header": "album actions", + "playqueue_overlay_track_actions_title": "track actions", + "playqueue_overlay_album_header_actions_title": "album actions", "playqueue_overlay_album_jump_to": "jump to album in library", + "playqueue_overlay_artist_jump_to": "jump to artist in library", + "playqueue_overlay_genre_jump_to": "jump to genre in library", "playqueue_overlay_add_to_end_in_queue": "add to end of play queue", "playqueue_overlay_add_as_next_in_queue": "add as next in play queue", @@ -94,8 +97,8 @@ "dimensions": { "playqueue_album_header_overlay": 35, - "playqueue_playlist_add_to_queue_overlay": 30, - "playqueue_playlist_list_overlay": 30, - "playqueue_playlist_name_overlay": 30 + "playqueue_playlist_add_to_queue_overlay": 35, + "playqueue_playlist_list_overlay": 35, + "playqueue_playlist_name_overlay": 35 } } \ No newline at end of file