| 219 | } |
| 220 | |
| 221 | void EmulationSettingsWidget::handleSpeedComboChange(QComboBox* cb, const char* section, const char* key) |
| 222 | { |
| 223 | const int custom_index = cb->count() - 1; |
| 224 | const int current_index = cb->currentIndex(); |
| 225 | |
| 226 | std::optional<float> new_value; |
| 227 | if (current_index == custom_index) |
| 228 | { |
| 229 | bool ok = false; |
| 230 | const double custom_value = QInputDialog::getDouble( |
| 231 | QtUtils::GetRootWidget(this), tr("Custom Speed"), tr("Enter Custom Speed"), cb->currentData().toFloat(), 0.0f, 5000.0f, 1, &ok); |
| 232 | if (!ok) |
| 233 | { |
| 234 | // we need to set back to the old value |
| 235 | float value = dialog()->getEffectiveFloatValue(section, key, 1.0f); |
| 236 | |
| 237 | QSignalBlocker sb(cb); |
| 238 | if (dialog()->isPerGameSettings() && !dialog()->getSettingsInterface()->GetFloatValue(section, key, &value)) |
| 239 | cb->setCurrentIndex(0); |
| 240 | else if (const int index = cb->findData(QVariant(value)); index >= 0) |
| 241 | cb->setCurrentIndex(index); |
| 242 | |
| 243 | return; |
| 244 | } |
| 245 | |
| 246 | cb->setItemText(custom_index, tr("Custom [%1% / %2 FPS (NTSC) / %3 FPS (PAL)]") |
| 247 | .arg(custom_value) |
| 248 | .arg((60 * custom_value) / 100) |
| 249 | .arg((50 * custom_value) / 100)); |
| 250 | new_value = static_cast<float>(custom_value / 100.0); |
| 251 | } |
| 252 | else if (current_index > 0 || !dialog()->isPerGameSettings()) |
| 253 | { |
| 254 | new_value = cb->currentData().toFloat(); |
| 255 | } |
| 256 | |
| 257 | dialog()->setFloatSettingValue(section, key, new_value); |
| 258 | } |
| 259 | |
| 260 | void EmulationSettingsWidget::onOptimalFramePacingChanged() |
| 261 | { |
nothing calls this directly
no test coverage detected