Fix inconsistent forward/backward slashes in Memcard Editor

Memcard Editor looks for an exact string match, so slashes must be
consistent.
This commit is contained in:
Silent 2020-12-22 16:14:22 +01:00
parent ca84925ff8
commit bb528fb15c
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
2 changed files with 12 additions and 10 deletions

View file

@ -33,7 +33,7 @@ MemoryCardEditorDialog::~MemoryCardEditorDialog() = default;
bool MemoryCardEditorDialog::setCardA(const QString& path) bool MemoryCardEditorDialog::setCardA(const QString& path)
{ {
const int index = m_ui.cardAPath->findData(QVariant(path)); const int index = m_ui.cardAPath->findData(QVariant(QDir::toNativeSeparators(path)));
if (index < 0) if (index < 0)
return false; return false;
@ -43,7 +43,7 @@ bool MemoryCardEditorDialog::setCardA(const QString& path)
bool MemoryCardEditorDialog::setCardB(const QString& path) bool MemoryCardEditorDialog::setCardB(const QString& path)
{ {
const int index = m_ui.cardBPath->findData(QVariant(path)); const int index = m_ui.cardBPath->findData(QVariant(QDir::toNativeSeparators(path)));
if (index < 0) if (index < 0)
return false; return false;
@ -114,7 +114,8 @@ void MemoryCardEditorDialog::loadCardFromComboBox(Card* card, int index)
QString filename; QString filename;
if (index == 1) if (index == 1)
{ {
filename = QFileDialog::getOpenFileName(this, tr("Select Memory Card"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)); filename = QDir::toNativeSeparators(
QFileDialog::getOpenFileName(this, tr("Select Memory Card"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)));
if (!filename.isEmpty()) if (!filename.isEmpty())
{ {
// add to combo box // add to combo box
@ -238,8 +239,8 @@ void MemoryCardEditorDialog::newCard(Card* card)
{ {
promptForSave(card); promptForSave(card);
QString filename = QString filename = QDir::toNativeSeparators(
QFileDialog::getSaveFileName(this, tr("Select Memory Card"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)); QFileDialog::getSaveFileName(this, tr("Select Memory Card"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)));
if (filename.isEmpty()) if (filename.isEmpty())
return; return;
@ -264,8 +265,8 @@ void MemoryCardEditorDialog::openCard(Card* card)
{ {
promptForSave(card); promptForSave(card);
QString filename = QString filename = QDir::toNativeSeparators(
QFileDialog::getOpenFileName(this, tr("Select Memory Card"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)); QFileDialog::getOpenFileName(this, tr("Select Memory Card"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)));
if (filename.isEmpty()) if (filename.isEmpty())
return; return;

View file

@ -11,7 +11,8 @@
#include <QtWidgets/QFileDialog> #include <QtWidgets/QFileDialog>
#include <QtWidgets/QLabel> #include <QtWidgets/QLabel>
static constexpr char MEMORY_CARD_IMAGE_FILTER[] = QT_TRANSLATE_NOOP("MemoryCardSettingsWidget", "All Memory Card Types (*.mcd *.mcr *.mc)"); static constexpr char MEMORY_CARD_IMAGE_FILTER[] =
QT_TRANSLATE_NOOP("MemoryCardSettingsWidget", "All Memory Card Types (*.mcd *.mcr *.mc)");
MemoryCardSettingsWidget::MemoryCardSettingsWidget(QtHostInterface* host_interface, QWidget* parent, MemoryCardSettingsWidget::MemoryCardSettingsWidget(QtHostInterface* host_interface, QWidget* parent,
SettingsDialog* dialog) SettingsDialog* dialog)
@ -104,8 +105,8 @@ void MemoryCardSettingsWidget::createPortSettingsUi(SettingsDialog* dialog, int
void MemoryCardSettingsWidget::onBrowseMemoryCardPathClicked(int index) void MemoryCardSettingsWidget::onBrowseMemoryCardPathClicked(int index)
{ {
QString path = QString path = QDir::toNativeSeparators(QFileDialog::getOpenFileName(this, tr("Select path to memory card image"),
QFileDialog::getOpenFileName(this, tr("Select path to memory card image"), QString(), tr(MEMORY_CARD_IMAGE_FILTER)); QString(), tr(MEMORY_CARD_IMAGE_FILTER)));
if (path.isEmpty()) if (path.isEmpty())
return; return;