Skip to content

Commit

Permalink
fix setHasChangesToSave ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Aug 10, 2024
1 parent b7c910e commit 80d8b19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
30 changes: 12 additions & 18 deletions Source/LumatoneEditorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -453,7 +447,7 @@ bool LumatoneEditorState::Controller::resetToCurrentFile()
LumatoneLayout defaultLayout;
editorState.setCompleteConfig(defaultLayout);
*editorState.lastSavedLayout = defaultLayout;
editorState.setHasChangesToSave(false);
setHasChangesToSave(false);
return true;
}

Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -594,4 +589,3 @@ void LumatoneEditorState::Controller::setDeveloperMode(bool developerModeOn)
editorState.setStateProperty(LumatoneEditorProperty::DeveloperModeOn, editorState.inDeveloperMode);
savePropertyBoolValue(LumatoneEditorProperty::DeveloperModeOn, developerModeOn);
}

8 changes: 2 additions & 6 deletions Source/LumatoneEditorState.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ class LumatoneEditorState : public LumatoneApplicationState

void loadPropertiesFile(juce::PropertiesFile* properties);

void setHasChangesToSave(bool hasChangesToSave);

protected:
bool hasChangesToSave = false;
bool hasChangesToSend = false;
Expand Down Expand Up @@ -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<LumatoneEditorColourPalette>& 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(); }
Expand All @@ -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);
Expand Down

0 comments on commit 80d8b19

Please sign in to comment.