1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-07 00:14:49 -04:00

Channel plugins: use specialized ChannelGUI superclass. Handle GUI lifecycle in MainWindow

This commit is contained in:
f4exb
2020-10-04 06:16:15 +02:00
parent 4ab683fa7d
commit b1c9a35dcb
116 changed files with 314 additions and 210 deletions
+48 -4
View File
@@ -36,6 +36,7 @@
#include "device/deviceuiset.h"
#include "device/deviceenumerator.h"
#include "channel/channelapi.h"
#include "channel/channelgui.h"
#include "feature/featureuiset.h"
#include "feature/feature.h"
#include "gui/indicator.h"
@@ -1921,8 +1922,15 @@ void MainWindow::channelAddClicked(int channelIndex)
ChannelAPI *channelAPI;
BasebandSampleSink *rxChannel;
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
ChannelGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingRxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
}
else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels
{
@@ -1931,8 +1939,15 @@ void MainWindow::channelAddClicked(int channelIndex)
ChannelAPI *channelAPI;
BasebandSampleSource *txChannel;
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
ChannelGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingTxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
}
else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range
{
@@ -1948,8 +1963,15 @@ void MainWindow::channelAddClicked(int channelIndex)
ChannelAPI *channelAPI;
BasebandSampleSink *rxChannel;
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
ChannelGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingRxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
}
else if (channelIndex < nbRxChannels + nbTxChannels)
{
@@ -1958,8 +1980,15 @@ void MainWindow::channelAddClicked(int channelIndex)
ChannelAPI *channelAPI;
BasebandSampleSource *txChannel;
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
ChannelGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingTxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
}
}
}
@@ -2148,3 +2177,18 @@ void MainWindow::commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifie
}
}
}
void MainWindow::handleClosingRxChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui)
{
deviceUISet->removeRxChannelInstance(gui);
}
void MainWindow::handleClosingTxChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui)
{
deviceUISet->removeTxChannelInstance(gui);
}
void MainWindow::handleClosingMIMOChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui)
{
deviceUISet->removeChannelInstance(gui);
}