Skip to content

Commit

Permalink
restore firmwarelistener in setting dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Aug 11, 2024
1 parent ba8264d commit 4f576af
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Source/Settings/CalibrationDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CalibrationDlg::CalibrationDlg (const LumatoneEditorState& stateIn)

calibrationSelectorTab->addChangeListener(this);

// getLumatoneController()->addFirmwareListener(this);
addFirmwareListener(this);

//[/UserPreSize]

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/Settings/FirmwareDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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\""));

Expand All @@ -71,7 +71,7 @@ FirmwareDlg::FirmwareDlg(const LumatoneEditorState& stateIn)

FirmwareDlg::~FirmwareDlg()
{
// getLumatoneController()->removeFirmwareListener(this);
removeFirmwareListener(this);
}

void FirmwareDlg::paint(Graphics& g)
Expand Down
5 changes: 2 additions & 3 deletions Source/Settings/MidiSettingsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 8 additions & 7 deletions Source/Settings/PresetSettingsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +29,6 @@ PresetSettingsDlg::PresetSettingsDlg(const LumatoneEditorState& stateIn)

PresetSettingsDlg::~PresetSettingsDlg()
{
// getLumatoneController()->removeFirmwareListener(this);
resetPresetsBtn = nullptr;
}

Expand Down Expand Up @@ -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))
Expand All @@ -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());
}
}
7 changes: 3 additions & 4 deletions Source/Settings/PresetSettingsDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class PresetSettingsDlg : public Component
, LumatoneEditorState
, protected Button::Listener
, protected LumatoneEditor::FirmwareListener

{
public:
Expand All @@ -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:
Expand Down

0 comments on commit 4f576af

Please sign in to comment.