Skip to content

Commit

Permalink
implement get recent files from state
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed May 12, 2024
1 parent a084d8a commit 8e8acec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Source/LumatoneEditorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Source/LumatoneEditorState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ bool TerpstraSysExApplication::perform(const InvocationInfo& info)

bool TerpstraSysExApplication::openSysExMapping()
{
fileChooser = std::make_unique<FileChooser>("Open a Lumatone key mapping", state.getRecentFiles().getFile(0).getParentDirectory(), "*.ltn;*.tsx");
fileChooser = std::make_unique<FileChooser>("Open a Lumatone key mapping", state.getLastOpenedMappingsDirectory(), "*.ltn");
fileChooser->launchAsync(FileBrowserComponent::FileChooserFlags::canSelectFiles | FileBrowserComponent::FileChooserFlags::openMode,
[&](const FileChooser& chooser)
{
Expand All @@ -417,7 +417,7 @@ bool TerpstraSysExApplication::saveSysExMapping(std::function<void(bool success)

bool TerpstraSysExApplication::saveSysExMappingAs(std::function<void(bool)> saveFileCallback)
{
fileChooser = std::make_unique<FileChooser>("Lumatone Key Mapping Files", state.getRecentFiles().getFile(0).getParentDirectory(), "*.ltn");
fileChooser = std::make_unique<FileChooser>("Lumatone Key Mapping Files", state.getLastOpenedMappingsDirectory(), "*.ltn");
fileChooser->launchAsync(FileBrowserComponent::FileChooserFlags::saveMode | FileBrowserComponent::FileChooserFlags::warnAboutOverwriting,
[this, saveFileCallback](const FileChooser& chooser)
{
Expand Down

0 comments on commit 8e8acec

Please sign in to comment.