From ecbff75bf1a1edee43f29bc3505f5ee0e79100cb Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 17 May 2016 14:21:27 +0200 Subject: [PATCH] Multi device support: add a check button to confirm source input change --- sdrbase/gui/samplingdevicecontrol.cpp | 5 +++++ sdrbase/gui/samplingdevicecontrol.h | 2 ++ sdrbase/gui/samplingdevicecontrol.ui | 26 ++++++++++++++++++++++++++ sdrbase/mainwindow.cpp | 24 +++++++++++++++++++++++- sdrbase/mainwindow.h | 1 + sdrbase/resources/res.qrc | 1 + 6 files changed, 58 insertions(+), 1 deletion(-) diff --git a/sdrbase/gui/samplingdevicecontrol.cpp b/sdrbase/gui/samplingdevicecontrol.cpp index 911010ae9..643326427 100644 --- a/sdrbase/gui/samplingdevicecontrol.cpp +++ b/sdrbase/gui/samplingdevicecontrol.cpp @@ -39,6 +39,11 @@ QComboBox *SamplingDeviceControl::getDeviceSelector() return ui->deviceSelect; } +QPushButton *SamplingDeviceControl::getDeviceSelectionConfirm() +{ + return ui->deviceConfirm; +} + void SamplingDeviceControl::populateChannelSelector() { if (m_pluginManager) diff --git a/sdrbase/gui/samplingdevicecontrol.h b/sdrbase/gui/samplingdevicecontrol.h index 47aac8b53..365f0b6fb 100644 --- a/sdrbase/gui/samplingdevicecontrol.h +++ b/sdrbase/gui/samplingdevicecontrol.h @@ -20,6 +20,7 @@ #include #include +#include #include "util/export.h" @@ -41,6 +42,7 @@ public: void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; } void setDeviceAPI(DeviceAPI *devieAPI) { m_deviceAPI = devieAPI; } QComboBox *getDeviceSelector(); + QPushButton *getDeviceSelectionConfirm(); void populateChannelSelector(); private: diff --git a/sdrbase/gui/samplingdevicecontrol.ui b/sdrbase/gui/samplingdevicecontrol.ui index de7c6c718..ad0f7add9 100644 --- a/sdrbase/gui/samplingdevicecontrol.ui +++ b/sdrbase/gui/samplingdevicecontrol.ui @@ -47,6 +47,32 @@ + + + + + 24 + 0 + + + + + 24 + 16777215 + + + + Confirm and change sampling device + + + + + + + :/checkmark.png:/checkmark.png + + + diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index c166db3f5..373e07dd4 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -201,7 +201,10 @@ void MainWindow::addDevice() bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true); m_pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()); - connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int))); + +// connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int))); + connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelectionConfirm(), SIGNAL(clicked(bool)), this, SLOT(on_sampleSource_confirmClicked(bool))); + m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked); ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr); @@ -681,6 +684,25 @@ void MainWindow::on_sampleSource_currentIndexChanged(int index) } } +void MainWindow::on_sampleSource_confirmClicked(bool checked) +{ + // Do it in the currently selected source tab + int currentSourceTabIndex = ui->tabInputsSelect->currentIndex(); + + 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()); + m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI); + m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex()); + + //deviceUI->m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset()); + deviceUI->m_deviceAPI->loadSourceSettings(m_settings.getWorkingPreset()); + } +} + void MainWindow::on_action_About_triggered() { AboutDialog dlg(this); diff --git a/sdrbase/mainwindow.h b/sdrbase/mainwindow.h index 769b3407e..886067765 100644 --- a/sdrbase/mainwindow.h +++ b/sdrbase/mainwindow.h @@ -148,6 +148,7 @@ private slots: void on_action_Audio_triggered(); void on_action_DV_Serial_triggered(bool checked); void on_sampleSource_currentIndexChanged(int index); + void on_sampleSource_confirmClicked(bool checked); void on_action_About_triggered(); void on_action_addDevice_triggered(); void on_action_removeDevice_triggered(); diff --git a/sdrbase/resources/res.qrc b/sdrbase/resources/res.qrc index 71d9b4eb0..7a23b04d3 100644 --- a/sdrbase/resources/res.qrc +++ b/sdrbase/resources/res.qrc @@ -1,5 +1,6 @@ + checkmark.png questionmark.png res.qrc export.png