From 8e8aceccb0e2ab37f2b3f21c3b72c49d3446d73a Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Sun, 12 May 2024 16:18:41 -0400 Subject: [PATCH] implement get recent files from state --- Source/LumatoneEditorState.cpp | 5 +++++ Source/LumatoneEditorState.h | 2 ++ Source/Main.cpp | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/LumatoneEditorState.cpp b/Source/LumatoneEditorState.cpp index a9fda4b..d6f3158 100644 --- a/Source/LumatoneEditorState.cpp +++ b/Source/LumatoneEditorState.cpp @@ -154,6 +154,11 @@ juce::File LumatoneEditorState::getUserPalettesDirectory() const return directory; } +juce::File LumatoneEditorState::getLastOpenedMappingsDirectory() const +{ + return recentFiles->getFile(0).getParentDirectory(); +} + void LumatoneEditorState::setHasChangesToSave(bool hasChangesToSaveIn) { hasChangesToSave = hasChangesToSaveIn; diff --git a/Source/LumatoneEditorState.h b/Source/LumatoneEditorState.h index 461c919..10ffaed 100644 --- a/Source/LumatoneEditorState.h +++ b/Source/LumatoneEditorState.h @@ -106,6 +106,8 @@ class LumatoneEditorState : public LumatoneApplicationState juce::File getUserMappingsDirectory() const; juce::File getUserPalettesDirectory() const; + juce::File getLastOpenedMappingsDirectory() const; + public: bool doSendChangesToDevice() const override; diff --git a/Source/Main.cpp b/Source/Main.cpp index 960398c..d05b718 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -391,7 +391,7 @@ bool TerpstraSysExApplication::perform(const InvocationInfo& info) bool TerpstraSysExApplication::openSysExMapping() { - fileChooser = std::make_unique("Open a Lumatone key mapping", state.getRecentFiles().getFile(0).getParentDirectory(), "*.ltn;*.tsx"); + fileChooser = std::make_unique("Open a Lumatone key mapping", state.getLastOpenedMappingsDirectory(), "*.ltn"); fileChooser->launchAsync(FileBrowserComponent::FileChooserFlags::canSelectFiles | FileBrowserComponent::FileChooserFlags::openMode, [&](const FileChooser& chooser) { @@ -417,7 +417,7 @@ bool TerpstraSysExApplication::saveSysExMapping(std::function saveFileCallback) { - fileChooser = std::make_unique("Lumatone Key Mapping Files", state.getRecentFiles().getFile(0).getParentDirectory(), "*.ltn"); + fileChooser = std::make_unique("Lumatone Key Mapping Files", state.getLastOpenedMappingsDirectory(), "*.ltn"); fileChooser->launchAsync(FileBrowserComponent::FileChooserFlags::saveMode | FileBrowserComponent::FileChooserFlags::warnAboutOverwriting, [this, saveFileCallback](const FileChooser& chooser) {