2019-12-31 06:17:17 +00:00
|
|
|
#include "consolesettingswidget.h"
|
2020-01-01 04:01:58 +00:00
|
|
|
#include "settingwidgetbinder.h"
|
2020-01-24 04:51:31 +00:00
|
|
|
#include <QtWidgets/QFileDialog>
|
|
|
|
|
|
|
|
static constexpr char BIOS_IMAGE_FILTER[] = "Binary Images (*.bin);;All Files (*.*)";
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-01-01 04:01:58 +00:00
|
|
|
ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
|
|
|
|
: QWidget(parent), m_host_interface(host_interface)
|
2019-12-31 06:17:17 +00:00
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
2020-01-01 04:01:58 +00:00
|
|
|
|
2020-01-28 14:01:44 +00:00
|
|
|
for (u32 i = 0; i < static_cast<u32>(CPUExecutionMode::Count); i++)
|
|
|
|
m_ui.cpuExecutionMode->addItem(tr(Settings::GetCPUExecutionModeDisplayName(static_cast<CPUExecutionMode>(i))));
|
|
|
|
|
2020-01-24 04:49:49 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console/Region",
|
|
|
|
&Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName);
|
|
|
|
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.biosPath, "BIOS/Path");
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableTTYOutput, "BIOS/PatchTTYEnable");
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.fastBoot, "BIOS/PatchFastBoot");
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter,
|
|
|
|
"General/SpeedLimiterEnabled");
|
2020-01-28 14:01:44 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.emulationSpeed, "General/EmulationSpeed");
|
2020-01-24 04:49:49 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "General/StartPaused");
|
2020-01-31 14:05:20 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU/ExecutionMode",
|
|
|
|
&Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName);
|
2020-01-24 04:51:31 +00:00
|
|
|
|
|
|
|
connect(m_ui.biosPathBrowse, &QPushButton::pressed, this, &ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked);
|
2020-01-28 14:01:44 +00:00
|
|
|
|
|
|
|
connect(m_ui.enableSpeedLimiter, &QCheckBox::stateChanged, this,
|
|
|
|
&ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged);
|
|
|
|
connect(m_ui.emulationSpeed, &QSlider::valueChanged, this, &ConsoleSettingsWidget::onEmulationSpeedValueChanged);
|
|
|
|
|
|
|
|
onEnableSpeedLimiterStateChanged();
|
|
|
|
onEmulationSpeedValueChanged(m_ui.emulationSpeed->value());
|
2019-12-31 06:17:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConsoleSettingsWidget::~ConsoleSettingsWidget() = default;
|
2020-01-24 04:51:31 +00:00
|
|
|
|
|
|
|
void ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked()
|
|
|
|
{
|
|
|
|
QString path = QFileDialog::getOpenFileName(this, tr("Select BIOS Image"), QString(), tr(BIOS_IMAGE_FILTER));
|
|
|
|
if (path.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_ui.biosPath->setText(path);
|
|
|
|
|
|
|
|
m_host_interface->putSettingValue("BIOS/Path", path);
|
|
|
|
m_host_interface->applySettings();
|
|
|
|
}
|
2020-01-28 14:01:44 +00:00
|
|
|
|
|
|
|
void ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged()
|
|
|
|
{
|
|
|
|
m_ui.emulationSpeed->setDisabled(!m_ui.enableSpeedLimiter->isChecked());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleSettingsWidget::onEmulationSpeedValueChanged(int value)
|
|
|
|
{
|
|
|
|
m_ui.emulationSpeedLabel->setText(tr("%1%").arg(value));
|
|
|
|
}
|