Qt: Clean up FPS target UI (fixes #436)
Vicki Pfau vi@endrift.com
Sun, 16 Sep 2018 13:38:23 -0700
3 files changed,
18 insertions(+),
9 deletions(-)
M
CHANGES
→
CHANGES
@@ -84,6 +84,7 @@ - FFmpeg: Support lossless h.264 encoding
- Feature: Added loading savestates from command line - Qt: Allow pausing game at load (fixes mgba.io/i/1129) - Wii: Move audio handling to callbacks (fixes mgba.io/i/803) + - Qt: Clean up FPS target UI (fixes mgba.io/i/436) 0.6.3: (2017-04-14) Bugfixes:
M
src/platform/qt/SettingsView.ui
→
src/platform/qt/SettingsView.ui
@@ -326,6 +326,9 @@ <item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QDoubleSpinBox" name="fpsTarget"> + <property name="decimals"> + <number>4</number> + </property> <property name="minimum"> <double>0.010000000000000</double> </property>
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -1409,17 +1409,22 @@ addControlledAction(avMenu, muteAction, "mute");
QMenu* target = avMenu->addMenu(tr("FPS target")); ConfigOption* fpsTargetOption = m_config->addOption("fpsTarget"); - fpsTargetOption->connect([this](const QVariant& value) { + QMap<double, QAction*> fpsTargets; + for (int fps : {15, 30, 45, 60, 90, 120, 240}) { + fpsTargets[fps] = fpsTargetOption->addValue(QString::number(fps), fps, target); + } + target->addSeparator(); + double nativeGB = double(GBA_ARM7TDMI_FREQUENCY) / double(VIDEO_TOTAL_LENGTH); + fpsTargets[nativeGB] = fpsTargetOption->addValue(tr("Native (59.7275)"), nativeGB, target); + + fpsTargetOption->connect([this, fpsTargets](const QVariant& value) { reloadConfig(); + for (auto iter = fpsTargets.begin(); iter != fpsTargets.end(); ++iter) { + bool enableSignals = iter.value()->blockSignals(true); + iter.value()->setChecked(abs(iter.key() - value.toDouble()) < 0.001); + iter.value()->blockSignals(enableSignals); + } }, this); - fpsTargetOption->addValue(tr("15"), 15, target); - fpsTargetOption->addValue(tr("30"), 30, target); - fpsTargetOption->addValue(tr("45"), 45, target); - fpsTargetOption->addValue(tr("Native (59.7)"), float(GBA_ARM7TDMI_FREQUENCY) / float(VIDEO_TOTAL_LENGTH), target); - fpsTargetOption->addValue(tr("60"), 60, target); - fpsTargetOption->addValue(tr("90"), 90, target); - fpsTargetOption->addValue(tr("120"), 120, target); - fpsTargetOption->addValue(tr("240"), 240, target); m_config->updateOption("fpsTarget"); avMenu->addSeparator();