| 399 | } |
| 400 | |
| 401 | void |
| 402 | FFTWidget::updateRefreshRates(void) |
| 403 | { |
| 404 | int index = 0; |
| 405 | int selectedIndex = 0; |
| 406 | unsigned int diff; |
| 407 | unsigned int bestMatch = 1 << 20; /* Just a big number */ |
| 408 | this->ui->rateCombo->clear(); |
| 409 | |
| 410 | for (auto p = this->refreshRates.begin(); p != this->refreshRates.end(); ++p) { |
| 411 | if (*p == 0) { |
| 412 | QString defString = this->defaultRefreshRate == 0 |
| 413 | ? "" |
| 414 | : " (" + QString::number(this->refreshRate) + " fps)"; |
| 415 | this->ui->rateCombo->addItem("Default" + defString); |
| 416 | } else { |
| 417 | this->ui->rateCombo->addItem(QString::number(*p) + " fps"); |
| 418 | } |
| 419 | |
| 420 | diff = SCAST(unsigned, |
| 421 | std::abs(SCAST(int, *p) - SCAST(int, this->refreshRate))); |
| 422 | if (diff < bestMatch) { |
| 423 | selectedIndex = index; |
| 424 | bestMatch = diff; |
| 425 | } |
| 426 | |
| 427 | ++index; |
| 428 | } |
| 429 | |
| 430 | this->ui->rateCombo->setCurrentIndex(selectedIndex); |
| 431 | } |
| 432 | |
| 433 | static QString |
| 434 | secondsToString(unsigned int seconds) |
no test coverage detected