diff --git a/Source/LumatoneEditorState.cpp b/Source/LumatoneEditorState.cpp index 362f61b..d8e46e4 100644 --- a/Source/LumatoneEditorState.cpp +++ b/Source/LumatoneEditorState.cpp @@ -197,12 +197,6 @@ juce::File LumatoneEditorState::getLastOpenedMappingsDirectory() const return recentFiles->getFile(0).getParentDirectory(); } -void LumatoneEditorState::setHasChangesToSave(bool hasChangesToSaveIn) -{ - hasChangesToSave = hasChangesToSaveIn; - setStateProperty(LumatoneEditorProperty::HasChangesToSave, hasChangesToSave); -} - void LumatoneEditorState::addColourSelectionBroadcaster(ColourSelectionBroadcaster *broadcasterIn) { colourSelectionGroup->addSelector(broadcasterIn); @@ -453,7 +447,7 @@ bool LumatoneEditorState::Controller::resetToCurrentFile() LumatoneLayout defaultLayout; editorState.setCompleteConfig(defaultLayout); *editorState.lastSavedLayout = defaultLayout; - editorState.setHasChangesToSave(false); + setHasChangesToSave(false); return true; } @@ -470,7 +464,7 @@ bool LumatoneEditorState::Controller::resetToCurrentFile() } // Mark file as unchanged (would prefer to do this after, but this works better for callbacks) - editorState.setHasChangesToSave(false); + setHasChangesToSave(false); // Send configuration to controller, if connected editorState.setCompleteConfig(keyMapping); @@ -496,11 +490,13 @@ bool LumatoneEditorState::Controller::resetToCurrentFile() return false; } -bool LumatoneEditorState::Controller::setCurrentFile(File fileToOpen) +bool LumatoneEditorState::Controller::setCurrentFile(File fileToOpen, bool loadFile) { editorState.currentFile = fileToOpen; editorState.setStateProperty(LumatoneEditorProperty::CurrentFile, editorState.currentFile.getFullPathName()); - return resetToCurrentFile(); + if (loadFile) + return resetToCurrentFile(); + return true; } // open a file from the "recent files" menu @@ -510,13 +506,6 @@ bool LumatoneEditorState::Controller::openRecentFile(int recentFileIndex) return setCurrentFile(editorState.recentFiles->getFile(recentFileIndex)); } -bool LumatoneEditorState::Controller::requestCompleteDeviceConfig() -{ - setHasChangesToSave(false); - editorState.undoManager->clearUndoHistory(); - return LumatoneApplicationState::Controller::requestCompleteDeviceConfig(); -} - bool LumatoneEditorState::Controller::saveMappingToFile(juce::File fileToSave) { juce::StringArray stringArray = editorState.getMappingData()->toStringArray(); @@ -580,6 +569,12 @@ void LumatoneEditorState::Controller::savePropertyStringValue(const juce::Identi editorState.setStateProperty(id, juce::var(value)); } +void LumatoneEditorState::Controller::setHasChangesToSave(bool hasChanges) +{ + editorState.hasChangesToSave = hasChanges; + editorState.setStateProperty(LumatoneEditorProperty::HasChangesToSave, hasChanges); +} + void LumatoneEditorState::Controller::setCalibrationMode(bool calibrationModeOn) { editorState.inCalibrationMode = calibrationModeOn; @@ -594,4 +589,3 @@ void LumatoneEditorState::Controller::setDeveloperMode(bool developerModeOn) editorState.setStateProperty(LumatoneEditorProperty::DeveloperModeOn, editorState.inDeveloperMode); savePropertyBoolValue(LumatoneEditorProperty::DeveloperModeOn, developerModeOn); } - diff --git a/Source/LumatoneEditorState.h b/Source/LumatoneEditorState.h index 19a4e2f..2f51766 100644 --- a/Source/LumatoneEditorState.h +++ b/Source/LumatoneEditorState.h @@ -148,8 +148,6 @@ class LumatoneEditorState : public LumatoneApplicationState void loadPropertiesFile(juce::PropertiesFile* properties); - void setHasChangesToSave(bool hasChangesToSave); - protected: bool hasChangesToSave = false; bool hasChangesToSend = false; @@ -207,15 +205,13 @@ class LumatoneEditorState : public LumatoneApplicationState bool resetToCurrentFile(); bool openRecentFile(int recentFileIndex); - virtual bool requestCompleteDeviceConfig() override; - void addPalette(const LumatoneEditorColourPalette& newPalette); bool deletePaletteFile(juce::File pathToPalette); void setColourPalettes(const juce::Array& palettesIn); void loadColourPalettesFromFile(); - bool setCurrentFile(juce::File fileToOpen); + bool setCurrentFile(juce::File fileToOpen, bool loadFile=true); bool saveMappingToFile(juce::File fileToSave); juce::PropertiesFile* getPropertiesFile() const { return editorState.propertiesFile.get(); } @@ -226,7 +222,7 @@ class LumatoneEditorState : public LumatoneApplicationState void savePropertyIntValue(const juce::Identifier& id, int value); void savePropertyStringValue(const juce::Identifier& id, juce::String value); - void setHasChangesToSave(bool hasChanges) { editorState.setHasChangesToSave(hasChanges); } + void setHasChangesToSave(bool hasChanges); void setCalibrationMode(bool calibrationModeOn); void setDeveloperMode(bool developerModeOn); void setEditMode(EditorMode editMode);