mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 23:25:41 +00:00
Qt: Implement memory card remove button
This commit is contained in:
parent
3272b37853
commit
1f40d5f77d
|
@ -5,6 +5,7 @@
|
|||
#include "qthostinterface.h"
|
||||
#include "qtutils.h"
|
||||
#include "settingwidgetbinder.h"
|
||||
#include <QtCore/QSignalBlocker>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
|
@ -45,10 +46,14 @@ void PortSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* ui)
|
|||
QStringLiteral("MemoryCards/Card%1Path").arg(index + 1));
|
||||
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);
|
||||
QPushButton* memory_card_path_browse = new QPushButton(tr("Browse..."), ui->widget);
|
||||
connect(memory_card_path_browse, &QPushButton::clicked, [this, index]() { onBrowseMemoryCardPathClicked(index); });
|
||||
memory_card_layout->addWidget(memory_card_path_browse);
|
||||
|
||||
QPushButton* memory_card_remove = new QPushButton(tr("Remove"), ui->widget);
|
||||
connect(memory_card_remove, &QPushButton::clicked, [this, index]() { onEjectMemoryCardClicked(index); });
|
||||
memory_card_layout->addWidget(memory_card_remove);
|
||||
|
||||
ui->layout->addWidget(new QLabel(tr("Memory Card Path:"), ui->widget));
|
||||
ui->layout->addLayout(memory_card_layout);
|
||||
|
||||
|
@ -247,3 +252,11 @@ void PortSettingsWidget::onBrowseMemoryCardPathClicked(int index)
|
|||
|
||||
m_port_ui[index].memory_card_path->setText(path);
|
||||
}
|
||||
|
||||
void PortSettingsWidget::onEjectMemoryCardClicked(int index)
|
||||
{
|
||||
QSignalBlocker blocker(m_port_ui[index].memory_card_path);
|
||||
m_port_ui[index].memory_card_path->setText(QString());
|
||||
m_host_interface->removeSettingValue(QStringLiteral("MemoryCards/Card%1Path").arg(index + 1));
|
||||
m_host_interface->applySettings();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ private:
|
|||
QVBoxLayout* layout;
|
||||
QComboBox* controller_type;
|
||||
QLineEdit* memory_card_path;
|
||||
QPushButton* memory_card_path_browse;
|
||||
QWidget* button_binding_container;
|
||||
};
|
||||
|
||||
|
@ -43,6 +42,7 @@ private:
|
|||
void createPortBindingSettingsUi(int index, PortSettingsUI* ui, ControllerType ctype);
|
||||
void onControllerTypeChanged(int index);
|
||||
void onBrowseMemoryCardPathClicked(int index);
|
||||
void onEjectMemoryCardClicked(int index);
|
||||
|
||||
std::array<PortSettingsUI, 2> m_port_ui = {};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue