| 271 | } |
| 272 | |
| 273 | void |
| 274 | SourceWidget::refreshGains(Suscan::Source::Config &config) |
| 275 | { |
| 276 | Suscan::Source::Device const &dev = config.getDevice(); |
| 277 | DeviceGain *gain = nullptr; |
| 278 | bool presetEnabled = this->ui->gainPresetCheck->isChecked(); |
| 279 | |
| 280 | this->clearGains(); |
| 281 | |
| 282 | for (auto p = dev.getFirstGain(); |
| 283 | p != dev.getLastGain(); |
| 284 | ++p) { |
| 285 | gain = new DeviceGain(nullptr, *p); |
| 286 | this->gainControls.push_back(gain); |
| 287 | this->ui->gainGridLayout->addWidget( |
| 288 | gain, |
| 289 | static_cast<int>(this->gainControls.size() - 1), |
| 290 | 0, |
| 291 | 1, |
| 292 | 1); |
| 293 | |
| 294 | connect( |
| 295 | gain, |
| 296 | SIGNAL(gainChanged(QString, float)), |
| 297 | this, |
| 298 | SLOT(onGainChanged(QString, float))); |
| 299 | gain->setGain(config.getGain(p->getName())); |
| 300 | } |
| 301 | |
| 302 | if (this->gainControls.size() == 0 |
| 303 | || config.getType() != SUSCAN_SOURCE_TYPE_SDR) |
| 304 | this->ui->gainsFrame->hide(); |
| 305 | else |
| 306 | this->ui->gainsFrame->show(); |
| 307 | |
| 308 | if (presetEnabled) |
| 309 | this->refreshCurrentAutoGain(dev.getDriver()); |
| 310 | else |
| 311 | this->ui->gainsFrame->setEnabled(true); |
| 312 | } |
| 313 | |
| 314 | bool |
| 315 | SourceWidget::tryApplyGains( |
no test coverage detected