MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / handleSpeedComboChange

Method handleSpeedComboChange

pcsx2-qt/Settings/EmulationSettingsWidget.cpp:221–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221void 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
260void EmulationSettingsWidget::onOptimalFramePacingChanged()
261{

Callers

nothing calls this directly

Calls 9

GetRootWidgetFunction · 0.85
QVariantClass · 0.85
isPerGameSettingsMethod · 0.80
getSettingsInterfaceMethod · 0.80
argMethod · 0.80
setFloatSettingValueMethod · 0.80
countMethod · 0.45
GetFloatValueMethod · 0.45

Tested by

no test coverage detected