Qt: Implement browse button for BIOS path

This commit is contained in:
Connor McLaughlin 2020-01-24 14:51:31 +10:00
parent 2694181811
commit f05f5aeb2b
2 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,8 @@
#include "consolesettingswidget.h"
#include "settingwidgetbinder.h"
#include <QtWidgets/QFileDialog>
static constexpr char BIOS_IMAGE_FILTER[] = "Binary Images (*.bin);;All Files (*.*)";
ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
: QWidget(parent), m_host_interface(host_interface)
@ -14,6 +17,20 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter,
"General/SpeedLimiterEnabled");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "General/StartPaused");
connect(m_ui.biosPathBrowse, &QPushButton::pressed, this, &ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked);
}
ConsoleSettingsWidget::~ConsoleSettingsWidget() = default;
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();
}

View File

@ -14,6 +14,9 @@ public:
explicit ConsoleSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
~ConsoleSettingsWidget();
private Q_SLOTS:
void onBrowseBIOSPathButtonClicked();
private:
Ui::ConsoleSettingsWidget m_ui;