mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-07 16:34:45 -04:00
Add support for plugin presets.
This commit is contained in:
+24
-5
@@ -92,6 +92,7 @@
|
||||
#include "webapi/webapiserver.h"
|
||||
#include "webapi/webapiadapter.h"
|
||||
#include "commands/command.h"
|
||||
#include "settings/serializableinterface.h"
|
||||
#ifdef ANDROID
|
||||
#include "util/android.h"
|
||||
#endif
|
||||
@@ -403,6 +404,7 @@ void MainWindow::sampleSourceAdd(Workspace *deviceWorkspace, Workspace *spectrum
|
||||
|
||||
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
|
||||
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
|
||||
loadDefaultPreset(deviceAPI->getSamplingDeviceId(), m_deviceUIs.back());
|
||||
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
|
||||
|
||||
#ifdef ANDROID
|
||||
@@ -638,6 +640,7 @@ void MainWindow::sampleSinkAdd(Workspace *deviceWorkspace, Workspace *spectrumWo
|
||||
|
||||
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
|
||||
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
|
||||
loadDefaultPreset(deviceAPI->getSamplingDeviceId(), m_deviceUIs.back());
|
||||
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
|
||||
}
|
||||
|
||||
@@ -869,6 +872,7 @@ void MainWindow::sampleMIMOAdd(Workspace *deviceWorkspace, Workspace *spectrumWo
|
||||
|
||||
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
|
||||
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
|
||||
loadDefaultPreset(deviceAPI->getSamplingDeviceId(), m_deviceUIs.back());
|
||||
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
|
||||
}
|
||||
|
||||
@@ -2777,13 +2781,13 @@ void MainWindow::channelAddClicked(Workspace *workspace, int deviceSetIndex, int
|
||||
{
|
||||
DeviceUISet *deviceUI = m_deviceUIs[deviceSetIndex];
|
||||
ChannelGUI *gui = nullptr;
|
||||
ChannelAPI *channelAPI;
|
||||
DeviceAPI *deviceAPI = deviceUI->m_deviceAPI;
|
||||
|
||||
if (deviceUI->m_deviceSourceEngine) // source device => Rx channels
|
||||
{
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getRxChannelRegistrations(); // Available channel plugins
|
||||
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex].m_plugin;
|
||||
ChannelAPI *channelAPI;
|
||||
BasebandSampleSink *rxChannel;
|
||||
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
|
||||
gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
|
||||
@@ -2796,7 +2800,6 @@ void MainWindow::channelAddClicked(Workspace *workspace, int deviceSetIndex, int
|
||||
{
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getTxChannelRegistrations(); // Available channel plugins
|
||||
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex].m_plugin;
|
||||
ChannelAPI *channelAPI;
|
||||
BasebandSampleSource *txChannel;
|
||||
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
|
||||
gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
|
||||
@@ -2817,7 +2820,6 @@ void MainWindow::channelAddClicked(Workspace *workspace, int deviceSetIndex, int
|
||||
{
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getMIMOChannelRegistrations(); // Available channel plugins
|
||||
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex].m_plugin;
|
||||
ChannelAPI *channelAPI;
|
||||
MIMOChannel *mimoChannel;
|
||||
pluginInterface->createMIMOChannel(deviceUI->m_deviceAPI, &mimoChannel, &channelAPI);
|
||||
gui = pluginInterface->createMIMOChannelGUI(deviceUI, mimoChannel);
|
||||
@@ -2829,7 +2831,6 @@ void MainWindow::channelAddClicked(Workspace *workspace, int deviceSetIndex, int
|
||||
{
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getRxChannelRegistrations(); // Available channel plugins
|
||||
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex - nbMIMOChannels].m_plugin;
|
||||
ChannelAPI *channelAPI;
|
||||
BasebandSampleSink *rxChannel;
|
||||
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
|
||||
gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
|
||||
@@ -2841,7 +2842,6 @@ void MainWindow::channelAddClicked(Workspace *workspace, int deviceSetIndex, int
|
||||
{
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getTxChannelRegistrations(); // Available channel plugins
|
||||
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex - nbMIMOChannels - nbRxChannels].m_plugin;
|
||||
ChannelAPI *channelAPI;
|
||||
BasebandSampleSource *txChannel;
|
||||
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
|
||||
gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
|
||||
@@ -2881,6 +2881,7 @@ void MainWindow::channelAddClicked(Workspace *workspace, int deviceSetIndex, int
|
||||
qPrintable(gui->getTitle()), workspace->getIndex());
|
||||
workspace->addToMdiArea((QMdiSubWindow*) gui);
|
||||
//gui->restoreGeometry(gui->getGeometryBytes());
|
||||
loadDefaultPreset(channelAPI->getURI(), gui);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2901,6 +2902,7 @@ void MainWindow::featureAddClicked(Workspace *workspace, int featureIndex)
|
||||
gui->setWorkspaceIndex(workspace->getIndex());
|
||||
gui->setDisplayedame(pluginInterface->getPluginDescriptor().displayedName);
|
||||
workspace->addToMdiArea((QMdiSubWindow*) gui);
|
||||
loadDefaultPreset(feature->getURI(), gui);
|
||||
|
||||
QObject::connect(
|
||||
gui,
|
||||
@@ -3087,6 +3089,23 @@ void MainWindow::deleteFeature(int featureSetIndex, int featureIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// Look for and load a preset named Defaults/Default for the given plugin id
|
||||
void MainWindow::loadDefaultPreset(const QString& pluginId, SerializableInterface *serializableInterface)
|
||||
{
|
||||
QList<PluginPreset*>* presets = m_mainCore->m_settings.getPluginPresets();
|
||||
|
||||
for (const auto preset : *presets)
|
||||
{
|
||||
if (preset->getGroup() == "Defaults"
|
||||
&& preset->getDescription() == "Default"
|
||||
&& preset->getPluginIdURI() == pluginId)
|
||||
{
|
||||
qDebug() << "MainWindow::loadDefaultPreset: Loading " << preset->getGroup() << preset->getDescription() << "for" << pluginId;
|
||||
serializableInterface->deserialize(preset->getConfig());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_About_triggered()
|
||||
{
|
||||
AboutDialog dlg(m_apiHost.isEmpty() ? "127.0.0.1" : m_apiHost, m_apiPort, m_mainCore->m_settings, this);
|
||||
|
||||
Reference in New Issue
Block a user