Fixed switching to play queue from LyricsLayout, and also ensure we

don't load lyrics until the screen is visible.
This commit is contained in:
casey langen 2019-04-08 22:32:24 -07:00
parent f167614851
commit d175e6c4c9
4 changed files with 26 additions and 14 deletions

View File

@ -78,7 +78,9 @@ void LyricsLayout::OnLayout() {
} }
void LyricsLayout::OnTrackChanged(size_t index, TrackPtr track) { void LyricsLayout::OnTrackChanged(size_t index, TrackPtr track) {
this->LoadLyricsForCurrentTrack(); if (this->IsVisible()) {
this->LoadLyricsForCurrentTrack();
}
} }
bool LyricsLayout::KeyPress(const std::string& kn) { bool LyricsLayout::KeyPress(const std::string& kn) {
@ -86,16 +88,26 @@ bool LyricsLayout::KeyPress(const std::string& kn) {
this->LoadLyricsForCurrentTrack(); this->LoadLyricsForCurrentTrack();
return true; return true;
} }
else if (Hotkeys::Is(Hotkeys::NavigateLibraryPlayQueue, kn)) {
this->Broadcast(message::JumpToPlayQueue);
return true;
}
else if (Hotkeys::Is(Hotkeys::NavigateLibrary, kn)) {
this->Broadcast(message::JumpToLibrary);
return true;
}
else if (kn == " ") { /* ugh... need to generalize this maybe */ else if (kn == " ") { /* ugh... need to generalize this maybe */
playback.PauseOrResume(); playback.PauseOrResume();
return true; return true;
} }
return LayoutBase::KeyPress(kn); return LayoutBase::KeyPress(kn);
} }
void LyricsLayout::OnVisibilityChanged(bool visible) { void LyricsLayout::OnVisibilityChanged(bool visible) {
LayoutBase::OnVisibilityChanged(visible); LayoutBase::OnVisibilityChanged(visible);
if (visible) { if (visible) {
this->LoadLyricsForCurrentTrack();
this->FocusFirst(); this->FocusFirst();
} }
} }
@ -179,17 +191,11 @@ void LyricsLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
if (shortcuts) { if (shortcuts) {
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLyrics), _TSTR("shortcuts_lyrics")); shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLyrics), _TSTR("shortcuts_lyrics"));
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLibrary), _TSTR("shortcuts_library")); shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLibrary), _TSTR("shortcuts_library"));
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateSettings), _TSTR("shortcuts_settings")); shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLibraryPlayQueue), _TSTR("shortcuts_play_queue"));
shortcuts->AddShortcut(App::Instance().GetQuitKey(), _TSTR("shortcuts_quit")); shortcuts->AddShortcut(App::Instance().GetQuitKey(), _TSTR("shortcuts_quit"));
shortcuts->SetChangedCallback([this](std::string key) { shortcuts->SetChangedCallback([this](std::string key) {
if (Hotkeys::Is(Hotkeys::NavigateSettings, key)) { if (key == App::Instance().GetQuitKey()) {
this->Broadcast(message::JumpToSettings);
}
if (Hotkeys::Is(Hotkeys::NavigateLibrary, key)) {
this->Broadcast(message::JumpToLibrary);
}
else if (key == App::Instance().GetQuitKey()) {
App::Instance().Quit(); App::Instance().Quit();
} }
else { else {

View File

@ -196,7 +196,12 @@ void MainLayout::ProcessMessage(musik::core::runtime::IMessage &message) {
else if (type == message::JumpToLibrary) { else if (type == message::JumpToLibrary) {
this->SetLayout(libraryLayout); this->SetLayout(libraryLayout);
} }
if (type == message::IndexerStarted) { else if (type == message::JumpToPlayQueue) {
this->SetLayout(libraryLayout);
libraryLayout->KeyPress(Hotkeys::Get(
Hotkeys::NavigateLibraryPlayQueue));
}
else if (type == message::IndexerStarted) {
this->syncUpdateCount = 0; this->syncUpdateCount = 0;
this->Layout(); this->Layout();
} }

View File

@ -62,9 +62,10 @@ namespace musik {
static const int JumpToSettings = First + 11; static const int JumpToSettings = First + 11;
static const int JumpToLyrics = First + 12; static const int JumpToLyrics = First + 12;
static const int JumpToHotkeys = First + 13; static const int JumpToHotkeys = First + 13;
static const int SetLastFmState = First + 14; static const int JumpToPlayQueue = First + 14;
static const int UpdateEqualizer = First + 15; static const int SetLastFmState = First + 15;
static const int DebugLog = First + 16; static const int UpdateEqualizer = First + 16;
static const int DebugLog = First + 17;
} }
} }
} }

View File

@ -205,7 +205,7 @@
"main_syncing_banner": "syncing metadata (%d tracks processed)", "main_syncing_banner": "syncing metadata (%d tracks processed)",
"lyrics_list_title": "lyrics for '%s' by '%s'", "lyrics_list_title": "lyrics for '%s' by '%s'",
"lyrics_not_playing": "nothing is currently playing!", "lyrics_not_playing": "can't show lyrics because nothing is playing!",
"lyrics_loading": "looking up lyrics...", "lyrics_loading": "looking up lyrics...",
"lyrics_lookup_failed": "lyrics lookup failed. press '%s' to retry.", "lyrics_lookup_failed": "lyrics lookup failed. press '%s' to retry.",