Qt: Move speed settings into its own category

This commit is contained in:
Connor McLaughlin 2021-01-23 17:33:36 +10:00
parent ddcc29c8a6
commit e54ba23c4f
13 changed files with 243 additions and 116 deletions

View file

@ -37,6 +37,9 @@ set(SRCS
displaysettingswidget.cpp
displaysettingswidget.h
displaysettingswidget.ui
emulationsettingswidget.cpp
emulationsettingswidget.h
emulationsettingswidget.ui
enhancementsettingswidget.cpp
enhancementsettingswidget.h
enhancementsettingswidget.ui

View file

@ -25,8 +25,6 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console", "Region",
&Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName,
Settings::DEFAULT_CONSOLE_REGION);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToHostRefreshRate, "Main",
"SyncToHostRefreshRate", false);
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU", "ExecutionMode",
&Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName,
Settings::DEFAULT_CPU_EXECUTION_MODE);
@ -37,28 +35,6 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromLoadImageToRAM, "CDROM", "LoadImageToRAM",
false);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
const int emulation_speed_index =
m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "EmulationSpeed", 1.0f)));
if (emulation_speed_index >= 0)
m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index);
connect(m_ui.emulationSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConsoleSettingsWidget::onEmulationSpeedIndexChanged);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed);
const int fast_forward_speed_index =
m_ui.fastForwardSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "FastForwardSpeed", 0.0f)));
if (fast_forward_speed_index >= 0)
m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index);
connect(m_ui.fastForwardSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConsoleSettingsWidget::onFastForwardSpeedIndexChanged);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.turboSpeed);
const int turbo_speed_index =
m_ui.turboSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "TurboSpeed", 0.0f)));
if (turbo_speed_index >= 0)
m_ui.turboSpeed->setCurrentIndex(turbo_speed_index);
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConsoleSettingsWidget::onTurboSpeedIndexChanged);
dialog->registerWidgetHelp(
m_ui.cdromLoadImageToRAM, tr("Preload Image to RAM"), tr("Unchecked"),
tr("Loads the game image into RAM. Useful for network paths that may become unreliable during gameplay. In some "
@ -67,24 +43,6 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
m_ui.cdromReadSpeedup, tr("CDROM Read Speedup"), tr("None (Double Speed)"),
tr("Speeds up CD-ROM reads by the specified factor. Only applies to double-speed reads, and is ignored when audio "
"is playing. May improve loading speeds in some games, at the cost of breaking others."));
dialog->registerWidgetHelp(
m_ui.emulationSpeed, tr("Emulation Speed"), "100%",
tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, "
"and if not, the emulator will run as fast as it can manage."));
dialog->registerWidgetHelp(
m_ui.fastForwardSpeed, tr("Fast Forward Speed"), tr("User Preference"),
tr("Sets the fast forward speed. This speed will be used when the fast forward hotkey is pressed/toggled."));
dialog->registerWidgetHelp(
m_ui.turboSpeed, tr("Turbo Speed"), tr("User Preference"),
tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled. Turboing will take "
"priority over fast forwarding if both hotkeys are pressed/toggled."));
dialog->registerWidgetHelp(
m_ui.syncToHostRefreshRate, tr("Sync To Host Refresh Rate"), tr("Unchecked"),
tr("Adjusts the emulation speed so the console's refresh rate matches the host's refresh rate when both VSync and "
"Audio Resampling settings are enabled. This results in the smoothest animations possible, at the cost of "
"potentially increasing the emulation speed by less than 1%. Sync To Host Refresh Rate will not take effect if "
"the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays "
"should disable this option."));
m_ui.cpuClockSpeed->setEnabled(m_ui.enableCPUClockSpeedControl->checkState() == Qt::Checked);
m_ui.cdromReadSpeedup->setCurrentIndex(m_host_interface->GetIntSettingValue("CDROM", "ReadSpeedup", 1) - 1);
@ -160,27 +118,3 @@ void ConsoleSettingsWidget::calculateCPUClockValue()
m_ui.cpuClockSpeed->setValue(static_cast<int>(percent));
updateCPUClockSpeedLabel();
}
void ConsoleSettingsWidget::onEmulationSpeedIndexChanged(int index)
{
bool okay;
const float value = m_ui.emulationSpeed->currentData().toFloat(&okay);
m_host_interface->SetFloatSettingValue("Main", "EmulationSpeed", okay ? value : 1.0f);
m_host_interface->applySettings();
}
void ConsoleSettingsWidget::onFastForwardSpeedIndexChanged(int index)
{
bool okay;
const float value = m_ui.fastForwardSpeed->currentData().toFloat(&okay);
m_host_interface->SetFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f);
m_host_interface->applySettings();
}
void ConsoleSettingsWidget::onTurboSpeedIndexChanged(int index)
{
bool okay;
const float value = m_ui.turboSpeed->currentData().toFloat(&okay);
m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f);
m_host_interface->applySettings();
}

