Refactor memory card loading into a new function

This commit is contained in:
King_DuckZ 2025-02-14 11:53:04 +00:00
parent d35a4f6d08
commit f933d66e55
2 changed files with 8 additions and 3 deletions

View file

@ -82,8 +82,6 @@ void MemoservWin::create_menu(QApplication* app) {
}
void MemoservWin::open_file_from_dialog() {
using std::filesystem::path;
QStringList files = QFileDialog::getOpenFileNames(
this,
tr("Open memory card"),
@ -91,7 +89,12 @@ void MemoservWin::open_file_from_dialog() {
tr("PSX Memory Card") + " (*.mcr *.sav *.srm);;" +
tr("All files") + " (*.*)"
);
for (const auto& file : files) {
load_memory_cards(files);
void MemoservWin::load_memory_cards (const QStringList& paths) {
using std::filesystem::path;
for (const auto& file : paths) {
auto lbl = std::make_unique<QLabel>();
lbl->setText(QString::fromStdString(path(file.toStdString()).filename()));

View file

@ -18,6 +18,7 @@
#pragma once
#include <QMainWindow>
#include <QStringList>
#include <list>
class QApplication;
@ -42,6 +43,7 @@ private:
void show_version_info();
void open_file_from_dialog();
void load_memory_cards (const QStringList& paths);
std::list<mc::psx::MemoryCard> m_memcards;
QGridLayout* m_main_lay;