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);
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",
&Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName);
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.enableSpeedLimiter,
"General/SpeedLimiterEnabled");
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.emulationSpeed, "General/EmulationSpeed");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "General/StartPaused");
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;
@ -34,3 +45,13 @@ void ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked()
m_host_interface->putSettingValue("BIOS/Path", path);
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:
void onBrowseBIOSPathButtonClicked();
void onEnableSpeedLimiterStateChanged();
void onEmulationSpeedValueChanged(int value);
private:
Ui::ConsoleSettingsWidget m_ui;

View File

@ -7,13 +7,13 @@
<x>0</x>
<y>0</y>
<width>502</width>
<height>308</height>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
@ -23,89 +23,184 @@
<property name="rightMargin">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Region:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="region">
<item>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Console</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Auto-Detect</string>
<string>Region:</string>
</property>
</item>
<item>
<property name="text">
<string>NTSC-J (Japan)</string>
</property>
</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">
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="region">
<item>
<property name="text">
<string>...</string>
<string>Auto-Detect</string>
</property>
</widget>
</item>
</layout>
</item>
<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="3" column="0" colspan="2">
<widget class="QCheckBox" name="fastBoot">
<property name="text">
<string>Fast Boot</string>
</property>
</widget>
</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>
</item>
<item>
<property name="text">
<string>NTSC-J (Japan)</string>
</property>
</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 Image Path:</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="fastBoot">
<property name="text">
<string>Fast Boot</string>
</property>
</widget>
</item>
<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>
</layout>
</widget>