View file

@ -20,9 +20,6 @@ private Q_SLOTS:
void onCPUClockSpeedValueChanged(int value);
void updateCPUClockSpeedLabel();
void onCDROMReadSpeedupValueChanged(int value);
void onEmulationSpeedIndexChanged(int index);
void onFastForwardSpeedIndexChanged(int index);
void onTurboSpeedIndexChanged(int index);
private:
void calculateCPUClockValue();

View file

@ -45,52 +45,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Speed Control</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="emulationSpeed"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Fast Forward Speed:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="fastForwardSpeed"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Turbo Speed:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="turboSpeed"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="syncToHostRefreshRate">
<property name="text">
<string>Sync To Host Refresh Rate</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">

View file

@ -59,6 +59,7 @@
<ClCompile Include="cheatmanagerdialog.cpp" />
<ClCompile Include="cheatcodeeditordialog.cpp" />
<ClCompile Include="consolesettingswidget.cpp" />
<ClCompile Include="emulationsettingswidget.cpp" />
<ClCompile Include="debuggermodels.cpp" />
<ClCompile Include="debuggerwindow.cpp" />
<ClCompile Include="enhancementsettingswidget.cpp" />
@ -118,6 +119,7 @@
<ClInclude Include="resource.h" />
<ClInclude Include="settingwidgetbinder.h" />
<QtMoc Include="consolesettingswidget.h" />
<QtMoc Include="emulationsettingswidget.h" />
<QtMoc Include="gamelistsettingswidget.h" />
<QtMoc Include="gamelistwidget.h" />
<QtMoc Include="gamepropertiesdialog.h" />
@ -164,6 +166,9 @@
<QtUi Include="consolesettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="emulationsettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="enhancementsettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
@ -219,6 +224,7 @@
<ClCompile Include="$(IntDir)moc_cheatcodeeditordialog.cpp" />
<ClCompile Include="$(IntDir)moc_consolesettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_controllersettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_emulationsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_enhancementsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_gamelistmodel.cpp" />
<ClCompile Include="$(IntDir)moc_gamelistsearchdirectoriesmodel.cpp" />

View file

