diff --git a/src/ProjectMWrapper.cpp b/src/ProjectMWrapper.cpp index 342cd64..db49dc3 100644 --- a/src/ProjectMWrapper.cpp +++ b/src/ProjectMWrapper.cpp @@ -206,6 +206,13 @@ std::string ProjectMWrapper::ProjectMRuntimeVersion() return projectMRuntimeVersion; } +void ProjectMWrapper::PresetFileNameToClipboard() const +{ + auto presetName = projectm_playlist_item(_playlist, projectm_playlist_get_position(_playlist)); + SDL_SetClipboardText(presetName); + projectm_playlist_free_string(presetName); +} + void ProjectMWrapper::PresetSwitchedEvent(bool isHardCut, unsigned int index, void* context) { auto that = reinterpret_cast(context); diff --git a/src/ProjectMWrapper.h b/src/ProjectMWrapper.h index 919a2f9..3493dc4 100644 --- a/src/ProjectMWrapper.h +++ b/src/ProjectMWrapper.h @@ -75,6 +75,11 @@ class ProjectMWrapper : public Poco::Util::Subsystem */ std::string ProjectMRuntimeVersion(); + /** + * Copies the full path of the current preset into the OS clipboard. + */ + void PresetFileNameToClipboard() const; + private: /** * @brief projectM callback. Called whenever a preset is switched. diff --git a/src/RenderLoop.cpp b/src/RenderLoop.cpp index 1fe8fa1..6312046 100644 --- a/src/RenderLoop.cpp +++ b/src/RenderLoop.cpp @@ -275,6 +275,13 @@ void RenderLoop::KeyEvent(const SDL_KeyboardEvent& event, bool down) } break; + case SDLK_c: + if (modifierPressed) + { + _projectMWrapper.PresetFileNameToClipboard(); + } + break; + #ifdef _DEBUG case SDLK_d: // Write next rendered frame to file diff --git a/src/gui/HelpWindow.cpp b/src/gui/HelpWindow.cpp index 058810c..16b8db8 100644 --- a/src/gui/HelpWindow.cpp +++ b/src/gui/HelpWindow.cpp @@ -167,5 +167,6 @@ void HelpWindow::FillKeyboardShortcutsTable() {"Increase Beat Sensitivity by 1%", "Cursor Up"}, {"Decrease Beat Sensitivity by 1%", "Cursor Down"}, {"Add Random Waveform at Mouse Pointer", "Shift+Left Mouse"}, - {"Clear Random Waveforms", "Middle Mouse"}}; + {"Clear Random Waveforms", "Middle Mouse"}, + {"Copy Current Preset Path to Clipboard", "Ctrl-c"}}; } diff --git a/src/gui/MainMenu.cpp b/src/gui/MainMenu.cpp index c0b1811..02afba6 100644 --- a/src/gui/MainMenu.cpp +++ b/src/gui/MainMenu.cpp @@ -77,6 +77,13 @@ void MainMenu::Draw() _notificationCenter.postNotification(new PlaybackControlNotification(PlaybackControlNotification::Action::ToggleShuffle)); } + ImGui::Separator(); + + if (ImGui::MenuItem("Copy Current Preset Filename", "Ctrl+c")) + { + _projectMWrapper.PresetFileNameToClipboard(); + } + ImGui::EndMenu(); }