From 4f576af4b4dd7d49c92856d4de68a697136090b9 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Sun, 11 Aug 2024 00:15:36 -0400 Subject: [PATCH] restore firmwarelistener in setting dialogs --- Source/Settings/CalibrationDlg.cpp | 4 ++-- Source/Settings/FirmwareDlg.cpp | 4 ++-- Source/Settings/MidiSettingsDlg.cpp | 5 ++--- Source/Settings/PresetSettingsDlg.cpp | 15 ++++++++------- Source/Settings/PresetSettingsDlg.h | 7 +++---- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/Settings/CalibrationDlg.cpp b/Source/Settings/CalibrationDlg.cpp index dd102a5b..300ff198 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 c0a16430..74a7c90b 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 fc4d389a..d02991b9 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 2254e0ef..d5f789c3 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 df5cc346..263dcb41 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: