mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-06 12:39:54 +00:00
Added "jump to artist" and "jump to genre" options to "album header"
context menu. Added "jump to album", "jump to artist", and "jump to genre" in track context menu.
This commit is contained in:
parent
e3f4179978
commit
a3d2d54fc4
@ -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<int, const char*> 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);
|
||||
|
@ -76,14 +76,6 @@ static std::string stringWithFormat(const std::string& key, const std::string& v
|
||||
return message;
|
||||
}
|
||||
|
||||
static std::shared_ptr<Adapter> createAddToAdapter() {
|
||||
std::shared_ptr<Adapter> 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<CategoryListQuery> queryPlaylists(musik::core::ILibraryPtr library) {
|
||||
std::shared_ptr<CategoryListQuery> 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> 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<ListOverlay> 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> 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<ListOverlay> dialog(new ListOverlay());
|
||||
|
||||
@ -324,6 +355,8 @@ void PlayQueueOverlays::ShowAlbumDividerOverlay(
|
||||
{
|
||||
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_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);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -46,8 +46,9 @@ namespace musik {
|
||||
using PlaylistSelectedCallback = std::function<void(DBID)>;
|
||||
|
||||
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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user