From 942bd0a7338933779fac3c1a8a0995c72a6a5944 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 14 May 2016 14:12:57 +0200 Subject: [PATCH] Multi device support: create a dedicated UI for devices control --- CMakeLists.txt | 3 +++ sdrbase/mainwindow.cpp | 60 ++++++++++++++++++++++++++++-------------- sdrbase/mainwindow.h | 12 +++++---- sdrbase/mainwindow.ui | 6 ++--- 4 files changed, 53 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4264b8d81..94ca66bcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,7 @@ set(sdrbase_SOURCES sdrbase/gui/audiodialog.cpp sdrbase/gui/presetitem.cpp sdrbase/gui/rollupwidget.cpp + sdrbase/gui/samplingdevicecontrol.cpp sdrbase/gui/scale.cpp sdrbase/gui/scaleengine.cpp sdrbase/gui/valuedial.cpp @@ -216,6 +217,7 @@ set(sdrbase_HEADERS sdrbase/gui/audiodialog.h sdrbase/gui/presetitem.h sdrbase/gui/rollupwidget.h + sdrbase/gui/samplingdevicecontrol.h sdrbase/gui/scale.h sdrbase/gui/scaleengine.h sdrbase/gui/valuedial.h @@ -258,6 +260,7 @@ set(sdrbase_FORMS sdrbase/gui/glspectrumgui.ui sdrbase/gui/pluginsdialog.ui sdrbase/gui/audiodialog.ui + sdrbase/gui/samplingdevicecontrol.ui ) set(sdrbase_RESOURCES diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 08c8f8a64..51115ff22 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +//#include #include #include #include @@ -38,6 +38,7 @@ #include "gui/rollupwidget.h" #include "gui/channelwindow.h" #include "gui/audiodialog.h" +#include "gui/samplingdevicecontrol.h" #include "dsp/dspengine.h" #include "dsp/spectrumvis.h" #include "dsp/dspcommands.h" @@ -144,9 +145,13 @@ MainWindow::MainWindow(QWidget* parent) : //ui->sampleSource->setCurrentIndex(sampleSourceIndex); //ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); - bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_sampleSource->blockSignals(true); - m_deviceUIs.back()->m_sampleSource->setCurrentIndex(sampleSourceIndex); - m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked); +// bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_sampleSource->blockSignals(true); +// m_deviceUIs.back()->m_sampleSource->setCurrentIndex(sampleSourceIndex); +// m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked); + + bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true); + m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->setCurrentIndex(sampleSourceIndex); + m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked); } qDebug() << "MainWindow::MainWindow: load current preset settings..."; @@ -213,11 +218,18 @@ void MainWindow::addDevice() ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr); ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr); - bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_sampleSource->blockSignals(true); - pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_sampleSource); - connect(m_deviceUIs.back()->m_sampleSource, SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int))); - m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked); - ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_sampleSource, tabNameCStr); +// bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_sampleSource->blockSignals(true); +// pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_sampleSource); +// connect(m_deviceUIs.back()->m_sampleSource, SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int))); +// m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked); +// int tabInputsSelectIndex = ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_sampleSource, tabNameCStr); + + bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true); + pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()); + 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->getDeviceSelector(), tabNameCStr); + ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr); // if (dspDeviceEngineUID == 0) // { @@ -255,7 +267,7 @@ void MainWindow::removeLastDevice() m_deviceUIs.pop_back(); } -void MainWindow::addChannelCreateAction(QAction* action) +void MainWindow::addChannelCreateAction(QAction* action) // TODO: move to some tabbed UI { ui->menu_Channels->addAction(action); } @@ -646,12 +658,15 @@ void MainWindow::on_presetTree_itemActivated(QTreeWidgetItem *item, int column) on_presetLoad_clicked(); } -//void MainWindow::on_action_Loaded_Plugins_triggered() -//{ -// PluginsDialog pluginsDialog(m_pluginManager, this); -// -// pluginsDialog.exec(); -//} +void MainWindow::on_action_Loaded_Plugins_triggered() // TODO: to be moved to a tabbed UI +{ + if (m_deviceUIs.size() > 0) + { + DeviceUISet *deviceUISet = m_deviceUIs[0]; + PluginsDialog pluginsDialog(deviceUISet->m_pluginManager, this); + pluginsDialog.exec(); + } +} void MainWindow::on_action_Audio_triggered() { @@ -701,8 +716,13 @@ void MainWindow::on_sampleSource_currentIndexChanged(int index) { DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; deviceUI->m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset()); - deviceUI->m_pluginManager->selectSampleSourceByIndex(m_deviceUIs.back()->m_sampleSource->currentIndex()); - m_settings.setSourceIndex(deviceUI->m_sampleSource->currentIndex()); + +// deviceUI->m_pluginManager->selectSampleSourceByIndex(m_deviceUIs.back()->m_sampleSource->currentIndex()); +// m_settings.setSourceIndex(deviceUI->m_sampleSource->currentIndex()); + + deviceUI->m_pluginManager->selectSampleSourceByIndex(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->currentIndex()); + m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex()); + deviceUI->m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset()); } } @@ -749,7 +769,7 @@ MainWindow::DeviceUISet::DeviceUISet(QTimer& timer) m_spectrumGUI = new GLSpectrumGUI; m_spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, m_spectrum); m_channelWindow = new ChannelWindow; - m_sampleSource = new QComboBox; + m_samplingDeviceControl = new SamplingDeviceControl; m_deviceEngine = 0; m_pluginManager = 0; @@ -763,7 +783,7 @@ MainWindow::DeviceUISet::DeviceUISet(QTimer& timer) MainWindow::DeviceUISet::~DeviceUISet() { - delete m_sampleSource; + delete m_samplingDeviceControl; delete m_channelWindow; delete m_spectrumGUI; delete m_spectrumVis; diff --git a/sdrbase/mainwindow.h b/sdrbase/mainwindow.h index ef314a914..e0470c4c2 100644 --- a/sdrbase/mainwindow.h +++ b/sdrbase/mainwindow.h @@ -27,7 +27,8 @@ class QLabel; class QTreeWidgetItem; class QDir; -class QComboBox; +//class QComboBox; +class SamplingDeviceControl; class AudioDeviceInfo; class DSPEngine; @@ -58,7 +59,8 @@ public: GLSpectrum *m_spectrum; GLSpectrumGUI *m_spectrumGUI; ChannelWindow *m_channelWindow; - QComboBox *m_sampleSource; +// QComboBox *m_sampleSource; + SamplingDeviceControl *m_samplingDeviceControl; DSPDeviceEngine *m_deviceEngine; PluginManager *m_pluginManager; @@ -75,8 +77,8 @@ public: void addChannelRollup(QWidget* widget); void addViewAction(QAction* action); - void addChannelMarker(ChannelMarker* channelMarker); - void removeChannelMarker(ChannelMarker* channelMarker); + void addChannelMarker(ChannelMarker* channelMarker); // TODO: review this + void removeChannelMarker(ChannelMarker* channelMarker); // TODO: review this void setInputGUI(int deviceTabIndex, QWidget* gui); const QTimer& getMasterTimer() const { return m_masterTimer; } @@ -141,7 +143,7 @@ private slots: void on_presetDelete_clicked(); void on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); void on_presetTree_itemActivated(QTreeWidgetItem *item, int column); -// void on_action_Loaded_Plugins_triggered(); + void on_action_Loaded_Plugins_triggered(); // TODO: to be moved to a tabbed UI void on_action_Audio_triggered(); void on_action_DV_Serial_triggered(bool checked); void on_sampleSource_currentIndexChanged(int index); diff --git a/sdrbase/mainwindow.ui b/sdrbase/mainwindow.ui index a582acb0e..329182da6 100644 --- a/sdrbase/mainwindow.ui +++ b/sdrbase/mainwindow.ui @@ -400,7 +400,7 @@ - Select Sample Source + Sampling devices control 1 @@ -424,7 +424,7 @@ 0 - 50 + 80 @@ -437,7 +437,7 @@ - Sample Source + Sampling devices 1