From f9c632d773ba2e39ec99cf9c7cf7e79676305071 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 24 May 2016 22:55:10 +0200 Subject: [PATCH] Multi device support: attempt to fix default preset load and save --- sdrbase/mainwindow.cpp | 44 +++++++++++++++++++++++------------------- sdrbase/mainwindow.h | 6 +++--- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 1d6986c2d..a3b6d3948 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -145,7 +145,7 @@ MainWindow::MainWindow(QWidget* parent) : qDebug() << "MainWindow::MainWindow: load current preset settings..."; - loadPresetSettings(m_settings.getWorkingPreset()); + loadPresetSettings(m_settings.getWorkingPreset(), 0); qDebug() << "MainWindow::MainWindow: apply settings..."; @@ -294,18 +294,18 @@ void MainWindow::loadSettings() } } -void MainWindow::loadPresetSettings(const Preset* preset) +void MainWindow::loadPresetSettings(const Preset* preset, int tabIndex) { qDebug("MainWindow::loadPresetSettings: preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); // Load into currently selected source tab - int currentSourceTabIndex = ui->tabInputsView->currentIndex(); + //int currentSourceTabIndex = ui->tabInputsView->currentIndex(); - if (currentSourceTabIndex >= 0) + if (tabIndex >= 0) { - DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; + DeviceUISet *deviceUI = m_deviceUIs[tabIndex]; deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig()); deviceUI->m_deviceAPI->loadChannelSettings(preset, &(m_pluginManager->m_pluginAPI)); deviceUI->m_deviceAPI->loadSourceSettings(preset); @@ -315,23 +315,23 @@ void MainWindow::loadPresetSettings(const Preset* preset) restoreState(preset->getLayout()); } -void MainWindow::saveSettings() -{ - qDebug() << "MainWindow::saveSettings"; +//void MainWindow::saveSettings() +//{ +// qDebug() << "MainWindow::saveSettings"; +// +// savePresetSettings(m_settings.getWorkingPreset()); +// m_settings.save(); +//} - savePresetSettings(m_settings.getWorkingPreset()); - m_settings.save(); -} - -void MainWindow::savePresetSettings(Preset* preset) +void MainWindow::savePresetSettings(Preset* preset, int tabIndex) { qDebug("MainWindow::savePresetSettings: preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); // Save from currently selected source tab - int currentSourceTabIndex = ui->tabInputsView->currentIndex(); - DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; + //int currentSourceTabIndex = ui->tabInputsView->currentIndex(); + DeviceUISet *deviceUI = m_deviceUIs[tabIndex]; preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize()); preset->clearChannels(); @@ -455,7 +455,7 @@ void MainWindow::on_presetSave_clicked() if(dlg.exec() == QDialog::Accepted) { Preset* preset = m_settings.newPreset(dlg.group(), dlg.description()); - savePresetSettings(preset); + savePresetSettings(preset, ui->tabInputsView->currentIndex()); ui->presetTree->setCurrentItem(addPresetToTree(preset)); } @@ -470,7 +470,7 @@ void MainWindow::on_presetUpdate_clicked() const Preset* preset = qvariant_cast(item->data(0, Qt::UserRole)); if (preset != 0) { Preset* preset_mod = const_cast(preset); - savePresetSettings(preset_mod); + savePresetSettings(preset_mod, ui->tabInputsView->currentIndex()); } } } @@ -559,7 +559,9 @@ void MainWindow::on_presetImport_clicked() void MainWindow::on_settingsSave_clicked() { - saveSettings(); +// saveSettings(); + savePresetSettings(m_settings.getWorkingPreset(), ui->tabInputsView->currentIndex()); + m_settings.save(); } void MainWindow::on_presetLoad_clicked() @@ -583,7 +585,7 @@ void MainWindow::on_presetLoad_clicked() return; } - loadPresetSettings(preset); + loadPresetSettings(preset, ui->tabInputsView->currentIndex()); applySettings(); } @@ -715,7 +717,9 @@ void MainWindow::on_action_removeDevice_triggered() void MainWindow::on_action_Exit_triggered() { - saveSettings(); +// saveSettings(); + savePresetSettings(m_settings.getWorkingPreset(), 0); + m_settings.save(); while (m_deviceUIs.size() > 0) { diff --git a/sdrbase/mainwindow.h b/sdrbase/mainwindow.h index c0835a1ba..0652d1419 100644 --- a/sdrbase/mainwindow.h +++ b/sdrbase/mainwindow.h @@ -121,9 +121,9 @@ private: std::string m_sampleFileName; void loadSettings(); - void loadPresetSettings(const Preset* preset); - void savePresetSettings(Preset* preset); - void saveSettings(); + void loadPresetSettings(const Preset* preset, int tabIndex); + void savePresetSettings(Preset* preset, int tabIndex); +// void saveSettings(); void createStatusBar(); void closeEvent(QCloseEvent*);