From b96c2e6c1763aab54ad07de3c0b4c438a7f3257d Mon Sep 17 00:00:00 2001 From: Casey Langen Date: Thu, 15 Feb 2018 09:21:00 -0800 Subject: [PATCH] Added the ability to start playback directly from the directory pane in DirectoryLayout by using the context menu key. --- src/musikcube/app/layout/DirectoryLayout.cpp | 12 +++++++++++- src/musikcube/data/locales/en_US.json | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/musikcube/app/layout/DirectoryLayout.cpp b/src/musikcube/app/layout/DirectoryLayout.cpp index 213e092bc..ecc4ab205 100644 --- a/src/musikcube/app/layout/DirectoryLayout.cpp +++ b/src/musikcube/app/layout/DirectoryLayout.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -218,8 +219,11 @@ bool DirectoryLayout::IsParentRoot() { bool DirectoryLayout::KeyPress(const std::string& key) { if (key == "KEY_ENTER") { - if (this->GetFocus() = this->directoryList) { + if (this->GetFocus() == this->directoryList) { if (!this->adapter->HasSubDirectories(this->directoryList->GetSelectedIndex())) { + std::string message = _TSTR("browse_no_subdirectories_toast"); + message = (boost::format(message) % Hotkeys::Get(Hotkeys::ContextMenu)).str(); + ToastOverlay::Show(message); return true; } @@ -236,6 +240,12 @@ bool DirectoryLayout::KeyPress(const std::string& key) { this->Requery(); } } + else if (Hotkeys::Is(Hotkeys::ContextMenu, key)) { + auto tracks = this->trackList->GetTrackList(); + auto index = this->trackList->GetSelectedTrackIndex(); + index = (index == ListWindow::NO_SELECTION) ? 0 : index; + this->playback.Play(*tracks.get(), index); + } else if (Hotkeys::Is(Hotkeys::ViewRefresh, key)) { this->queryHash = 0; this->Refresh(); diff --git a/src/musikcube/data/locales/en_US.json b/src/musikcube/data/locales/en_US.json index 784b94d1f..e25a63a7d 100644 --- a/src/musikcube/data/locales/en_US.json +++ b/src/musikcube/data/locales/en_US.json @@ -28,6 +28,7 @@ "browse_pick_path_last_directory": "last directory", "browse_no_paths_overlay_error_title": "no paths configured", "browse_no_paths_overlay_error_message": "you have not configured any metadata paths.\n\nyou must add at least one path in the settings screen before you can browse by directory.", + "browse_no_subdirectories_toast": "there are no more sub-directories.\n\npress '%s' to play the selection.", "console_command_output_title": "command output", "console_debug_logs_title": "debug logs",