CIoConfig::CIoConfig(QSettings *settings, QWidget *parent) : QDialog(parent), ui(new Ui::CIoConfig), m_settings(settings) { unsigned int i=0; QString devstr; QString devlabel; bool cfgmatch=false; //flag to indicate that device from config was found ui->setupUi(this); QString indev = settings->value("input/device", "").toString(); // automatic discovery of FCD does not work on Mac // so we do it ourselves if we have portaudio #if defined(Q_WS_MAC) && defined(WITH_PORTAUDIO) portaudio_device_list devices; inDevList = devices.get_input_devices(); string this_dev; for (i = 0; i < inDevList.size(); i++) { this_dev = inDevList[i].get_name(); if (this_dev.find("FUNcube Dongle V1.0") != string::npos) { devstr = "fcd,type=1,device='FUNcube Dongle V1.0'"; ui->inDevCombo->addItem("FUNcube Dongle V1.0", QVariant(devstr)); } else if (this_dev.find("FUNcube Dongle V2.0") != string::npos) { devstr = "fcd,type=2,device='FUNcube Dongle V2.0'"; ui->inDevCombo->addItem("FUNcube Dongle V2.0", QVariant(devstr)); } if (indev == QString(inDevList[i].get_name().c_str())) { ui->inDevCombo->setCurrentIndex(i); ui->inDevEdit->setText(devstr); cfgmatch = true; } } #endif // Get list of input devices discovered by gr-osmosdr and store them in // the input device selector together with the device descriptor strings osmosdr::devices_t devs = osmosdr::device::find(); qDebug() << __FUNCTION__ << ": Available input devices:"; BOOST_FOREACH(osmosdr::device_t &dev, devs) { if (dev.count("label")) { devlabel = QString(dev["label"].c_str()); dev.erase("label"); } else { devlabel = "Unknown"; } devstr = QString(dev.to_string().c_str()); ui->inDevCombo->addItem(devlabel, QVariant(devstr)); // is this the device stored in config? if (indev == devstr) { ui->inDevCombo->setCurrentIndex(i); ui->inDevEdit->setText(devstr); cfgmatch = true; } qDebug() << " " << i << ":" << devlabel; ++i; // Following code could be used for multiple matches /* QStringList list; int pos = 0; while ((pos = rx.indexIn(devstr, pos)) != -1) { list << rx.cap(1); pos += rx.matchedLength(); } */ } ui->inDevCombo->addItem(tr("Other..."), QVariant("")); // If device string from config is not one of the detected devices // it could be that device is not plugged in (in which case we select // other) or that this is the first time (select the first detected device). if (!cfgmatch) { if (indev.isEmpty()) { // First time config: select the first detected device ui->inDevCombo->setCurrentIndex(0); ui->inDevEdit->setText(ui->inDevCombo->itemData(0).toString()); if (ui->inDevEdit->text().isEmpty()) ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); } else { // Select other ui->inDevCombo->setCurrentIndex(i); ui->inDevEdit->setText(indev); } } updateInputSampleRates(settings->value("input/sample_rate", 0).toInt()); // Analog bandwidth ui->bwSpinBox->setValue(1.0e-6*settings->value("input/bandwidth", 0.0).toDouble()); // LNB LO ui->loSpinBox->setValue(1.0e-6*settings->value("input/lnb_lo", 0.0).toDouble()); // Output device QString outdev = settings->value("output/device", "").toString(); #ifdef WITH_PULSEAUDIO // get list of output devices pa_device_list devices; outDevList = devices.get_output_devices(); qDebug() << __FUNCTION__ << ": Available output devices:"; for (i = 0; i < outDevList.size(); i++) { qDebug() << " " << i << ":" << QString(outDevList[i].get_description().c_str()); //qDebug() << " " << QString(outDevList[i].get_name().c_str()); ui->outDevCombo->addItem(QString(outDevList[i].get_description().c_str())); // note that item #i in devlist will be item #(i+1) // in combo box due to "default" if (outdev == QString(outDevList[i].get_name().c_str())) ui->outDevCombo->setCurrentIndex(i+1); } #elif defined(Q_WS_MAC) && defined(WITH_PORTAUDIO) // get list of output devices // (already defined) portaudio_device_list devices; outDevList = devices.get_output_devices(); qDebug() << __FUNCTION__ << ": Available output devices:"; for (i = 0; i < outDevList.size(); i++) { qDebug() << " " << i << ":" << QString(outDevList[i].get_name().c_str()); ui->outDevCombo->addItem(QString(outDevList[i].get_name().c_str())); // note that item #i in devlist will be item #(i+1) // in combo box due to "default" if (outdev == QString(outDevList[i].get_name().c_str())) ui->outDevCombo->setCurrentIndex(i+1); } #else ui->outDevCombo->setEditable(true); #endif // WITH_PULSEAUDIO // Signals and slots connect(this, SIGNAL(accepted()), this, SLOT(saveConfig())); connect(ui->inDevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(inputDeviceSelected(int))); connect(ui->inDevEdit, SIGNAL(textChanged(QString)), this, SLOT(inputDevstrChanged(QString))); }
CIoConfig::CIoConfig(QSettings * settings, std::map<QString, QVariant> &devList, QWidget *parent) : QDialog(parent), ui(new Ui::CIoConfig), m_settings(settings) { unsigned int i=0; QString devstr; bool cfgmatch=false; //flag to indicate that device from config was found ui->setupUi(this); QString indev = settings->value("input/device", "").toString(); // insert the device list in device combo box std::map<QString, QVariant>::iterator I = devList.begin(); i = 0; while (I != devList.end()) { devstr = (*I).second.toString(); ui->inDevCombo->addItem((*I).first, devstr); // is this the device stored in config? if (indev == devstr) { ui->inDevCombo->setCurrentIndex(i); ui->inDevEdit->setText(devstr); cfgmatch = true; } ++I; ++i; } ui->inDevCombo->addItem(tr("Other..."), QVariant("")); // If device string from config is not one of the detected devices // it could be that device is not plugged in (in which case we select // other) or that this is the first time (select the first detected device). if (!cfgmatch) { if (indev.isEmpty()) { // First time config: select the first detected device ui->inDevCombo->setCurrentIndex(0); ui->inDevEdit->setText(ui->inDevCombo->itemData(0).toString()); if (ui->inDevEdit->text().isEmpty()) ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); } else { // Select other ui->inDevCombo->setCurrentIndex(i); ui->inDevEdit->setText(indev); } } // input rate updateInputSampleRates(settings->value("input/sample_rate", 0).toInt()); // decimation int idx = decim2idx(settings->value("input/decimation", 0).toInt()); ui->decimCombo->setCurrentIndex(idx); decimationChanged(idx); // Analog bandwidth ui->bwSpinBox->setValue(1.0e-6*settings->value("input/bandwidth", 0.0).toDouble()); // LNB LO ui->loSpinBox->setValue(1.0e-6 * settings->value("input/lnb_lo", 0.0).toDouble()); // Output device QString outdev = settings->value("output/device", "").toString(); // get list of audio output devices #ifdef WITH_PULSEAUDIO pa_device_list devices; outDevList = devices.get_output_devices(); qDebug() << __FUNCTION__ << ": Available output devices:"; for (i = 0; i < outDevList.size(); i++) { qDebug() << " " << i << ":" << QString(outDevList[i].get_description().c_str()); //qDebug() << " " << QString(outDevList[i].get_name().c_str()); ui->outDevCombo->addItem(QString(outDevList[i].get_description().c_str())); // note that item #i in devlist will be item #(i+1) // in combo box due to "default" if (outdev == QString(outDevList[i].get_name().c_str())) ui->outDevCombo->setCurrentIndex(i+1); } #elif WITH_PORTAUDIO portaudio_device_list devices; outDevList = devices.get_output_devices(); for (i = 0; i < outDevList.size(); i++) { ui->outDevCombo->addItem(QString(outDevList[i].get_description().c_str())); // note that item #i in devlist will be item #(i+1) // in combo box due to "default" if (outdev == QString(outDevList[i].get_name().c_str())) ui->outDevCombo->setCurrentIndex(i+1); } //ui->outDevCombo->setEditable(true); #elif defined(GQRX_OS_MACX) osxaudio_device_list devices; outDevList = devices.get_output_devices(); qDebug() << __FUNCTION__ << ": Available output devices:"; for (i = 0; i < outDevList.size(); i++) { qDebug() << " " << i << ":" << QString(outDevList[i].get_name().c_str()); ui->outDevCombo->addItem(QString(outDevList[i].get_name().c_str())); // note that item #i in devlist will be item #(i+1) // in combo box due to "default" if (outdev == QString(outDevList[i].get_name().c_str())) ui->outDevCombo->setCurrentIndex(i+1); } #else ui->outDevCombo->addItem(settings->value("output/device", "Default").toString(), settings->value("output/device", "Default").toString()); ui->outDevCombo->setEditable(true); #endif // WITH_PULSEAUDIO // Signals and slots connect(this, SIGNAL(accepted()), this, SLOT(saveConfig())); connect(ui->inDevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(inputDeviceSelected(int))); connect(ui->inDevEdit, SIGNAL(textChanged(QString)), this, SLOT(inputDevstrChanged(QString))); connect(ui->inSrCombo, SIGNAL(editTextChanged(QString)), this, SLOT(inputRateChanged(QString))); connect(ui->decimCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(decimationChanged(int))); }