diff --git a/src/duckstation-qt/portsettingswidget.cpp b/src/duckstation-qt/portsettingswidget.cpp index 2ff7ab526..7d088dfa5 100644 --- a/src/duckstation-qt/portsettingswidget.cpp +++ b/src/duckstation-qt/portsettingswidget.cpp @@ -7,8 +7,11 @@ #include "settingwidgetbinder.h" #include #include +#include #include +static constexpr char MEMORY_CARD_IMAGE_FILTER[] = "All Memory Card Types (*.mcd *.mc)"; + PortSettingsWidget::PortSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */) : QWidget(parent), m_host_interface(host_interface) { @@ -43,6 +46,8 @@ void PortSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* ui) memory_card_layout->addWidget(ui->memory_card_path); ui->memory_card_path_browse = new QPushButton(tr("Browse..."), ui->widget); + connect(ui->memory_card_path_browse, &QPushButton::clicked, + [this, index]() { onBrowseMemoryCardPathClicked(index); }); memory_card_layout->addWidget(ui->memory_card_path_browse); ui->layout->addWidget(new QLabel(tr("Memory Card Path:"), ui->widget)); ui->layout->addLayout(memory_card_layout); @@ -232,3 +237,13 @@ void PortSettingsWidget::onControllerTypeChanged(int index) m_host_interface->applySettings(); createPortBindingSettingsUi(index, &m_port_ui[index], static_cast(type_index)); } + +void PortSettingsWidget::onBrowseMemoryCardPathClicked(int index) +{ + QString path = + QFileDialog::getOpenFileName(this, tr("Select path to memory card image"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)); + if (path.isEmpty()) + return; + + m_port_ui[index].memory_card_path->setText(path); +} diff --git a/src/duckstation-qt/portsettingswidget.h b/src/duckstation-qt/portsettingswidget.h index c50d59cb1..1dd8c13a9 100644 --- a/src/duckstation-qt/portsettingswidget.h +++ b/src/duckstation-qt/portsettingswidget.h @@ -42,6 +42,7 @@ private: void createPortSettingsUi(int index, PortSettingsUI* ui); void createPortBindingSettingsUi(int index, PortSettingsUI* ui, ControllerType ctype); void onControllerTypeChanged(int index); + void onBrowseMemoryCardPathClicked(int index); std::array m_port_ui = {}; };