Qt: Implement browse button for memory card paths
This commit is contained in:
parent
9915d977e4
commit
3272b37853
|
@ -7,8 +7,11 @@
|
|||
#include "settingwidgetbinder.h"
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
||||
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<ControllerType>(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);
|
||||
}
|
||||
|
|
|
@ -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<PortSettingsUI, 2> m_port_ui = {};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue