Skip to content

Commit 947099c

Browse files
committed
Add ctrl-c shortcut to copy current preset path to clipboard
1 parent 9151982 commit 947099c

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

src/ProjectMWrapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ std::string ProjectMWrapper::ProjectMRuntimeVersion()
206206
return projectMRuntimeVersion;
207207
}
208208

209+
void ProjectMWrapper::PresetFileNameToClipboard() const
210+
{
211+
auto presetName = projectm_playlist_item(_playlist, projectm_playlist_get_position(_playlist));
212+
SDL_SetClipboardText(presetName);
213+
projectm_playlist_free_string(presetName);
214+
}
215+
209216
void ProjectMWrapper::PresetSwitchedEvent(bool isHardCut, unsigned int index, void* context)
210217
{
211218
auto that = reinterpret_cast<ProjectMWrapper*>(context);

src/ProjectMWrapper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class ProjectMWrapper : public Poco::Util::Subsystem
7575
*/
7676
std::string ProjectMRuntimeVersion();
7777

78+
/**
79+
* Copies the full path of the current preset into the OS clipboard.
80+
*/
81+
void PresetFileNameToClipboard() const;
82+
7883
private:
7984
/**
8085
* @brief projectM callback. Called whenever a preset is switched.

src/RenderLoop.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ void RenderLoop::KeyEvent(const SDL_KeyboardEvent& event, bool down)
275275
}
276276
break;
277277

278+
case SDLK_c:
279+
if (modifierPressed)
280+
{
281+
_projectMWrapper.PresetFileNameToClipboard();
282+
}
283+
break;
284+
278285
#ifdef _DEBUG
279286
case SDLK_d:
280287
// Write next rendered frame to file

src/gui/HelpWindow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,6 @@ void HelpWindow::FillKeyboardShortcutsTable()
167167
{"Increase Beat Sensitivity by 1%", "Cursor Up"},
168168
{"Decrease Beat Sensitivity by 1%", "Cursor Down"},
169169
{"Add Random Waveform at Mouse Pointer", "Shift+Left Mouse"},
170-
{"Clear Random Waveforms", "Middle Mouse"}};
170+
{"Clear Random Waveforms", "Middle Mouse"},
171+
{"Copy Current Preset Path to Clipboard", "Ctrl-c"}};
171172
}

src/gui/MainMenu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ void MainMenu::Draw()
7777
_notificationCenter.postNotification(new PlaybackControlNotification(PlaybackControlNotification::Action::ToggleShuffle));
7878
}
7979

80+
ImGui::Separator();
81+
82+
if (ImGui::MenuItem("Copy Current Preset Filename", "Ctrl+c"))
83+
{
84+
_projectMWrapper.PresetFileNameToClipboard();
85+
}
86+
8087
ImGui::EndMenu();
8188
}
8289

0 commit comments

Comments
 (0)