From 57943a9b6d4f26e0f0e0e96f9195dd85fb83bc44 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 13 Sep 2020 18:32:33 +0200 Subject: [PATCH] Removed sampling device control objects --- sdrgui/CMakeLists.txt | 3 - sdrgui/device/deviceuiset.cpp | 3 - sdrgui/device/deviceuiset.h | 2 - sdrgui/gui/samplingdevicecontrol.cpp | 99 -------- sdrgui/gui/samplingdevicecontrol.h | 61 ----- sdrgui/gui/samplingdevicecontrol.ui | 113 ---------- sdrgui/mainwindow.cpp | 325 +-------------------------- sdrgui/mainwindow.h | 3 - sdrgui/mainwindow.ui | 46 ---- 9 files changed, 9 insertions(+), 646 deletions(-) delete mode 100644 sdrgui/gui/samplingdevicecontrol.cpp delete mode 100644 sdrgui/gui/samplingdevicecontrol.h delete mode 100644 sdrgui/gui/samplingdevicecontrol.ui diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index 5c88d2ea9..b8187f86f 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -45,7 +45,6 @@ set(sdrgui_SOURCES gui/pluginsdialog.cpp gui/presetitem.cpp gui/rollupwidget.cpp - gui/samplingdevicecontrol.cpp gui/samplingdevicedialog.cpp gui/samplingdevicesdock.cpp gui/scaleengine.cpp @@ -121,7 +120,6 @@ set(sdrgui_HEADERS gui/pluginsdialog.h gui/presetitem.h gui/rollupwidget.h - gui/samplingdevicecontrol.h gui/samplingdevicedialog.h gui/samplingdevicesdock.h gui/scaleengine.h @@ -172,7 +170,6 @@ set(sdrgui_FORMS gui/pluginsdialog.ui gui/audiodialog.ui gui/audioselectdialog.ui - gui/samplingdevicecontrol.ui gui/samplingdevicedialog.ui gui/myposdialog.ui gui/transverterdialog.ui diff --git a/sdrgui/device/deviceuiset.cpp b/sdrgui/device/deviceuiset.cpp index b19c9979c..b62965901 100644 --- a/sdrgui/device/deviceuiset.cpp +++ b/sdrgui/device/deviceuiset.cpp @@ -23,7 +23,6 @@ #include "dsp/spectrumvis.h" #include "gui/glspectrumgui.h" #include "gui/channelwindow.h" -#include "gui/samplingdevicecontrol.h" #include "dsp/dspdevicesourceengine.h" #include "dsp/dspdevicesinkengine.h" #include "plugin/plugininstancegui.h" @@ -53,7 +52,6 @@ DeviceUISet::DeviceUISet(int tabIndex, int deviceType, QTimer& timer) m_spectrumGUI = new GLSpectrumGUI; m_spectrumGUI->setBuddies(m_spectrumVis, m_spectrum); m_channelWindow = new ChannelWindow; - m_samplingDeviceControl = new SamplingDeviceControl(tabIndex, deviceType); m_deviceAPI = nullptr; m_deviceSourceEngine = nullptr; m_deviceSinkEngine = nullptr; @@ -72,7 +70,6 @@ DeviceUISet::DeviceUISet(int tabIndex, int deviceType, QTimer& timer) DeviceUISet::~DeviceUISet() { - delete m_samplingDeviceControl; delete m_channelWindow; delete m_spectrumGUI; delete m_spectrumVis; diff --git a/sdrgui/device/deviceuiset.h b/sdrgui/device/deviceuiset.h index 4c69e5327..90c5f2ae2 100644 --- a/sdrgui/device/deviceuiset.h +++ b/sdrgui/device/deviceuiset.h @@ -27,7 +27,6 @@ class SpectrumVis; class GLSpectrum; class GLSpectrumGUI; class ChannelWindow; -class SamplingDeviceControl; class DeviceAPI; class DSPDeviceSourceEngine; class DSPDeviceSinkEngine; @@ -44,7 +43,6 @@ public: GLSpectrum *m_spectrum; GLSpectrumGUI *m_spectrumGUI; ChannelWindow *m_channelWindow; - SamplingDeviceControl *m_samplingDeviceControl; DeviceAPI *m_deviceAPI; DSPDeviceSourceEngine *m_deviceSourceEngine; DSPDeviceSinkEngine *m_deviceSinkEngine; diff --git a/sdrgui/gui/samplingdevicecontrol.cpp b/sdrgui/gui/samplingdevicecontrol.cpp deleted file mode 100644 index 6db786b70..000000000 --- a/sdrgui/gui/samplingdevicecontrol.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2015-2017 Edouard Griffiths, F4EXB // -// // -// 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "samplingdevicecontrol.h" -#include "samplingdevicedialog.h" -#include "plugin/pluginmanager.h" -#include "device/deviceenumerator.h" -#include "ui_samplingdevicecontrol.h" - - -SamplingDeviceControl::SamplingDeviceControl(int tabIndex, int deviceType, QWidget* parent) : - QWidget(parent), - ui(new Ui::SamplingDeviceControl), - m_deviceTabIndex(tabIndex), - m_deviceType(deviceType), - m_selectedDeviceIndex(-1) -{ - ui->setupUi(this); - ui->deviceSelectedText->setText("None"); -} - -SamplingDeviceControl::~SamplingDeviceControl() -{ - delete ui; -} - -void SamplingDeviceControl::on_deviceChange_clicked() -{ - SamplingDeviceDialog dialog(m_deviceType, m_deviceTabIndex, this); - dialog.exec(); - - if (dialog.getSelectedDeviceIndex() >= 0) - { - m_selectedDeviceIndex = dialog.getSelectedDeviceIndex(); - setSelectedDeviceIndex(m_selectedDeviceIndex); - emit changed(); - } -} - -void SamplingDeviceControl::on_deviceReload_clicked() -{ - if (m_selectedDeviceIndex >= 0) { - emit changed(); - } -} - -void SamplingDeviceControl::setSelectedDeviceIndex(int index) -{ - if (m_deviceType == 0) // Single Rx - { - const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(index); - DeviceEnumerator::instance()->changeRxSelection(m_deviceTabIndex, index); - ui->deviceSelectedText->setText(samplingDevice->displayedName); - } - else if (m_deviceType == 1) // Single Tx - { - const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(index); - DeviceEnumerator::instance()->changeTxSelection(m_deviceTabIndex, index); - ui->deviceSelectedText->setText(samplingDevice->displayedName); - } - else if (m_deviceType == 2) // MIMO - { - const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(index); - DeviceEnumerator::instance()->changeMIMOSelection(m_deviceTabIndex, index); - ui->deviceSelectedText->setText(samplingDevice->displayedName); - } - - m_selectedDeviceIndex = index; -} - -void SamplingDeviceControl::removeSelectedDeviceIndex() -{ - if (m_deviceType == 0) // Single Rx - { - DeviceEnumerator::instance()->removeRxSelection(m_deviceTabIndex); - ui->deviceSelectedText->setText("None"); - } - else if (m_deviceType == 1) // Single Tx - { - DeviceEnumerator::instance()->removeTxSelection(m_deviceTabIndex); - ui->deviceSelectedText->setText("None"); - } - - m_selectedDeviceIndex = -1; -} diff --git a/sdrgui/gui/samplingdevicecontrol.h b/sdrgui/gui/samplingdevicecontrol.h deleted file mode 100644 index 925d53e2f..000000000 --- a/sdrgui/gui/samplingdevicecontrol.h +++ /dev/null @@ -1,61 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2015 Edouard Griffiths, F4EXB // -// // -// 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_GUI_SAMPLINGDEVICECONTROL_H_ -#define SDRBASE_GUI_SAMPLINGDEVICECONTROL_H_ - - -#include -#include -#include - -#include "export.h" - -namespace Ui { - class SamplingDeviceControl; -} - -class ChannelMarker; -class PluginManager; - -class SDRGUI_API SamplingDeviceControl : public QWidget { - Q_OBJECT - -public: - explicit SamplingDeviceControl(int tabIndex, int deviceType, QWidget* parent = 0); - ~SamplingDeviceControl(); - - int getSelectedDeviceIndex() const { return m_selectedDeviceIndex; } - void setSelectedDeviceIndex(int index); - void removeSelectedDeviceIndex(); - -private slots: - void on_deviceChange_clicked(); - void on_deviceReload_clicked(); - -private: - Ui::SamplingDeviceControl* ui; - int m_deviceTabIndex; - int m_deviceType; - int m_selectedDeviceIndex; - -signals: - void changed(); -}; - - -#endif /* SDRBASE_GUI_SAMPLINGDEVICECONTROL_H_ */ diff --git a/sdrgui/gui/samplingdevicecontrol.ui b/sdrgui/gui/samplingdevicecontrol.ui deleted file mode 100644 index 337ed1da9..000000000 --- a/sdrgui/gui/samplingdevicecontrol.ui +++ /dev/null @@ -1,113 +0,0 @@ - - - SamplingDeviceControl - - - - 0 - 0 - 300 - 40 - - - - - 300 - 40 - - - - - 16777215 - 16777215 - - - - - Liberation Sans - 9 - - - - Title & Color - - - - 3 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - - Device - - - - - - - - 24 - 0 - - - - - 24 - 16777215 - - - - Change sampling device - - - - - - - :/choose.png:/choose.png - - - - - - - - 24 - 16777215 - - - - Reload sampling device - - - - - - - :/recycle.png:/recycle.png - - - - - - - - - - - - diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index e362f573a..601c84ae6 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -48,7 +48,6 @@ #include "gui/audiodialog.h" #include "gui/loggingdialog.h" #include "gui/deviceuserargsdialog.h" -#include "gui/samplingdevicecontrol.h" #include "gui/sdrangelsplash.h" #include "gui/mypositiondialog.h" #include "gui/ambedevicesdialog.h" @@ -141,13 +140,11 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse // work around broken Qt dock widget ordering removeDockWidget(ui->inputViewDock); - removeDockWidget(ui->inputSelectDock); removeDockWidget(ui->spectraDisplayDock); removeDockWidget(ui->presetDock); removeDockWidget(ui->commandsDock); removeDockWidget(ui->channelDock); addDockWidget(Qt::LeftDockWidgetArea, ui->inputViewDock); - addDockWidget(Qt::LeftDockWidgetArea, ui->inputSelectDock); addDockWidget(Qt::LeftDockWidgetArea, ui->spectraDisplayDock); addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock); addDockWidget(Qt::LeftDockWidgetArea, ui->commandsDock); @@ -155,14 +152,12 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse addDockWidget(Qt::RightDockWidgetArea, ui->channelDock); ui->inputViewDock->show(); - ui->inputSelectDock->show(); ui->spectraDisplayDock->show(); ui->presetDock->show(); ui->commandsDock->show(); ui->channelDock->show(); ui->menu_Window->addAction(ui->inputViewDock->toggleViewAction()); - ui->menu_Window->addAction(ui->inputSelectDock->toggleViewAction()); ui->menu_Window->addAction(ui->spectraDisplayDock->toggleViewAction()); ui->menu_Window->addAction(ui->presetDock->toggleViewAction()); ui->menu_Window->addAction(ui->commandsDock->toggleViewAction()); @@ -173,11 +168,6 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse "QComboBox::item:selected { color: rgb(255,140,0); } " "QTabWidget::pane { border: 1px solid #C06900; } " "QTabBar::tab:selected { background: rgb(128,70,0); }"); - ui->tabInputsSelect->setStyleSheet("QWidget { background: rgb(50,50,50); } " - "QToolButton::checked { background: rgb(128,70,0); } " - "QComboBox::item:selected { color: rgb(255,140,0); } " - "QTabWidget::pane { border: 1px solid #808080; } " - "QTabBar::tab:selected { background: rgb(100,100,100); }"); connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection); @@ -326,11 +316,6 @@ void MainWindow::addSourceDevice(int deviceIndex) ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr); ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr); - connect(m_deviceUIs.back()->m_samplingDeviceControl, SIGNAL(changed()), this, SLOT(sampleSourceChanged())); - - ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr); - ui->tabInputsSelect->setTabToolTip(deviceTabIndex, QString(uidCStr)); - // Create a file source instance by default if requested device was not enumerated (index = -1) if (deviceIndex < 0) { deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex(); @@ -352,7 +337,6 @@ void MainWindow::addSourceDevice(int deviceIndex) m_deviceUIs.back()->m_deviceAPI->setHardwareUserArguments(userArgs); } - m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(deviceIndex); ui->inputViewDock->setSelectedDeviceIndex(deviceTabIndex, deviceIndex); // delete previous plugin GUI @@ -407,11 +391,6 @@ void MainWindow::addSinkDevice() ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr); ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr); - connect(m_deviceUIs.back()->m_samplingDeviceControl, SIGNAL(changed()), this, SLOT(sampleSinkChanged())); - - ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr); - ui->tabInputsSelect->setTabToolTip(deviceTabIndex, QString(uidCStr)); - // create a file sink by default int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileOutputDeviceIndex(); const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex); @@ -430,7 +409,6 @@ void MainWindow::addSinkDevice() m_deviceUIs.back()->m_deviceAPI->setHardwareUserArguments(userArgs); } - m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(fileSinkDeviceIndex); ui->inputViewDock->setSelectedDeviceIndex(deviceTabIndex, fileSinkDeviceIndex); // delete previous plugin GUI if it exists @@ -461,6 +439,7 @@ void MainWindow::removeLastDevice() ui->tabSpectraGUI->removeTab(ui->tabSpectraGUI->count() - 1); ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); + ui->inputViewDock->removeLastDevice(); // deletes old UI and input object m_deviceUIs.back()->freeChannels(); // destroys the channel instances @@ -471,12 +450,9 @@ void MainWindow::removeLastDevice() m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput( m_deviceUIs.back()->m_deviceAPI->getSampleSource()); m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists - m_deviceUIs.back()->m_samplingDeviceControl->removeSelectedDeviceIndex(); // This releases the device in the device list ui->tabChannels->removeTab(ui->tabChannels->count() - 1); - ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1); - m_deviceWidgetTabs.removeLast(); ui->tabInputsView->clear(); @@ -503,6 +479,7 @@ void MainWindow::removeLastDevice() ui->tabSpectraGUI->removeTab(ui->tabSpectraGUI->count() - 1); ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); + ui->inputViewDock->removeLastDevice(); // deletes old UI and output object m_deviceUIs.back()->freeChannels(); @@ -513,12 +490,9 @@ void MainWindow::removeLastDevice() m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput( m_deviceUIs.back()->m_deviceAPI->getSampleSink()); m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists - m_deviceUIs.back()->m_samplingDeviceControl->removeSelectedDeviceIndex(); // This releases the device in the device list ui->tabChannels->removeTab(ui->tabChannels->count() - 1); - ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1); - m_deviceWidgetTabs.removeLast(); ui->tabInputsView->clear(); @@ -546,6 +520,7 @@ void MainWindow::removeLastDevice() ui->tabSpectraGUI->removeTab(ui->tabSpectraGUI->count() - 1); ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); + ui->inputViewDock->removeLastDevice(); // deletes old UI and output object m_deviceUIs.back()->freeChannels(); @@ -555,10 +530,8 @@ void MainWindow::removeLastDevice() m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId(); m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO( m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()); - m_deviceUIs.back()->m_samplingDeviceControl->removeSelectedDeviceIndex(); // This releases the device in the device list ui->tabChannels->removeTab(ui->tabChannels->count() - 1); - ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1); m_deviceWidgetTabs.removeLast(); ui->tabInputsView->clear(); @@ -961,25 +934,17 @@ bool MainWindow::handleMessage(const Message& cmd) else if (MsgSetDevice::match(cmd)) { MsgSetDevice& notif = (MsgSetDevice&) cmd; - ui->tabInputsSelect->setCurrentIndex(notif.getDeviceSetIndex()); + ui->tabInputsView->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(); - } else if (notif.getDeviceType() == 0) { - sampleSourceChanged(); - } else if (notif.getDeviceType() == 2) { - sampleMIMOChanged(); - } + samplingDeviceChanged(notif.getDeviceType(), notif.getDeviceSetIndex(), notif.getDeviceIndex()); return true; } else if (MsgAddChannel::match(cmd)) { MsgAddChannel& notif = (MsgAddChannel&) cmd; - ui->tabInputsSelect->setCurrentIndex(notif.getDeviceSetIndex()); + ui->tabInputsView->setCurrentIndex(notif.getDeviceSetIndex()); channelAddClicked(notif.getChannelRegistrationIndex()); return true; @@ -1199,7 +1164,7 @@ void MainWindow::on_commandRun_clicked() if (item != 0) { - int currentDeviceSetIndex = ui->tabInputsSelect->currentIndex(); + int currentDeviceSetIndex = ui->tabInputsView->currentIndex(); if (item->type() == PItem) // run individual command { @@ -1753,117 +1718,6 @@ void MainWindow::sampleSourceChanged(int tabIndex, int newDeviceIndex) } } -void MainWindow::sampleSourceChanged() -{ - // Do it in the currently selected source tab - int currentSourceTabIndex = ui->tabInputsSelect->currentIndex(); - - if (currentSourceTabIndex >= 0) - { - qDebug("MainWindow::sampleSourceChanged: tab at %d", currentSourceTabIndex); - DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; - 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( - deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()); - 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(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex())); - - if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default - { - qDebug("MainWindow::sampleSourceChanged: non existent device replaced by File Input"); - int deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex(); - samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex); - 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(deviceIndex)); - } - - 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::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(currentSourceTabIndex, gui, deviceUI->m_deviceAPI->getSamplingDeviceDisplayName()); - deviceUI->m_deviceAPI->getSampleSource()->init(); - - deviceUI->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings - - if (currentSourceTabIndex == 0) // save as default starting device - { - m_settings.setSourceIndex(samplingDevice->sequence); - m_settings.setSourceDeviceId(samplingDevice->id); - } - } -} - void MainWindow::sampleSinkChanged(int tabIndex, int newDeviceIndex) { if (tabIndex >= 0) @@ -1965,170 +1819,10 @@ void MainWindow::sampleSinkChanged(int tabIndex, int newDeviceIndex) } } -void MainWindow::sampleSinkChanged() -{ - // Do it in the currently selected source tab - int currentSinkTabIndex = ui->tabInputsSelect->currentIndex(); - - if (currentSinkTabIndex >= 0) - { - qDebug("MainWindow::sampleSinkChanged: tab at %d", currentSinkTabIndex); - DeviceUISet *deviceUI = m_deviceUIs[currentSinkTabIndex]; - 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(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()); - 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(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex())); - - 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::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(currentSinkTabIndex, gui, deviceUI->m_deviceAPI->getSamplingDeviceDisplayName(), 1); - m_deviceUIs.back()->m_deviceAPI->getSampleSink()->init(); - - deviceUI->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings - } -} - -void MainWindow::sampleMIMOChanged() -{ - // Do it in the currently selected source tab - int currentMIMOTabIndex = ui->tabInputsSelect->currentIndex(); - - if (currentMIMOTabIndex >= 0) - { - qDebug("MainWindow::sampleMIMOChanged: tab at %d", currentMIMOTabIndex); - DeviceUISet *deviceUI = m_deviceUIs[currentMIMOTabIndex]; - deviceUI->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings - deviceUI->m_deviceAPI->stopDeviceEngine(); - - // deletes old UI and output object - deviceUI->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI - deviceUI->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceGUI( - deviceUI->m_deviceAPI->getSamplingDevicePluginInstanceGUI()); - deviceUI->m_deviceAPI->resetSamplingDeviceId(); - deviceUI->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO( - deviceUI->m_deviceAPI->getSampleMIMO()); - - const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice( - deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()); - 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()->getMIMOPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex())); - - QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence); - - if (userArgs.size() > 0) { - deviceUI->m_deviceAPI->setHardwareUserArguments(userArgs); - } - - // constructs new GUI and MIMO object - DeviceSampleMIMO *mimo = deviceUI->m_deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance( - deviceUI->m_deviceAPI->getSamplingDeviceId(), deviceUI->m_deviceAPI); - deviceUI->m_deviceAPI->setSampleMIMO(mimo); - QWidget *gui; - PluginInstanceGUI *pluginUI = deviceUI->m_deviceAPI->getPluginInterface()->createSampleMIMOPluginInstanceGUI( - deviceUI->m_deviceAPI->getSamplingDeviceId(), - &gui, - deviceUI); - deviceUI->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(pluginUI->getInputMessageQueue()); - deviceUI->m_deviceAPI->setSamplingDevicePluginInstanceGUI(pluginUI); - setDeviceGUI(currentMIMOTabIndex, gui, deviceUI->m_deviceAPI->getSamplingDeviceDisplayName(), 2); - m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()->init(); - - deviceUI->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings - } -} - void MainWindow::channelAddClicked(int channelIndex) { // Do it in the currently selected source tab - int currentSourceTabIndex = ui->tabInputsSelect->currentIndex(); + int currentSourceTabIndex = ui->tabInputsView->currentIndex(); if (currentSourceTabIndex >= 0) { @@ -2210,7 +1904,6 @@ void MainWindow::tabInputViewIndexChanged() ui->tabSpectra->setCurrentIndex(inputViewIndex); ui->tabChannels->setCurrentIndex(inputViewIndex); - ui->tabInputsSelect->setCurrentIndex(inputViewIndex); ui->tabSpectraGUI->setCurrentIndex(inputViewIndex); } @@ -2303,7 +1996,7 @@ void MainWindow::setLoggingOptions() void MainWindow::commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release) { //qDebug("MainWindow::commandKeyPressed: key: %x mod: %x %s", (int) key, (int) keyModifiers, release ? "release" : "press"); - int currentDeviceSetIndex = ui->tabInputsSelect->currentIndex(); + int currentDeviceSetIndex = ui->tabInputsView->currentIndex(); for (int i = 0; i < m_settings.getCommandCount(); ++i) { diff --git a/sdrgui/mainwindow.h b/sdrgui/mainwindow.h index 3f269d5f4..916287a9a 100644 --- a/sdrgui/mainwindow.h +++ b/sdrgui/mainwindow.h @@ -400,9 +400,6 @@ private slots: 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(); void channelAddClicked(int channelIndex); void on_action_Loaded_Plugins_triggered(); void on_action_About_triggered(); diff --git a/sdrgui/mainwindow.ui b/sdrgui/mainwindow.ui index 30945ca9f..665eb0c25 100644 --- a/sdrgui/mainwindow.ui +++ b/sdrgui/mainwindow.ui @@ -691,52 +691,6 @@ - - - Sampling devices control - - - 1 - - - - - 0 - 0 - - - - - 3 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 110 - - - - -1 - - - - - - E&xit