Multi device support: add a check button to confirm source input change

This commit is contained in:
f4exb 2016-05-17 14:21:27 +02:00
parent 8e3e00e7e5
commit ecbff75bf1
6 changed files with 58 additions and 1 deletions

View File

@ -39,6 +39,11 @@ QComboBox *SamplingDeviceControl::getDeviceSelector()
return ui->deviceSelect;
}
QPushButton *SamplingDeviceControl::getDeviceSelectionConfirm()
{
return ui->deviceConfirm;
}
void SamplingDeviceControl::populateChannelSelector()
{
if (m_pluginManager)

View File

@ -20,6 +20,7 @@
#include <QWidget>
#include <QComboBox>
#include <QPushButton>
#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:

View File

@ -47,6 +47,32 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deviceConfirm">
<property name="minimumSize">
<size>
<width>24</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Confirm and change sampling device</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/checkmark.png</normaloff>:/checkmark.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -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);

View File

@ -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();

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>checkmark.png</file>
<file>questionmark.png</file>
<file>res.qrc</file>
<file>export.png</file>