1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 05:41:56 -05:00

New sampling devices dock with change and reload buttons. Implements #629

This commit is contained in:
f4exb 2020-09-13 17:50:24 +02:00
parent 5c1dc1e5a7
commit 5af1e12f6d
13 changed files with 601 additions and 54 deletions

View File

@ -47,6 +47,7 @@ set(sdrgui_SOURCES
gui/rollupwidget.cpp
gui/samplingdevicecontrol.cpp
gui/samplingdevicedialog.cpp
gui/samplingdevicesdock.cpp
gui/scaleengine.cpp
gui/sdrangelsplash.cpp
gui/tickedslider.cpp
@ -122,6 +123,7 @@ set(sdrgui_HEADERS
gui/rollupwidget.h
gui/samplingdevicecontrol.h
gui/samplingdevicedialog.h
gui/samplingdevicesdock.h
gui/scaleengine.h
gui/sdrangelsplash.h
gui/tickedslider.h

View File

@ -85,6 +85,7 @@ ChannelsDock::~ChannelsDock()
{
delete m_closeButton;
delete m_normalButton;
delete m_addChannelButton;
delete m_titleLabel;
delete m_titleBarLayout;
delete m_titleBar;

View File

@ -25,7 +25,6 @@
SamplingDeviceControl::SamplingDeviceControl(int tabIndex, int deviceType, QWidget* parent) :
QWidget(parent),
ui(new Ui::SamplingDeviceControl),
m_pluginManager(0),
m_deviceTabIndex(tabIndex),
m_deviceType(deviceType),
m_selectedDeviceIndex(-1)

View File

@ -42,7 +42,6 @@ public:
int getSelectedDeviceIndex() const { return m_selectedDeviceIndex; }
void setSelectedDeviceIndex(int index);
void removeSelectedDeviceIndex();
void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; }
private slots:
void on_deviceChange_clicked();
@ -50,7 +49,6 @@ private slots:
private:
Ui::SamplingDeviceControl* ui;
PluginManager *m_pluginManager;
int m_deviceTabIndex;
int m_deviceType;
int m_selectedDeviceIndex;

View File

@ -29,7 +29,8 @@ SamplingDeviceDialog::SamplingDeviceDialog(int deviceType, int deviceTabIndex, Q
ui(new Ui::SamplingDeviceDialog),
m_deviceType(deviceType),
m_deviceTabIndex(deviceTabIndex),
m_selectedDeviceIndex(-1)
m_selectedDeviceIndex(-1),
m_hasChanged(false)
{
ui->setupUi(this);
@ -52,6 +53,31 @@ SamplingDeviceDialog::~SamplingDeviceDialog()
delete ui;
}
int SamplingDeviceDialog::exec()
{
m_hasChanged = false;
return QDialog::exec();
}
void SamplingDeviceDialog::setSelectedDeviceIndex(int deviceIndex)
{
ui->deviceSelect->blockSignals(true);
ui->deviceSelect->setCurrentIndex(deviceIndex);
m_selectedDeviceIndex = deviceIndex;
ui->deviceSelect->blockSignals(false);
}
void SamplingDeviceDialog::getDeviceId(QString& id) const
{
id = ui->deviceSelect->currentText();
}
void SamplingDeviceDialog::on_deviceSelect_currentIndexChanged(int index)
{
(void) index;
m_hasChanged = true;
}
void SamplingDeviceDialog::accept()
{
m_selectedDeviceIndex = m_deviceIndexes[ui->deviceSelect->currentIndex()];
@ -66,3 +92,9 @@ void SamplingDeviceDialog::accept()
QDialog::accept();
}
void SamplingDeviceDialog::reject()
{
m_hasChanged = false;
QDialog::reject();
}

View File

@ -35,9 +35,14 @@ class SDRGUI_API SamplingDeviceDialog : public QDialog {
Q_OBJECT
public:
explicit SamplingDeviceDialog(int deviceType, int deviceTabIndex, QWidget* parent = 0);
explicit SamplingDeviceDialog(int deviceType, int deviceTabIndex, QWidget* parent = nullptr);
~SamplingDeviceDialog();
int getSelectedDeviceIndex() const { return m_selectedDeviceIndex; }
void setSelectedDeviceIndex(int deviceIndex);
void setTabIndex(int deviceTabIndex) { m_deviceTabIndex = deviceTabIndex; }
void getDeviceId(QString& id) const;
int exec();
bool hasChanged() const { return m_hasChanged; }
private:
Ui::SamplingDeviceDialog* ui;
@ -45,9 +50,12 @@ private:
int m_deviceTabIndex;
int m_selectedDeviceIndex;
std::vector<int> m_deviceIndexes;
bool m_hasChanged;
private slots:
void on_deviceSelect_currentIndexChanged(int index);
void accept();
void reject();
};
#endif /* SDRGUI_GUI_SAMPLINGDEVICEDIALOG_H_ */

View File

@ -0,0 +1,183 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QStyle>
#include "device/deviceenumerator.h"
#include "samplingdevicesdock.h"
SamplingDevicesDock::SamplingDevicesDock(QWidget *parent, Qt::WindowFlags flags) :
QDockWidget(parent, flags),
m_currentTabIndex(0)
{
m_titleBar = new QWidget();
m_titleBarLayout = new QHBoxLayout();
m_titleBarLayout->setMargin(1);
m_titleBar->setLayout(m_titleBarLayout);
m_titleLabel = new QLabel();
m_titleLabel->setText(QString("Sampling device")); // will be changed dynamically
m_changeDeviceButton = new QPushButton();
QIcon changeIcon(":/swap.png");
m_changeDeviceButton->setIcon(changeIcon);
m_changeDeviceButton->setToolTip("Change device");
m_changeDeviceButton->setFixedSize(16, 16);
m_reloadDeviceButton = new QPushButton();
QIcon reloadIcon(":/recycle.png");
m_reloadDeviceButton->setIcon(reloadIcon);
m_reloadDeviceButton->setToolTip("Reload device");
m_reloadDeviceButton->setFixedSize(16, 16);
m_normalButton = new QPushButton();
QIcon normalIcon = style()->standardIcon(QStyle::SP_TitleBarNormalButton, 0, this);
m_normalButton->setIcon(normalIcon);
m_normalButton->setFixedSize(12, 12);
m_closeButton = new QPushButton();
QIcon closeIcon = style()->standardIcon(QStyle::SP_TitleBarCloseButton, 0, this);
m_closeButton->setIcon(closeIcon);
m_closeButton->setFixedSize(12, 12);
m_titleBarLayout->addWidget(m_changeDeviceButton);
m_titleBarLayout->addWidget(m_reloadDeviceButton);
m_titleBarLayout->addWidget(m_titleLabel);
m_titleBarLayout->addWidget(m_normalButton);
m_titleBarLayout->addWidget(m_closeButton);
setTitleBarWidget(m_titleBar);
QObject::connect(
m_changeDeviceButton,
&QPushButton::clicked,
this,
&SamplingDevicesDock::openChangeDeviceDialog
);
QObject::connect(
m_reloadDeviceButton,
&QPushButton::clicked,
this,
&SamplingDevicesDock::reloadDevice
);
QObject::connect(
m_normalButton,
&QPushButton::clicked,
this,
&SamplingDevicesDock::toggleFloating
);
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(hide()));
}
SamplingDevicesDock::~SamplingDevicesDock()
{
for (int i = 0; i < m_devicesInfo.size(); i++) {
delete m_devicesInfo[i].m_samplingDeviceDialog;
}
delete m_closeButton;
delete m_normalButton;
delete m_reloadDeviceButton;
delete m_changeDeviceButton;
delete m_titleLabel;
delete m_titleBarLayout;
delete m_titleBar;
}
void SamplingDevicesDock::addDevice(int deviceType, int deviceTabIndex)
{
m_devicesInfo.push_back(DeviceInfo{
deviceType,
deviceTabIndex,
new SamplingDeviceDialog(deviceType, deviceTabIndex, this)
});
setCurrentTabIndex(deviceTabIndex);
}
void SamplingDevicesDock::removeLastDevice()
{
if (m_devicesInfo.size() > 0)
{
delete m_devicesInfo.back().m_samplingDeviceDialog;
m_devicesInfo.pop_back();
}
}
void SamplingDevicesDock::setCurrentTabIndex(int deviceTabIndex)
{
m_currentTabIndex = deviceTabIndex;
QString newTitle;
m_devicesInfo[m_currentTabIndex].m_samplingDeviceDialog->getDeviceId(newTitle);
int newTitleSize = newTitle.size();
if (newTitleSize > 0)
{
if (newTitleSize > 40) {
newTitle.chop(newTitleSize - 40);
}
m_titleLabel->setText(newTitle);
}
}
void SamplingDevicesDock::setSelectedDeviceIndex(int deviceTabIndex, int deviceIndex)
{
if (deviceTabIndex < m_devicesInfo.size())
{
m_devicesInfo[deviceTabIndex].m_samplingDeviceDialog->setSelectedDeviceIndex(deviceIndex);
setCurrentTabIndex(m_currentTabIndex); // update title
}
}
void SamplingDevicesDock::toggleFloating()
{
setFloating(!isFloating());
}
void SamplingDevicesDock::reloadDevice()
{
emit deviceChanged(
m_devicesInfo[m_currentTabIndex].m_deviceType,
m_devicesInfo[m_currentTabIndex].m_deviceTabIndex,
m_devicesInfo[m_currentTabIndex].m_samplingDeviceDialog->getSelectedDeviceIndex()
);
}
void SamplingDevicesDock::openChangeDeviceDialog()
{
if (m_currentTabIndex < m_devicesInfo.size())
{
m_devicesInfo[m_currentTabIndex].m_samplingDeviceDialog->exec();
if (m_devicesInfo[m_currentTabIndex].m_samplingDeviceDialog->hasChanged())
{
setCurrentTabIndex(m_currentTabIndex); // update title
emit deviceChanged(
m_devicesInfo[m_currentTabIndex].m_deviceType,
m_devicesInfo[m_currentTabIndex].m_deviceTabIndex,
m_devicesInfo[m_currentTabIndex].m_samplingDeviceDialog->getSelectedDeviceIndex()
);
}
}
}

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRGUI_GUI_SAMPLINGDEVICESDOCK_H_
#define SDRGUI_GUI_SAMPLINGDEVICESDOCK_H_
#include <QDockWidget>
#include <QList>
#include "samplingdevicedialog.h"
class QHBoxLayout;
class QLabel;
class QPushButton;
class SamplingDeviceDialog;
class SamplingDevicesDock : public QDockWidget
{
Q_OBJECT
public:
SamplingDevicesDock(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~SamplingDevicesDock();
void addDevice(int deviceType, int deviceTabIndex);
void removeLastDevice();
void setCurrentTabIndex(int deviceTabIndex);
void setSelectedDeviceIndex(int deviceTabIndex, int deviceIndex);
private:
struct DeviceInfo
{
DeviceInfo(int deviceType, int deviceTabIndex, SamplingDeviceDialog *samplingDeviceDialog) :
m_deviceType(deviceType),
m_deviceTabIndex(deviceTabIndex),
m_samplingDeviceDialog(samplingDeviceDialog)
{}
DeviceInfo(const DeviceInfo& other) :
m_deviceType(other.m_deviceType),
m_deviceTabIndex(other.m_deviceTabIndex),
m_samplingDeviceDialog(other.m_samplingDeviceDialog)
{}
int m_deviceType;
int m_deviceTabIndex;
SamplingDeviceDialog *m_samplingDeviceDialog;
};
QPushButton *m_changeDeviceButton;
QPushButton *m_reloadDeviceButton;
QWidget *m_titleBar;
QHBoxLayout *m_titleBarLayout;
QLabel *m_titleLabel;
QPushButton *m_normalButton;
QPushButton *m_closeButton;
QList<DeviceInfo> m_devicesInfo;
int m_currentTabIndex;
private slots:
void toggleFloating();
void reloadDevice();
void openChangeDeviceDialog();
signals:
void deviceChanged(int deviceType, int deviceTabIndex, int newDeviceIndex);
};
#endif // SDRGUI_GUI_SAMPLINGDEVICESDOCK_H_

View File

@ -227,6 +227,7 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
connect(ui->tabInputsView, SIGNAL(currentChanged(int)), this, SLOT(tabInputViewIndexChanged()));
connect(ui->tabChannels, SIGNAL(currentChanged(int)), this, SLOT(tabChannelsIndexChanged()));
connect(ui->channelDock, SIGNAL(addChannel(int)), this, SLOT(channelAddClicked(int)));
connect(ui->inputViewDock, SIGNAL(deviceChanged(int, int, int)), this, SLOT(samplingDeviceChanged(int, int, int)));
QString applicationDirPath = qApp->applicationDirPath();
@ -303,6 +304,8 @@ void MainWindow::addSourceDevice(int deviceIndex)
sprintf(uidCStr, "UID:%d", dspDeviceSourceEngineUID);
int deviceTabIndex = m_deviceUIs.size();
ui->inputViewDock->addDevice(0, deviceTabIndex);
m_deviceUIs.push_back(new DeviceUISet(deviceTabIndex, 0, m_masterTimer));
m_deviceUIs.back()->m_deviceSourceEngine = dspDeviceSourceEngine;
m_deviceUIs.back()->m_deviceSinkEngine = nullptr;
@ -314,7 +317,6 @@ void MainWindow::addSourceDevice(int deviceIndex)
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleRx, deviceTabIndex, dspDeviceSourceEngine, nullptr, nullptr);
m_deviceUIs.back()->m_deviceAPI = deviceAPI;
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(m_pluginManager);
QList<QString> channelNames;
m_pluginManager->listRxChannels(channelNames);
m_deviceUIs.back()->setNumberOfAvailableRxChannels(channelNames.size());
@ -351,6 +353,7 @@ void MainWindow::addSourceDevice(int deviceIndex)
}
m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(deviceIndex);
ui->inputViewDock->setSelectedDeviceIndex(deviceTabIndex, deviceIndex);
// delete previous plugin GUI
m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI(
@ -381,6 +384,8 @@ void MainWindow::addSinkDevice()
sprintf(uidCStr, "UID:%d", dspDeviceSinkEngineUID);
int deviceTabIndex = m_deviceUIs.size();
ui->inputViewDock->addDevice(1, deviceTabIndex);
m_deviceUIs.push_back(new DeviceUISet(deviceTabIndex, 1, m_masterTimer));
m_deviceUIs.back()->m_deviceSourceEngine = nullptr;
m_deviceUIs.back()->m_deviceSinkEngine = dspDeviceSinkEngine;
@ -392,7 +397,6 @@ void MainWindow::addSinkDevice()
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleTx, deviceTabIndex, nullptr, dspDeviceSinkEngine, nullptr);
m_deviceUIs.back()->m_deviceAPI = deviceAPI;
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(m_pluginManager);
QList<QString> channelNames;
m_pluginManager->listTxChannels(channelNames);
m_deviceUIs.back()->setNumberOfAvailableTxChannels(channelNames.size());
@ -427,6 +431,7 @@ void MainWindow::addSinkDevice()
}
m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(fileSinkDeviceIndex);
ui->inputViewDock->setSelectedDeviceIndex(deviceTabIndex, fileSinkDeviceIndex);
// delete previous plugin GUI if it exists
m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI(
@ -959,6 +964,7 @@ bool MainWindow::handleMessage(const Message& cmd)
ui->tabInputsSelect->setCurrentIndex(notif.getDeviceSetIndex());
DeviceUISet *deviceUI = m_deviceUIs[notif.getDeviceSetIndex()];
deviceUI->m_samplingDeviceControl->setSelectedDeviceIndex(notif.getDeviceIndex());
ui->inputViewDock->setSelectedDeviceIndex(notif.getDeviceSetIndex(), notif.getDeviceIndex());
if (notif.getDeviceType() == 1) {
sampleSinkChanged();
@ -1625,6 +1631,128 @@ void MainWindow::on_action_LimeRFE_triggered()
#endif
}
void MainWindow::samplingDeviceChanged(int deviceType, int tabIndex, int newDeviceIndex)
{
qDebug("MainWindow::samplingDeviceChanged: deviceType: %d tabIndex: %d newDeviceIndex: %d",
deviceType, tabIndex, newDeviceIndex);
const PluginInterface::SamplingDevice *samplingDevice;
if (deviceType == 0) {
sampleSourceChanged(tabIndex, newDeviceIndex);
} else if (deviceType == 1) {
sampleSinkChanged(tabIndex, newDeviceIndex);
}
}
void MainWindow::sampleSourceChanged(int tabIndex, int newDeviceIndex)
{
if (tabIndex >= 0)
{
qDebug("MainWindow::sampleSourceChanged: tab at %d", tabIndex);
DeviceUISet *deviceUI = m_deviceUIs[tabIndex];
deviceUI->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
deviceUI->m_deviceAPI->stopDeviceEngine();
// deletes old UI and input object
deviceUI->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI
deviceUI->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI(
deviceUI->m_deviceAPI->getSamplingDevicePluginInstanceGUI());
deviceUI->m_deviceAPI->resetSamplingDeviceId();
deviceUI->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
deviceUI->m_deviceAPI->getSampleSource());
deviceUI->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(newDeviceIndex);
qDebug("MainWindow::sampleSourceChanged: %s", qPrintable(samplingDevice->hardwareId));
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(newDeviceIndex));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleSourceChanged: non existent device replaced by File Input");
int fileInputDeviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileInputDeviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileInputDeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
deviceUI->m_deviceAPI->setHardwareUserArguments(userArgs);
}
// add to buddies list
std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin();
int nbOfBuddies = 0;
for (; it != m_deviceUIs.end(); ++it)
{
if (*it != deviceUI) // do not add to itself
{
if ((*it)->m_deviceSourceEngine) // it is a source device
{
if ((deviceUI->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
(deviceUI->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
{
(*it)->m_deviceAPI->addSourceBuddy(deviceUI->m_deviceAPI);
nbOfBuddies++;
}
}
if ((*it)->m_deviceSinkEngine) // it is a sink device
{
if ((deviceUI->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
(deviceUI->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
{
(*it)->m_deviceAPI->addSourceBuddy(deviceUI->m_deviceAPI);
nbOfBuddies++;
}
}
}
}
if (nbOfBuddies == 0) {
deviceUI->m_deviceAPI->setBuddyLeader(true);
}
// constructs new GUI and input object
DeviceSampleSource *source = deviceUI->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
deviceUI->m_deviceAPI->getSamplingDeviceId(), deviceUI->m_deviceAPI);
deviceUI->m_deviceAPI->setSampleSource(source);
QWidget *gui;
PluginInstanceGUI *pluginUI = deviceUI->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstanceGUI(
deviceUI->m_deviceAPI->getSamplingDeviceId(),
&gui,
deviceUI);
deviceUI->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(pluginUI->getInputMessageQueue());
deviceUI->m_deviceAPI->setSamplingDevicePluginInstanceGUI(pluginUI);
setDeviceGUI(tabIndex, gui, deviceUI->m_deviceAPI->getSamplingDeviceDisplayName());
deviceUI->m_deviceAPI->getSampleSource()->init();
deviceUI->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
if (tabIndex == 0) // save as default starting device
{
m_settings.setSourceIndex(samplingDevice->sequence);
m_settings.setSourceDeviceId(samplingDevice->id);
}
}
}
void MainWindow::sampleSourceChanged()
{
// Do it in the currently selected source tab
@ -1736,6 +1864,107 @@ void MainWindow::sampleSourceChanged()
}
}
void MainWindow::sampleSinkChanged(int tabIndex, int newDeviceIndex)
{
if (tabIndex >= 0)
{
qDebug("MainWindow::sampleSinkChanged: tab at %d", tabIndex);
DeviceUISet *deviceUI = m_deviceUIs[tabIndex];
deviceUI->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
deviceUI->m_deviceAPI->stopDeviceEngine();
// deletes old UI and output object
deviceUI->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(0); // have sink stop sending messages to the GUI
deviceUI->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI(
deviceUI->m_deviceAPI->getSamplingDevicePluginInstanceGUI());
deviceUI->m_deviceAPI->resetSamplingDeviceId();
deviceUI->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
deviceUI->m_deviceAPI->getSampleSink());
deviceUI->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(newDeviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(newDeviceIndex));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleSinkChanged: non existent device replaced by File Sink");
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileOutputDeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
deviceUI->m_deviceAPI->setHardwareUserArguments(userArgs);
}
// add to buddies list
std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin();
int nbOfBuddies = 0;
for (; it != m_deviceUIs.end(); ++it)
{
if (*it != deviceUI) // do not add to itself
{
if ((*it)->m_deviceSourceEngine) // it is a source device
{
if ((deviceUI->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
(deviceUI->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
{
(*it)->m_deviceAPI->addSinkBuddy(deviceUI->m_deviceAPI);
nbOfBuddies++;
}
}
if ((*it)->m_deviceSinkEngine) // it is a sink device
{
if ((deviceUI->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
(deviceUI->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
{
(*it)->m_deviceAPI->addSinkBuddy(deviceUI->m_deviceAPI);
nbOfBuddies++;
}
}
}
}
if (nbOfBuddies == 0) {
deviceUI->m_deviceAPI->setBuddyLeader(true);
}
// constructs new GUI and output object
DeviceSampleSink *sink = deviceUI->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
deviceUI->m_deviceAPI->getSamplingDeviceId(), deviceUI->m_deviceAPI);
deviceUI->m_deviceAPI->setSampleSink(sink);
QWidget *gui;
PluginInstanceGUI *pluginUI = deviceUI->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstanceGUI(
deviceUI->m_deviceAPI->getSamplingDeviceId(),
&gui,
deviceUI);
deviceUI->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(pluginUI->getInputMessageQueue());
deviceUI->m_deviceAPI->setSamplingDevicePluginInstanceGUI(pluginUI);
setDeviceGUI(tabIndex, gui, deviceUI->m_deviceAPI->getSamplingDeviceDisplayName(), 1);
deviceUI->m_deviceAPI->getSampleSink()->init();
deviceUI->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
}
}
void MainWindow::sampleSinkChanged()
{
// Do it in the currently selected source tab
@ -1966,6 +2195,10 @@ void MainWindow::tabInputViewIndexChanged()
{
int inputViewIndex = ui->tabInputsView->currentIndex();
if (inputViewIndex >= 0) {
ui->inputViewDock->setCurrentTabIndex(inputViewIndex);
}
if ((inputViewIndex >= 0) && (m_masterTabIndex >= 0) && (inputViewIndex != m_masterTabIndex))
{
DeviceUISet *deviceUI = m_deviceUIs[inputViewIndex];

View File

@ -364,6 +364,8 @@ private:
void addSinkDevice();
void removeLastDevice();
void deleteChannel(int deviceSetIndex, int channelIndex);
void sampleSourceChanged(int tabIndex, int newDeviceIndex);
void sampleSinkChanged(int tabIndex, int newDeviceIndex);
void setLoggingOptions();
@ -397,6 +399,7 @@ private slots:
void on_action_LimeRFE_triggered();
void on_action_My_Position_triggered();
void on_action_DeviceUserArguments_triggered();
void samplingDeviceChanged(int deviceType, int tabIndex, int newDeviceIndex);
void sampleSourceChanged();
void sampleSinkChanged();
void sampleMIMOChanged();

View File

@ -138,7 +138,7 @@
<addaction name="menu_Help"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="inputViewDock">
<widget class="SamplingDevicesDock" name="inputViewDock">
<property name="windowTitle">
<string>Sampling devices</string>
</property>
@ -181,52 +181,6 @@
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="inputSelectDock">
<property name="windowTitle">
<string>Sampling devices control</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="intputSelectDockWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QTabWidget" name="tabInputsSelect">
<property name="minimumSize">
<size>
<width>0</width>
<height>110</height>
</size>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="spectraDisplayDock">
<property name="windowTitle">
<string>Spectrum Display</string>
@ -737,6 +691,52 @@
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="inputSelectDock">
<property name="windowTitle">
<string>Sampling devices control</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="intputSelectDockWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QTabWidget" name="tabInputsSelect">
<property name="minimumSize">
<size>
<width>0</width>
<height>110</height>
</size>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<action name="action_Exit">
<property name="text">
<string>E&amp;xit</string>
@ -966,6 +966,12 @@
<header>gui/channelsdock.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SamplingDevicesDock</class>
<extends>QDockWidget</extends>
<header>gui/samplingdevicesdock.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>presetTree</tabstop>

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>swap.png</file>
<file>gridpolar.png</file>
<file>gridrect.png</file>
<file>double_arrow_up.png</file>

BIN
sdrgui/resources/swap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB