mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 21:01:45 -05:00
Simplify and clarify Plugin Manager source selection by index
This commit is contained in:
parent
83d6d9d190
commit
3869d515cd
@ -57,8 +57,8 @@ public:
|
|||||||
bool handleMessage(const Message& message);
|
bool handleMessage(const Message& message);
|
||||||
|
|
||||||
void updateSampleSourceDevices();
|
void updateSampleSourceDevices();
|
||||||
int fillSampleSourceSelector(QComboBox* comboBox);
|
void fillSampleSourceSelector(QComboBox* comboBox);
|
||||||
int selectSampleSource(int index);
|
int selectSampleSourceByIndex(int index);
|
||||||
int selectFirstSampleSource(const QString& sourceId);
|
int selectFirstSampleSource(const QString& sourceId);
|
||||||
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence);
|
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
m_pluginManager->loadPlugins();
|
m_pluginManager->loadPlugins();
|
||||||
|
|
||||||
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
||||||
int nbSources = m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
|
m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
|
||||||
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
||||||
|
|
||||||
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
||||||
@ -116,15 +116,10 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
qDebug() << "MainWindow::MainWindow: select SampleSource from settings...";
|
qDebug() << "MainWindow::MainWindow: select SampleSource from settings...";
|
||||||
|
|
||||||
int sampleSourceIndex = m_settings.getSourceIndex();
|
int sampleSourceIndex = m_settings.getSourceIndex();
|
||||||
|
sampleSourceIndex = m_pluginManager->selectSampleSourceByIndex(sampleSourceIndex);
|
||||||
|
|
||||||
if(sampleSourceIndex >= nbSources)
|
if (sampleSourceIndex >= 0)
|
||||||
{
|
{
|
||||||
sampleSourceIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nbSources > 0)
|
|
||||||
{
|
|
||||||
m_pluginManager->selectSampleSource(sampleSourceIndex);
|
|
||||||
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
||||||
ui->sampleSource->setCurrentIndex(sampleSourceIndex);
|
ui->sampleSource->setCurrentIndex(sampleSourceIndex);
|
||||||
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
||||||
@ -562,7 +557,7 @@ void MainWindow::on_action_Preferences_triggered()
|
|||||||
void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
|
m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
|
||||||
m_pluginManager->selectSampleSource(ui->sampleSource->currentIndex());
|
m_pluginManager->selectSampleSourceByIndex(ui->sampleSource->currentIndex());
|
||||||
m_settings.setSourceIndex(ui->sampleSource->currentIndex());
|
m_settings.setSourceIndex(ui->sampleSource->currentIndex());
|
||||||
m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());
|
m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());
|
||||||
}
|
}
|
||||||
|
@ -274,9 +274,9 @@ int PluginManager::fillSampleSourceSelector(QComboBox* comboBox)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PluginManager::selectSampleSource(int index)
|
int PluginManager::selectSampleSourceByIndex(int index)
|
||||||
{
|
{
|
||||||
qDebug("PluginManager::selectSampleSource by index: index: %d", index);
|
qDebug("PluginManager::selectSampleSourceByIndex: index: %d", index);
|
||||||
|
|
||||||
m_dspEngine->stopAcquistion();
|
m_dspEngine->stopAcquistion();
|
||||||
|
|
||||||
@ -288,31 +288,19 @@ int PluginManager::selectSampleSource(int index)
|
|||||||
m_sampleSourceId.clear();
|
m_sampleSourceId.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index == -1)
|
if (m_sampleSourceDevices.count() == 0)
|
||||||
{
|
{
|
||||||
if(!m_sampleSourceId.isEmpty())
|
return -1;
|
||||||
{
|
}
|
||||||
for(int i = 0; i < m_sampleSourceDevices.count(); i++)
|
|
||||||
{
|
|
||||||
if(m_sampleSourceDevices[i].m_sourceId == m_sampleSourceId)
|
|
||||||
{
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(index == -1)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
if(m_sampleSourceDevices.count() > 0)
|
return -1;
|
||||||
{
|
}
|
||||||
index = 0;
|
|
||||||
}
|
if (index >= m_sampleSourceDevices.count())
|
||||||
else
|
{
|
||||||
{
|
index = 0;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleSourceId = m_sampleSourceDevices[index].m_sourceId;
|
m_sampleSourceId = m_sampleSourceDevices[index].m_sourceId;
|
||||||
|
Loading…
Reference in New Issue
Block a user