1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-13 20:01:46 -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; } PluginInterface *getPluginInterface() { return m_pluginInterface; }
PluginInstanceGUI *getSamplingDevicePluginInstanceGUI() { return m_samplingDevicePluginInstanceUI; } PluginInstanceGUI *getSamplingDevicePluginInstanceGUI() { return m_samplingDevicePluginInstanceUI; }
// PluginInstanceGUI *getSampleSourcePluginInstanceGUI() { return m_sampleSourcePluginInstanceUI; }
// PluginInstanceGUI *getSampleSinkPluginInstanceGUI() { return m_sampleSinkPluginInstanceUI; }
void getDeviceEngineStateStr(QString& state, int subsystemIndex = 0); void getDeviceEngineStateStr(QString& state, int subsystemIndex = 0);

View File

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

View File

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

View File

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

View File

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