diff --git a/Source/Settings/CalibrationDlg.cpp b/Source/Settings/CalibrationDlg.cpp index dd102a5..300ff19 100644 --- a/Source/Settings/CalibrationDlg.cpp +++ b/Source/Settings/CalibrationDlg.cpp @@ -69,7 +69,7 @@ CalibrationDlg::CalibrationDlg (const LumatoneEditorState& stateIn) calibrationSelectorTab->addChangeListener(this); - // getLumatoneController()->addFirmwareListener(this); + addFirmwareListener(this); //[/UserPreSize] @@ -86,7 +86,7 @@ CalibrationDlg::CalibrationDlg (const LumatoneEditorState& stateIn) CalibrationDlg::~CalibrationDlg() { //[Destructor_pre]. You can add your own custom destruction code here.. - // getLumatoneController()->removeFirmwareListener(this); + removeFirmwareListener(this); //[/Destructor_pre] btnStart = nullptr; diff --git a/Source/Settings/FirmwareDlg.cpp b/Source/Settings/FirmwareDlg.cpp index c0a1643..74a7c90 100644 --- a/Source/Settings/FirmwareDlg.cpp +++ b/Source/Settings/FirmwareDlg.cpp @@ -59,7 +59,7 @@ FirmwareDlg::FirmwareDlg(const LumatoneEditorState& stateIn) addAndMakeVisible(firmwareStatusLabel.get()); updateFirmwareVersionLabel(); - // getLumatoneController()->addFirmwareListener(this); + addFirmwareListener(this); postMessage(translate("Select a firmware file and then click \"Begin Update\"")); @@ -71,7 +71,7 @@ FirmwareDlg::FirmwareDlg(const LumatoneEditorState& stateIn) FirmwareDlg::~FirmwareDlg() { - // getLumatoneController()->removeFirmwareListener(this); + removeFirmwareListener(this); } void FirmwareDlg::paint(Graphics& g) diff --git a/Source/Settings/MidiSettingsDlg.cpp b/Source/Settings/MidiSettingsDlg.cpp index fc4d389..d02991b 100644 --- a/Source/Settings/MidiSettingsDlg.cpp +++ b/Source/Settings/MidiSettingsDlg.cpp @@ -49,15 +49,14 @@ MidiSettingsDlg::MidiSettingsDlg(const LumatoneEditorState& stateIn) flexBox.justifyContent = FlexBox::JustifyContent::flexStart; flexBox.alignContent = FlexBox::AlignContent::flexStart; - // getLumatoneController()->addFirmwareListener(this); + addFirmwareListener(this); setSupportedControls(getFirmwareVersion()); } MidiSettingsDlg::~MidiSettingsDlg() { - // Not good when app closes with this window open... - // getLumatoneController()->removeFirmwareListener(this); + removeFirmwareListener(this); setMidiChannelHeader = nullptr; setMidiChannelLabels.clear(); diff --git a/Source/Settings/PresetSettingsDlg.cpp b/Source/Settings/PresetSettingsDlg.cpp index 2254e0e..d5f789c 100644 --- a/Source/Settings/PresetSettingsDlg.cpp +++ b/Source/Settings/PresetSettingsDlg.cpp @@ -21,7 +21,6 @@ PresetSettingsDlg::PresetSettingsDlg(const LumatoneEditorState& stateIn) addAndMakeVisible(resetPresetsBtn.get()); resetPresetsBtn->addListener(this); - // getLumatoneController()->addFirmwareListener(this); setSupportedControls(getFirmwareVersion()); flexBox.justifyContent = FlexBox::JustifyContent::flexStart; @@ -30,7 +29,6 @@ PresetSettingsDlg::PresetSettingsDlg(const LumatoneEditorState& stateIn) PresetSettingsDlg::~PresetSettingsDlg() { - // getLumatoneController()->removeFirmwareListener(this); resetPresetsBtn = nullptr; } @@ -62,11 +60,6 @@ void PresetSettingsDlg::buttonClicked(Button* btn) } } -void PresetSettingsDlg::firmwareRevisionReceived(LumatoneFirmware::Version version) -{ - setSupportedControls(version); -} - void PresetSettingsDlg::setSupportedControls(LumatoneFirmware::Version version) { if (getFirmwareSupport().versionAcknowledgesCommand(version, RESET_DEFAULT_PRESETS)) @@ -81,3 +74,11 @@ void PresetSettingsDlg::setSupportedControls(LumatoneFirmware::Version version) // TODO: better approach for changing tooltips } } + +void PresetSettingsDlg::handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier & property) +{ + if (property == LumatoneStateProperty::LastConnectedFirmwareVersion) + { + setSupportedControls(getFirmwareVersion()); + } +} diff --git a/Source/Settings/PresetSettingsDlg.h b/Source/Settings/PresetSettingsDlg.h index df5cc34..263dcb4 100644 --- a/Source/Settings/PresetSettingsDlg.h +++ b/Source/Settings/PresetSettingsDlg.h @@ -19,7 +19,6 @@ class PresetSettingsDlg : public Component , LumatoneEditorState , protected Button::Listener - , protected LumatoneEditor::FirmwareListener { public: @@ -35,10 +34,10 @@ class PresetSettingsDlg : public Component void setSupportedControls(LumatoneFirmware::Version version); - //========================================================================= - // LumatoneEditor::FirmwareListener implementation + //============================================================================== + // Implementation of LumatoneEditorState - void firmwareRevisionReceived(LumatoneFirmware::Version version) override; + void handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier& property) override; private: