mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-05 02:58:37 -04:00
Multi device support: simplify source input setting
This commit is contained in:
parent
86b04a4d62
commit
5a8d05bfaf
@ -118,7 +118,7 @@ PluginInterface::SampleSourceDevices AirspyPlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* AirspyPlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* AirspyPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if (!m_pluginAPI)
|
||||
{
|
||||
@ -128,7 +128,7 @@ PluginGUI* AirspyPlugin::createSampleSourcePluginGUI(const QString& sourceId, co
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
AirspyGui* gui = new AirspyGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -76,7 +76,7 @@ PluginInterface::SampleSourceDevices BlderfPlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* BlderfPlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* BlderfPlugin::createSampleSourcePluginGUI(const QString& sourceId,QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if (!m_pluginAPI)
|
||||
{
|
||||
@ -86,7 +86,7 @@ PluginGUI* BlderfPlugin::createSampleSourcePluginGUI(const QString& sourceId, co
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
BladerfGui* gui = new BladerfGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -75,12 +75,12 @@ PluginInterface::SampleSourceDevices FCDProPlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* FCDProPlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* FCDProPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if(sourceId == fcd_traits<Pro>::interfaceIID)
|
||||
{
|
||||
FCDProGui* gui = new FCDProGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -75,12 +75,12 @@ PluginInterface::SampleSourceDevices FCDProPlusPlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* FCDProPlusPlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* FCDProPlusPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if(sourceId == fcd_traits<ProPlus>::interfaceIID)
|
||||
{
|
||||
FCDProPlusGui* gui = new FCDProPlusGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -68,12 +68,12 @@ PluginInterface::SampleSourceDevices FileSourcePlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* FileSourcePlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* FileSourcePlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
FileSourceGui* gui = new FileSourceGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -113,7 +113,7 @@ PluginInterface::SampleSourceDevices HackRFPlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* HackRFPlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* HackRFPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if (!m_pluginAPI)
|
||||
{
|
||||
@ -123,7 +123,7 @@ PluginGUI* HackRFPlugin::createSampleSourcePluginGUI(const QString& sourceId, co
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
HackRFGui* gui = new HackRFGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -60,11 +60,11 @@ PluginInterface::SampleSourceDevices RTLSDRPlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* RTLSDRPlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* RTLSDRPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if(sourceId == m_deviceTypeID) {
|
||||
RTLSDRGui* gui = new RTLSDRGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
} else {
|
||||
return NULL;
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -68,12 +68,12 @@ PluginInterface::SampleSourceDevices SDRdaemonPlugin::enumSampleSources()
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* SDRdaemonPlugin::createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
PluginGUI* SDRdaemonPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
SDRdaemonGui* gui = new SDRdaemonGui(m_pluginAPI, deviceAPI);
|
||||
deviceAPI->setInputGUI(gui, sourceDisplayName);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI);
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
|
@ -204,6 +204,8 @@ void MainWindow::addDevice()
|
||||
connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int)));
|
||||
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked);
|
||||
ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr);
|
||||
|
||||
int sampleSourceIndex = m_pluginManager->selectSampleSourceBySerialOrSequence("sdrangel.samplesource.filesource", "0", 0, m_deviceUIs.back()->m_deviceAPI);
|
||||
}
|
||||
|
||||
void MainWindow::removeLastDevice()
|
||||
@ -215,10 +217,6 @@ void MainWindow::removeLastDevice()
|
||||
ui->tabSpectraGUI->removeTab(ui->tabSpectraGUI->count() - 1);
|
||||
ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1);
|
||||
|
||||
// PluginManager destructor does freeAll() which does stopAcquistion() but stopAcquistion()
|
||||
// can be done several times only the first is active so it is fine to do it here
|
||||
// On the other hand freeAll() must be executed only once
|
||||
|
||||
m_deviceUIs.back()->m_deviceAPI->freeAll();
|
||||
|
||||
ui->tabChannels->removeTab(ui->tabChannels->count() - 1);
|
||||
@ -255,20 +253,40 @@ void MainWindow::setInputGUI(int deviceTabIndex, QWidget* gui, const QString& so
|
||||
char tabNameCStr[16];
|
||||
sprintf(tabNameCStr, "R%d", deviceTabIndex);
|
||||
|
||||
qDebug("MainWindow::setInputGUI: insert tab at %d", deviceTabIndex);
|
||||
|
||||
if (deviceTabIndex < ui->tabInputsView->count())
|
||||
if (deviceTabIndex < m_deviceWidgetTabs.size())
|
||||
{
|
||||
qDebug("MainWindow::setInputGUI: tab device index %d replace", deviceTabIndex);
|
||||
ui->tabInputsView->removeTab(deviceTabIndex);
|
||||
ui->tabInputsView->insertTab(deviceTabIndex, gui, tabNameCStr);
|
||||
m_deviceWidgetTabs[deviceTabIndex] = {gui, sourceDisplayName, QString(tabNameCStr)};
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("MainWindow::setInputGUI: tab device index %d add", deviceTabIndex);
|
||||
ui->tabInputsView->addTab(gui, tabNameCStr);
|
||||
m_deviceWidgetTabs.append({gui, sourceDisplayName, QString(tabNameCStr)});
|
||||
}
|
||||
|
||||
ui->tabInputsView->setTabToolTip(deviceTabIndex, sourceDisplayName);
|
||||
ui->tabInputsView->clear();
|
||||
|
||||
for (int i = 0; i < m_deviceWidgetTabs.size(); i++)
|
||||
{
|
||||
qDebug("MainWindow::setInputGUI: adding tab for %s", m_deviceWidgetTabs[i].displayName.toStdString().c_str());
|
||||
ui->tabInputsView->addTab(m_deviceWidgetTabs[i].gui, m_deviceWidgetTabs[i].tabName);
|
||||
ui->tabInputsView->setTabToolTip(i, m_deviceWidgetTabs[i].displayName);
|
||||
}
|
||||
|
||||
|
||||
// if (deviceTabIndex < ui->tabInputsView->count())
|
||||
// {
|
||||
// qDebug("MainWindow::setInputGUI: tab device index %d replace", deviceTabIndex);
|
||||
// ui->tabInputsView->removeTab(deviceTabIndex);
|
||||
// ui->tabInputsView->insertTab(deviceTabIndex, gui, tabNameCStr);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// qDebug("MainWindow::setInputGUI: tab device index %d add", deviceTabIndex);
|
||||
// ui->tabInputsView->addTab(gui, tabNameCStr);
|
||||
// }
|
||||
|
||||
// ui->tabInputsView->setTabToolTip(deviceTabIndex, sourceDisplayName);
|
||||
}
|
||||
|
||||
void MainWindow::loadSettings()
|
||||
@ -649,6 +667,7 @@ void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
||||
|
||||
if (currentSourceTabIndex >= 0)
|
||||
{
|
||||
qDebug("MainWindow::on_sampleSource_currentIndexChanged: tab at %d", currentSourceTabIndex);
|
||||
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
||||
deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
||||
//deviceUI->m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QList>
|
||||
|
||||
#include "settings/mainsettings.h"
|
||||
#include "util/messagequeue.h"
|
||||
#include "util/export.h"
|
||||
@ -44,6 +46,7 @@ class ChannelMarker;
|
||||
class PluginManager;
|
||||
class DeviceAPI;
|
||||
class PluginInterface;
|
||||
class QWidget;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -85,11 +88,19 @@ private:
|
||||
PItem
|
||||
};
|
||||
|
||||
struct DeviceWidgetTabData
|
||||
{
|
||||
QWidget *gui;
|
||||
QString displayName;
|
||||
QString tabName;
|
||||
};
|
||||
|
||||
Ui::MainWindow* ui;
|
||||
AudioDeviceInfo* m_audioDeviceInfo;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
MainSettings m_settings;
|
||||
std::vector<DeviceUISet*> m_deviceUIs;
|
||||
QList<DeviceWidgetTabData> m_deviceWidgetTabs;
|
||||
|
||||
DSPEngine* m_dspEngine;
|
||||
PluginManager* m_pluginManager;
|
||||
|
@ -17,6 +17,7 @@ struct PluginDescriptor {
|
||||
class PluginAPI;
|
||||
class DeviceAPI;
|
||||
class PluginGUI;
|
||||
class QWidget;
|
||||
|
||||
class PluginInterface {
|
||||
public:
|
||||
@ -47,7 +48,7 @@ public:
|
||||
virtual PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI) { return 0; }
|
||||
|
||||
virtual SampleSourceDevices enumSampleSources() { return SampleSourceDevices(); }
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceAPI *deviceAPI)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,12 +133,14 @@ int PluginManager::selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI)
|
||||
<< " ser: " << m_sampleSourceSerial.toStdString().c_str()
|
||||
<< " seq: " << m_sampleSourceSequence;
|
||||
|
||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
||||
QWidget *gui;
|
||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, &gui, deviceAPI);
|
||||
m_sampleSourcePluginGUI = pluginGUI;
|
||||
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
||||
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
||||
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
||||
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
||||
deviceAPI->setInputGUI(gui, m_sampleSourceDevices[index].m_displayName);
|
||||
|
||||
return index;
|
||||
}
|
||||
@ -191,12 +193,14 @@ int PluginManager::selectFirstSampleSource(const QString& sourceId, DeviceAPI *d
|
||||
<< " ser: " << m_sampleSourceSerial.toStdString().c_str()
|
||||
<< " seq: " << m_sampleSourceSequence;
|
||||
|
||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
||||
QWidget *gui;
|
||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, &gui, deviceAPI);
|
||||
m_sampleSourcePluginGUI = pluginGUI;
|
||||
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
||||
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
||||
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
||||
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
||||
deviceAPI->setInputGUI(gui, m_sampleSourceDevices[index].m_displayName);
|
||||
|
||||
return index;
|
||||
}
|
||||
@ -263,12 +267,14 @@ int PluginManager::selectSampleSourceBySerialOrSequence(const QString& sourceId,
|
||||
<< " ser: " << qPrintable(m_sampleSourceSerial)
|
||||
<< " seq: " << m_sampleSourceSequence;
|
||||
|
||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
||||
QWidget *gui;
|
||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, &gui, deviceAPI);
|
||||
m_sampleSourcePluginGUI = pluginGUI;
|
||||
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
||||
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
||||
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
||||
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
||||
deviceAPI->setInputGUI(gui, m_sampleSourceDevices[index].m_displayName);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user