From 7aa5fc91cf58c8cd1cbcf584b967cdbc81c27e40 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 6 Aug 2022 01:03:51 +0200 Subject: [PATCH] The flux source/sink value is now persistent. --- src/gui/mainwindow.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/mainwindow.cc b/src/gui/mainwindow.cc index d8ce833c..7a561ba8 100644 --- a/src/gui/mainwindow.cc +++ b/src/gui/mainwindow.cc @@ -19,6 +19,9 @@ extern const std::map formats; +#define CONFIG_FORMAT "Format" +#define CONFIG_FLUX "FluxSourceSink" + MainWindow::MainWindow(): MainWindowGen(nullptr), _config("FluxEngine") @@ -34,7 +37,7 @@ MainWindow::MainWindow(): }); wxString defaultFormatName = "ibm"; - _config.Read("Format", &defaultFormatName); + _config.Read(CONFIG_FORMAT, &defaultFormatName); int defaultFormat = 0; int i = 0; @@ -60,9 +63,12 @@ MainWindow::MainWindow(): if (MainWindow::formatChoice->GetCount() > 0) formatChoice->SetSelection(defaultFormat); - fluxSourceSinkCombo->SetValue(fluxSourceSinkCombo->GetString(0)); + wxString defaultFluxSourceSink = fluxSourceSinkCombo->GetString(0); + _config.Read(CONFIG_FLUX, &defaultFluxSourceSink); + fluxSourceSinkCombo->SetValue(defaultFluxSourceSink); formatChoice->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &MainWindow::OnControlsChanged, this); + fluxSourceSinkCombo->Bind(wxEVT_TEXT, &MainWindow::OnControlsChanged, this); readFluxButton->Bind(wxEVT_BUTTON, &MainWindow::OnReadFluxButton, this); readImageButton->Bind(wxEVT_BUTTON, &MainWindow::OnReadImageButton, this); writeFluxButton->Bind(wxEVT_BUTTON, &MainWindow::OnWriteFluxButton, this); @@ -80,9 +86,10 @@ void MainWindow::OnExit(wxCommandEvent& event) void MainWindow::OnControlsChanged(wxCommandEvent& event) { - _config.Write("Format", + _config.Write(CONFIG_FORMAT, formatChoice->GetString(formatChoice->GetSelection())); - _config.Flush(); + _config.Write(CONFIG_FLUX, + fluxSourceSinkCombo->GetValue()); } void MainWindow::OnStopButton(wxCommandEvent&)