Qt: Add CPU settings/emulation speed to console settings

This commit is contained in:
Connor McLaughlin 2020-01-29 00:01:44 +10:00
parent 5272ecd572
commit 6624df1e8c
3 changed files with 199 additions and 81 deletions

View File

@ -9,6 +9,9 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
for (u32 i = 0; i < static_cast<u32>(CPUExecutionMode::Count); i++)
m_ui.cpuExecutionMode->addItem(tr(Settings::GetCPUExecutionModeDisplayName(static_cast<CPUExecutionMode>(i))));
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console/Region", SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console/Region",
&Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName); &Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName);
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.biosPath, "BIOS/Path"); SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.biosPath, "BIOS/Path");
@ -16,9 +19,17 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.fastBoot, "BIOS/PatchFastBoot"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.fastBoot, "BIOS/PatchFastBoot");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter,
"General/SpeedLimiterEnabled"); "General/SpeedLimiterEnabled");
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.emulationSpeed, "General/EmulationSpeed");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "General/StartPaused"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "General/StartPaused");
connect(m_ui.biosPathBrowse, &QPushButton::pressed, this, &ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked); connect(m_ui.biosPathBrowse, &QPushButton::pressed, this, &ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked);
connect(m_ui.enableSpeedLimiter, &QCheckBox::stateChanged, this,
&ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged);
connect(m_ui.emulationSpeed, &QSlider::valueChanged, this, &ConsoleSettingsWidget::onEmulationSpeedValueChanged);
onEnableSpeedLimiterStateChanged();
onEmulationSpeedValueChanged(m_ui.emulationSpeed->value());
} }
ConsoleSettingsWidget::~ConsoleSettingsWidget() = default; ConsoleSettingsWidget::~ConsoleSettingsWidget() = default;
@ -34,3 +45,13 @@ void ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked()
m_host_interface->putSettingValue("BIOS/Path", path); m_host_interface->putSettingValue("BIOS/Path", path);
m_host_interface->applySettings(); m_host_interface->applySettings();
} }
void ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged()
{
m_ui.emulationSpeed->setDisabled(!m_ui.enableSpeedLimiter->isChecked());
}
void ConsoleSettingsWidget::onEmulationSpeedValueChanged(int value)
{
m_ui.emulationSpeedLabel->setText(tr("%1%").arg(value));
}

View File

@ -16,6 +16,8 @@ public:
private Q_SLOTS: private Q_SLOTS:
void onBrowseBIOSPathButtonClicked(); void onBrowseBIOSPathButtonClicked();
void onEnableSpeedLimiterStateChanged();
void onEmulationSpeedValueChanged(int value);
private: private:
Ui::ConsoleSettingsWidget m_ui; Ui::ConsoleSettingsWidget m_ui;

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>502</width> <width>502</width>
<height>308</height> <height>358</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@ -23,89 +23,184 @@
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <property name="bottomMargin">
<layout class="QFormLayout" name="formLayout"> <number>0</number>
<item row="0" column="0"> </property>
<widget class="QLabel" name="label"> <item>
<property name="text"> <widget class="QGroupBox" name="groupBox">
<string>Region:</string> <property name="title">
</property> <string>Console</string>
</widget> </property>
</item> <layout class="QFormLayout" name="formLayout">
<item row="0" column="1"> <item row="0" column="0">
<widget class="QComboBox" name="region"> <widget class="QLabel" name="label">
<item>
<property name="text"> <property name="text">
<string>Auto-Detect</string> <string>Region:</string>
</property> </property>
</item> </widget>
<item> </item>
<property name="text"> <item row="0" column="1">
<string>NTSC-J (Japan)</string> <widget class="QComboBox" name="region">
</property> <item>
</item>
<item>
<property name="text">
<string>NTSC-U (US)</string>
</property>
</item>
<item>
<property name="text">
<string>PAL (Europe, Australia)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>BIOS Path:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="biosPath"/>
</item>
<item>
<widget class="QPushButton" name="biosPathBrowse">
<property name="text"> <property name="text">
<string>...</string> <string>Auto-Detect</string>
</property> </property>
</widget> </item>
</item> <item>
</layout> <property name="text">
</item> <string>NTSC-J (Japan)</string>
<item row="2" column="0" colspan="2"> </property>
<widget class="QCheckBox" name="enableTTYOutput"> </item>
<property name="text"> <item>
<string>Enable TTY Output</string> <property name="text">
</property> <string>NTSC-U (US)</string>
</widget> </property>
</item> </item>
<item row="3" column="0" colspan="2"> <item>
<widget class="QCheckBox" name="fastBoot"> <property name="text">
<property name="text"> <string>PAL (Europe, Australia)</string>
<string>Fast Boot</string> </property>
</property> </item>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="1" column="0">
<widget class="QCheckBox" name="enableSpeedLimiter"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Enable Speed Limiter</string> <string>BIOS Image Path:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="pauseOnStart"> <widget class="QCheckBox" name="fastBoot">
<property name="text"> <property name="text">
<string>Pause On Start</string> <string>Fast Boot</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="enableTTYOutput">
<property name="text">
<string>Enable TTY Output</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="biosPath"/>
</item>
<item>
<widget class="QPushButton" name="biosPathBrowse">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Behaviour</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="emulationSpeed">
<property name="minimum">
<number>25</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
<property name="pageStep">
<number>25</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>25</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="emulationSpeedLabel">
<property name="text">
<string>100%</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="enableSpeedLimiter">
<property name="text">
<string>Enable Speed Limiter</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="pauseOnStart">
<property name="text">
<string>Pause On Start</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>CPU Emulation</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Execution Mode:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cpuExecutionMode"/>
</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> </item>
</layout> </layout>
</widget> </widget>