diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index 90412e4c1..398a3ea6d 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -199,6 +199,18 @@ void DeviceAPI::saveSourceSettings(Preset* preset) } } +void DeviceAPI::saveChannelSettings(Preset *preset) +{ + qDebug("DeviceAPI::saveChannelSettings"); + + qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type + + for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) + { + preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize()); + } +} + // sort by increasing delta frequency and type (i.e. name) bool DeviceAPI::ChannelInstanceRegistration::operator<(const ChannelInstanceRegistration& other) const { diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h index d2e02a295..83328e76f 100644 --- a/sdrbase/device/deviceapi.h +++ b/sdrbase/device/deviceapi.h @@ -73,6 +73,7 @@ public: void loadSourceSettings(const Preset* preset); void saveSourceSettings(Preset* preset); + void saveChannelSettings(Preset* preset); protected: struct ChannelInstanceRegistration diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 53fd4dd09..366ca7998 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -316,7 +316,7 @@ void MainWindow::loadPresetSettings(const Preset* preset) { DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig()); - deviceUI->m_pluginManager->loadSettings(preset, deviceUI->m_deviceAPI); + deviceUI->m_pluginManager->loadChannelSettings(preset, deviceUI->m_deviceAPI); deviceUI->m_deviceAPI->loadSourceSettings(preset); } diff --git a/sdrbase/plugin/pluginapi.h b/sdrbase/plugin/pluginapi.h index 5724c18de..338126fa8 100644 --- a/sdrbase/plugin/pluginapi.h +++ b/sdrbase/plugin/pluginapi.h @@ -2,6 +2,8 @@ #define INCLUDE_PLUGINAPI_H #include +#include + #include "util/export.h" class QString; @@ -16,6 +18,18 @@ class SDRANGEL_API PluginAPI : public QObject { Q_OBJECT public: + struct ChannelRegistration + { + QString m_channelName; + PluginInterface* m_plugin; + ChannelRegistration(const QString& channelName, PluginInterface* plugin) : + m_channelName(channelName), + m_plugin(plugin) + { } + }; + + typedef QList ChannelRegistrations; + // MainWindow access MessageQueue* getMainWindowMessageQueue(); diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index b82c0c414..9627c19da 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -56,7 +56,7 @@ void PluginManager::loadPlugins() void PluginManager::registerChannel(const QString& channelName, PluginInterface* plugin) { - m_channelRegistrations.append(ChannelRegistration(channelName, plugin)); + m_channelRegistrations.append(PluginAPI::ChannelRegistration(channelName, plugin)); } void PluginManager::registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI) @@ -85,7 +85,7 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin)); } -void PluginManager::loadSettings(const Preset* preset, DeviceAPI *deviceAPI) +void PluginManager::loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI) { fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); @@ -507,7 +507,7 @@ void PluginManager::renameChannelInstances() void PluginManager::populateChannelComboBox(QComboBox *channels) { - for(ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it) + for(PluginAPI::ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it) { const PluginDescriptor& pluginDescipror = it->m_plugin->getPluginDescriptor(); channels->addItem(pluginDescipror.displayedName); diff --git a/sdrbase/plugin/pluginmanager.h b/sdrbase/plugin/pluginmanager.h index f3f26a943..4d6c4d36c 100644 --- a/sdrbase/plugin/pluginmanager.h +++ b/sdrbase/plugin/pluginmanager.h @@ -47,7 +47,7 @@ public: void removeChannelInstance(PluginGUI* pluginGUI); void registerSampleSource(const QString& sourceName, PluginInterface* plugin); - void loadSettings(const Preset* preset, DeviceAPI *deviceAPI); + void loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI); // void loadSourceSettings(const Preset* preset); void saveSettings(Preset* preset); // void saveSourceSettings(Preset* preset); @@ -67,16 +67,6 @@ public: void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI); private: - struct ChannelRegistration { - QString m_channelName; - PluginInterface* m_plugin; - ChannelRegistration(const QString& channelName, PluginInterface* plugin) : - m_channelName(channelName), - m_plugin(plugin) - { } - }; - typedef QList ChannelRegistrations; - struct ChannelInstanceRegistration { QString m_channelName; PluginGUI* m_gui; @@ -129,7 +119,7 @@ private: DSPDeviceEngine* m_dspDeviceEngine; Plugins m_plugins; - ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here + PluginAPI::ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here ChannelInstanceRegistrations m_channelInstanceRegistrations; // TODO: remove SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system