mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
Multi device support: attempt to fix default preset load and save
This commit is contained in:
parent
3e1236f898
commit
f9c632d773
@ -145,7 +145,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: load current preset settings...";
|
qDebug() << "MainWindow::MainWindow: load current preset settings...";
|
||||||
|
|
||||||
loadPresetSettings(m_settings.getWorkingPreset());
|
loadPresetSettings(m_settings.getWorkingPreset(), 0);
|
||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: apply settings...";
|
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]",
|
qDebug("MainWindow::loadPresetSettings: preset [%s | %s]",
|
||||||
qPrintable(preset->getGroup()),
|
qPrintable(preset->getGroup()),
|
||||||
qPrintable(preset->getDescription()));
|
qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
// Load into currently selected source tab
|
// 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_spectrumGUI->deserialize(preset->getSpectrumConfig());
|
||||||
deviceUI->m_deviceAPI->loadChannelSettings(preset, &(m_pluginManager->m_pluginAPI));
|
deviceUI->m_deviceAPI->loadChannelSettings(preset, &(m_pluginManager->m_pluginAPI));
|
||||||
deviceUI->m_deviceAPI->loadSourceSettings(preset);
|
deviceUI->m_deviceAPI->loadSourceSettings(preset);
|
||||||
@ -315,23 +315,23 @@ void MainWindow::loadPresetSettings(const Preset* preset)
|
|||||||
restoreState(preset->getLayout());
|
restoreState(preset->getLayout());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::saveSettings()
|
//void MainWindow::saveSettings()
|
||||||
{
|
//{
|
||||||
qDebug() << "MainWindow::saveSettings";
|
// qDebug() << "MainWindow::saveSettings";
|
||||||
|
//
|
||||||
|
// savePresetSettings(m_settings.getWorkingPreset());
|
||||||
|
// m_settings.save();
|
||||||
|
//}
|
||||||
|
|
||||||
savePresetSettings(m_settings.getWorkingPreset());
|
void MainWindow::savePresetSettings(Preset* preset, int tabIndex)
|
||||||
m_settings.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::savePresetSettings(Preset* preset)
|
|
||||||
{
|
{
|
||||||
qDebug("MainWindow::savePresetSettings: preset [%s | %s]",
|
qDebug("MainWindow::savePresetSettings: preset [%s | %s]",
|
||||||
qPrintable(preset->getGroup()),
|
qPrintable(preset->getGroup()),
|
||||||
qPrintable(preset->getDescription()));
|
qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
// Save from currently selected source tab
|
// Save from currently selected source tab
|
||||||
int currentSourceTabIndex = ui->tabInputsView->currentIndex();
|
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
|
||||||
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
DeviceUISet *deviceUI = m_deviceUIs[tabIndex];
|
||||||
|
|
||||||
preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize());
|
preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize());
|
||||||
preset->clearChannels();
|
preset->clearChannels();
|
||||||
@ -455,7 +455,7 @@ void MainWindow::on_presetSave_clicked()
|
|||||||
|
|
||||||
if(dlg.exec() == QDialog::Accepted) {
|
if(dlg.exec() == QDialog::Accepted) {
|
||||||
Preset* preset = m_settings.newPreset(dlg.group(), dlg.description());
|
Preset* preset = m_settings.newPreset(dlg.group(), dlg.description());
|
||||||
savePresetSettings(preset);
|
savePresetSettings(preset, ui->tabInputsView->currentIndex());
|
||||||
|
|
||||||
ui->presetTree->setCurrentItem(addPresetToTree(preset));
|
ui->presetTree->setCurrentItem(addPresetToTree(preset));
|
||||||
}
|
}
|
||||||
@ -470,7 +470,7 @@ void MainWindow::on_presetUpdate_clicked()
|
|||||||
const Preset* preset = qvariant_cast<const Preset*>(item->data(0, Qt::UserRole));
|
const Preset* preset = qvariant_cast<const Preset*>(item->data(0, Qt::UserRole));
|
||||||
if (preset != 0) {
|
if (preset != 0) {
|
||||||
Preset* preset_mod = const_cast<Preset*>(preset);
|
Preset* preset_mod = const_cast<Preset*>(preset);
|
||||||
savePresetSettings(preset_mod);
|
savePresetSettings(preset_mod, ui->tabInputsView->currentIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,7 +559,9 @@ void MainWindow::on_presetImport_clicked()
|
|||||||
|
|
||||||
void MainWindow::on_settingsSave_clicked()
|
void MainWindow::on_settingsSave_clicked()
|
||||||
{
|
{
|
||||||
saveSettings();
|
// saveSettings();
|
||||||
|
savePresetSettings(m_settings.getWorkingPreset(), ui->tabInputsView->currentIndex());
|
||||||
|
m_settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_presetLoad_clicked()
|
void MainWindow::on_presetLoad_clicked()
|
||||||
@ -583,7 +585,7 @@ void MainWindow::on_presetLoad_clicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPresetSettings(preset);
|
loadPresetSettings(preset, ui->tabInputsView->currentIndex());
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -715,7 +717,9 @@ void MainWindow::on_action_removeDevice_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_action_Exit_triggered()
|
void MainWindow::on_action_Exit_triggered()
|
||||||
{
|
{
|
||||||
saveSettings();
|
// saveSettings();
|
||||||
|
savePresetSettings(m_settings.getWorkingPreset(), 0);
|
||||||
|
m_settings.save();
|
||||||
|
|
||||||
while (m_deviceUIs.size() > 0)
|
while (m_deviceUIs.size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -121,9 +121,9 @@ private:
|
|||||||
std::string m_sampleFileName;
|
std::string m_sampleFileName;
|
||||||
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void loadPresetSettings(const Preset* preset);
|
void loadPresetSettings(const Preset* preset, int tabIndex);
|
||||||
void savePresetSettings(Preset* preset);
|
void savePresetSettings(Preset* preset, int tabIndex);
|
||||||
void saveSettings();
|
// void saveSettings();
|
||||||
|
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void closeEvent(QCloseEvent*);
|
void closeEvent(QCloseEvent*);
|
||||||
|
Loading…
Reference in New Issue
Block a user