@ -0,0 +1,83 @@
#include "emulationsettingswidget.h"
#include "core/system.h"
#include "qtutils.h"
#include "settingsdialog.h"
#include "settingwidgetbinder.h"
#include <QtWidgets/QMessageBox>
EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface, QWidget* parent,
SettingsDialog* dialog)
: QWidget(parent), m_host_interface(host_interface)
{
m_ui.setupUi(this);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToHostRefreshRate, "Main",
"SyncToHostRefreshRate", false);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
const int emulation_speed_index =
m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "EmulationSpeed", 1.0f)));
if (emulation_speed_index >= 0)
m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index);
connect(m_ui.emulationSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&EmulationSettingsWidget::onEmulationSpeedIndexChanged);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed);
const int fast_forward_speed_index =
m_ui.fastForwardSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "FastForwardSpeed", 0.0f)));
if (fast_forward_speed_index >= 0)
m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index);
connect(m_ui.fastForwardSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&EmulationSettingsWidget::onFastForwardSpeedIndexChanged);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.turboSpeed);
const int turbo_speed_index =
m_ui.turboSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "TurboSpeed", 0.0f)));
if (turbo_speed_index >= 0)
m_ui.turboSpeed->setCurrentIndex(turbo_speed_index);
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&EmulationSettingsWidget::onTurboSpeedIndexChanged);
dialog->registerWidgetHelp(
m_ui.emulationSpeed, tr("Emulation Speed"), "100%",
tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, "
"and if not, the emulator will run as fast as it can manage."));
dialog->registerWidgetHelp(
m_ui.fastForwardSpeed, tr("Fast Forward Speed"), tr("User Preference"),
tr("Sets the fast forward speed. This speed will be used when the fast forward hotkey is pressed/toggled."));
dialog->registerWidgetHelp(
m_ui.turboSpeed, tr("Turbo Speed"), tr("User Preference"),
tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled. Turboing will take "
"priority over fast forwarding if both hotkeys are pressed/toggled."));
dialog->registerWidgetHelp(
m_ui.syncToHostRefreshRate, tr("Sync To Host Refresh Rate"), tr("Unchecked"),
tr("Adjusts the emulation speed so the console's refresh rate matches the host's refresh rate when both VSync and "
"Audio Resampling settings are enabled. This results in the smoothest animations possible, at the cost of "
"potentially increasing the emulation speed by less than 1%. Sync To Host Refresh Rate will not take effect if "
"the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays "
"should disable this option."));
}
EmulationSettingsWidget::~EmulationSettingsWidget() = default;
void EmulationSettingsWidget::onEmulationSpeedIndexChanged(int index)
{
bool okay;
const float value = m_ui.emulationSpeed->currentData().toFloat(&okay);
m_host_interface->SetFloatSettingValue("Main", "EmulationSpeed", okay ? value : 1.0f);
m_host_interface->applySettings();
}
void EmulationSettingsWidget::onFastForwardSpeedIndexChanged(int index)
{
bool okay;
const float value = m_ui.fastForwardSpeed->currentData().toFloat(&okay);
m_host_interface->SetFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f);
m_host_interface->applySettings();
}
void EmulationSettingsWidget::onTurboSpeedIndexChanged(int index)
{
bool okay;
const float value = m_ui.turboSpeed->currentData().toFloat(&okay);
m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f);
m_host_interface->applySettings();
}

View file

@ -0,0 +1,28 @@
#pragma once
#include <QtWidgets/QWidget>
#include "ui_emulationsettingswidget.h"
class QtHostInterface;
class SettingsDialog;
class EmulationSettingsWidget : public QWidget
{
Q_OBJECT
public:
explicit EmulationSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog);
~EmulationSettingsWidget();
private Q_SLOTS:
void onEmulationSpeedIndexChanged(int index);
void onFastForwardSpeedIndexChanged(int index);
void onTurboSpeedIndexChanged(int index);
private:
Ui::EmulationSettingsWidget m_ui;
QtHostInterface* m_host_interface;
};

