1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-12 11:26:11 -05:00

Add GUI to device set outside plugin

This commit is contained in:
f4exb 2020-10-03 03:09:36 +02:00
parent b8568feb47
commit 7a0f15acaf
5 changed files with 41 additions and 28 deletions

View File

@ -128,8 +128,6 @@ public:
PluginInterface *getPluginInterface() { return m_pluginInterface; }
PluginInstanceGUI *getSamplingDevicePluginInstanceGUI() { return m_samplingDevicePluginInstanceUI; }
// PluginInstanceGUI *getSampleSourcePluginInstanceGUI() { return m_sampleSourcePluginInstanceUI; }
// PluginInstanceGUI *getSampleSinkPluginInstanceGUI() { return m_sampleSinkPluginInstanceUI; }
void getDeviceEngineStateStr(QString& state, int subsystemIndex = 0);

View File

@ -22,7 +22,6 @@
#include <cstdio>
#include <algorithm>
#include <plugin/plugininstancegui.h>
#include "device/deviceenumerator.h"
#include "settings/preset.h"
#include "util/message.h"

View File

@ -91,21 +91,21 @@ void DeviceUISet::addRollupWidget(QWidget *widget)
m_channelWindow->addRollupWidget(widget);
}
void DeviceUISet::registerRxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI)
void DeviceUISet::registerRxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, PluginInstanceGUI* pluginGUI)
{
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI, 0));
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, pluginGUI, 0));
renameChannelInstances();
}
void DeviceUISet::registerTxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI)
void DeviceUISet::registerTxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, PluginInstanceGUI* pluginGUI)
{
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI, 1));
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, pluginGUI, 1));
renameChannelInstances();
}
void DeviceUISet::registerChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI)
void DeviceUISet::registerChannelInstance(const QString& channelName, ChannelAPI *channelAPI, PluginInstanceGUI* pluginGUI)
{
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI, 2));
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, pluginGUI, 2));
renameChannelInstances();
}
@ -208,11 +208,12 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
qDebug("DeviceUISet::loadRxChannelSettings: creating new channel [%s] from config [%s]",
qPrintable((*channelRegistrations)[i].m_channelIdURI),
qPrintable(channelConfig.m_channelIdURI));
ChannelAPI *channelAPI;
BasebandSampleSink *rxChannel;
(*channelRegistrations)[i].m_plugin->createRxChannel(m_deviceAPI, &rxChannel, nullptr);
(*channelRegistrations)[i].m_plugin->createRxChannel(m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *rxChannelGUI =
(*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, rxChannelGUI, 0);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, channelAPI, rxChannelGUI, 0);
break;
}
}
@ -285,11 +286,12 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
qDebug("DeviceUISet::loadTxChannelSettings: creating new channel [%s] from config [%s]",
qPrintable((*channelRegistrations)[i].m_channelIdURI),
qPrintable(channelConfig.m_channelIdURI));
ChannelAPI *channelAPI;
BasebandSampleSource *txChannel;
(*channelRegistrations)[i].m_plugin->createTxChannel(m_deviceAPI, &txChannel, nullptr);
(*channelRegistrations)[i].m_plugin->createTxChannel(m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *txChannelGUI =
(*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, txChannelGUI, 1);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, channelAPI, txChannelGUI, 1);
break;
}
}
@ -364,11 +366,13 @@ void DeviceUISet::loadMIMOChannelSettings(const Preset *preset, PluginAPI *plugi
qDebug("DeviceUISet::loadMIMOChannelSettings: creating new channel [%s] from config [%s]",
qPrintable((*channelRegistrations)[i].m_channelIdURI),
qPrintable(channelConfig.m_channelIdURI));
ChannelAPI *channelAPI;
MIMOChannel *mimoChannel;
(*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, nullptr);
(*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI);
PluginInstanceGUI *mimoChannelGUI =
(*channelRegistrations)[i].m_plugin->createMIMOChannelGUI(this, mimoChannel);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, mimoChannelGUI, 2);
(*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, channelAPI, mimoChannelGUI, 2);
break;
}
}

View File

@ -34,6 +34,7 @@ class DSPDeviceMIMOEngine;
class ChannelMarker;
class PluginAPI;
class PluginInstanceGUI;
class ChannelAPI;
class Preset;
class SDRGUI_API DeviceUISet
@ -66,9 +67,9 @@ public:
void saveTxChannelSettings(Preset* preset);
void loadMIMOChannelSettings(const Preset* preset, PluginAPI *pluginAPI);
void saveMIMOChannelSettings(Preset* preset);
void registerRxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI);
void registerTxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI);
void registerChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI);
void registerRxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, PluginInstanceGUI* pluginGUI);
void registerTxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, PluginInstanceGUI* pluginGUI);
void registerChannelInstance(const QString& channelName, ChannelAPI *channelAPI, PluginInstanceGUI* pluginGUI);
void removeRxChannelInstance(PluginInstanceGUI* pluginGUI);
void removeTxChannelInstance(PluginInstanceGUI* pluginGUI);
void removeChannelInstance(PluginInstanceGUI* pluginGUI);
@ -85,17 +86,20 @@ private:
struct ChannelInstanceRegistration
{
QString m_channelName;
ChannelAPI *m_channelAPI;
PluginInstanceGUI* m_gui;
int m_channelType;
ChannelInstanceRegistration() :
m_channelName(),
m_channelAPI(nullptr),
m_gui(nullptr),
m_channelType(0)
{ }
ChannelInstanceRegistration(const QString& channelName, PluginInstanceGUI* pluginGUI, int channelType) :
ChannelInstanceRegistration(const QString& channelName, ChannelAPI *channelAPI, PluginInstanceGUI* pluginGUI, int channelType) :
m_channelName(channelName),
m_channelAPI(channelAPI),
m_gui(pluginGUI),
m_channelType(channelType)
{ }

View File

@ -1922,17 +1922,21 @@ void MainWindow::channelAddClicked(int channelIndex)
{
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getRxChannelRegistrations(); // Available channel plugins
PluginInterface *pluginInterface = (*channelRegistrations)[channelIndex].m_plugin;
ChannelAPI *channelAPI;
BasebandSampleSink *rxChannel;
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, nullptr);
pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(gui->getName(), channelAPI, gui);
}
else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels
{
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getTxChannelRegistrations(); // Available channel plugins
PluginInterface *pluginInterface = (*channelRegistrations)[channelIndex].m_plugin;
ChannelAPI *channelAPI;
BasebandSampleSource *txChannel;
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, nullptr);
pluginInterface->createTxChannelGUI(deviceUI, txChannel);
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(gui->getName(), channelAPI, gui);
}
else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range
{
@ -1945,17 +1949,21 @@ void MainWindow::channelAddClicked(int channelIndex)
{
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getRxChannelRegistrations(); // Available channel plugins
PluginInterface *pluginInterface = (*channelRegistrations)[channelIndex].m_plugin;
ChannelAPI *channelAPI;
BasebandSampleSink *rxChannel;
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, nullptr);
pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(gui->getName(), channelAPI, gui);
}
else if (channelIndex < nbRxChannels + nbTxChannels)
{
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getTxChannelRegistrations(); // Available channel plugins
PluginInterface *pluginInterface = (*channelRegistrations)[channelIndex - nbRxChannels].m_plugin;
ChannelAPI *channelAPI;
BasebandSampleSource *txChannel;
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, nullptr);
pluginInterface->createTxChannelGUI(deviceUI, txChannel);
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(gui->getName(), channelAPI, gui);
}
}
}