View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EmulationSettingsWidget</class>
<widget class="QWidget" name="EmulationSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>648</width>
<height>456</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Speed Control</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="emulationSpeed"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Fast Forward Speed:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="fastForwardSpeed"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Turbo Speed:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="turboSpeed"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="syncToHostRefreshRate">
<property name="text">
<string>Sync To Host Refresh Rate</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="resources/resources.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -969,6 +969,8 @@ void MainWindow::connectSignals()
[this]() { doSettings(SettingsDialog::Category::BIOSSettings); });
connect(m_ui.actionConsoleSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::ConsoleSettings); });
connect(m_ui.actionEmulationSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::EmulationSettings); });
connect(m_ui.actionGameListSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::GameListSettings); });
connect(m_ui.actionHotkeySettings, &QAction::triggered,

View file

@ -119,6 +119,7 @@
<addaction name="actionGeneralSettings"/>
<addaction name="actionBIOSSettings"/>
<addaction name="actionConsoleSettings"/>
<addaction name="actionEmulationSettings"/>
<addaction name="actionGameListSettings"/>
<addaction name="actionHotkeySettings"/>
<addaction name="actionControllerSettings"/>
@ -375,6 +376,15 @@
<string>C&amp;onsole Settings...</string>
</property>
</action>
<action name="actionEmulationSettings">
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/applications-other.png</normaloff>:/icons/applications-other.png</iconset>
</property>
<property name="text">
<string>E&amp;mulation Settings...</string>
</property>
</action>
<action name="actionControllerSettings">
<property name="icon">
<iconset resource="resources/resources.qrc">
@ -387,7 +397,7 @@
<action name="actionHotkeySettings">
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/applications-other.png</normaloff>:/icons/applications-other.png</iconset>
<normaloff>:/icons/preferences-desktop-keyboard-shortcuts.png</normaloff>:/icons/preferences-desktop-keyboard-shortcuts.png</iconset>
</property>
<property name="text">
<string>&amp;Hotkey Settings...</string>

View file

@ -5,6 +5,7 @@
#include "consolesettingswidget.h"
#include "controllersettingswidget.h"
#include "displaysettingswidget.h"
#include "emulationsettingswidget.h"
#include "enhancementsettingswidget.h"
#include "gamelistsettingswidget.h"
#include "generalsettingswidget.h"
@ -27,6 +28,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
m_general_settings = new GeneralSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_bios_settings = new BIOSSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_emulation_settings = new EmulationSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer);
m_hotkey_settings = new HotkeySettingsWidget(host_interface, m_ui.settingsContainer);
m_controller_settings = new ControllerSettingsWidget(host_interface, m_ui.settingsContainer);
@ -40,6 +42,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::GeneralSettings), m_general_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::BIOSSettings), m_bios_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::ConsoleSettings), m_console_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::EmulationSettings), m_emulation_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::GameListSettings), m_game_list_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::HotkeySettings), m_hotkey_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::ControllerSettings), m_controller_settings);

View file

@ -12,6 +12,7 @@ class BIOSSettingsWidget;
class GameListSettingsWidget;
class HotkeySettingsWidget;
class ConsoleSettingsWidget;
class EmulationSettingsWidget;
class ControllerSettingsWidget;
class MemoryCardSettingsWidget;
class DisplaySettingsWidget;
@ -30,6 +31,7 @@ public:
GeneralSettings,
BIOSSettings,
ConsoleSettings,
EmulationSettings,
GameListSettings,
HotkeySettings,
ControllerSettings,
@ -48,6 +50,7 @@ public:
GeneralSettingsWidget* getGeneralSettingsWidget() const { return m_general_settings; }
BIOSSettingsWidget* getBIOSSettingsWidget() const { return m_bios_settings; }
ConsoleSettingsWidget* getConsoleSettingsWidget() const { return m_console_settings; }
EmulationSettingsWidget* getEmulationSettingsWidget() const { return m_emulation_settings; }
GameListSettingsWidget* getGameListSettingsWidget() const { return m_game_list_settings; }
HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }
ControllerSettingsWidget* getControllerSettingsWidget() const { return m_controller_settings; }
@ -77,6 +80,7 @@ private:
GeneralSettingsWidget* m_general_settings = nullptr;
BIOSSettingsWidget* m_bios_settings = nullptr;
ConsoleSettingsWidget* m_console_settings = nullptr;
EmulationSettingsWidget* m_emulation_settings = nullptr;
GameListSettingsWidget* m_game_list_settings = nullptr;
HotkeySettingsWidget* m_hotkey_settings = nullptr;
ControllerSettingsWidget* m_controller_settings = nullptr;

View file

@ -80,6 +80,15 @@
<normaloff>:/icons/utilities-system-monitor.png</normaloff>:/icons/utilities-system-monitor.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Emulation Settings</string>
</property>
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/applications-other.png</normaloff>:/icons/applications-other.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Game List Settings</string>